planetscale/database-js

New tables not found in foreign key enabled cluster

AndrewBarba opened this issue · 2 comments

Setup

I have a cluster in the foreign key beta and I've successfully migrated tables into the cluster using the PS migrator.

Issue

When connecting the database using database-js, any new table I add to the cluster returns a "table not found" error when I try and query it. Using the regular mysql2 driver works fine. Any table that was added as part of the migration does seem to query correctly using database-js, its limited to tables added after the migration.

Can you explain what you mean by that? And what your connection string is when it works with mysql2? Please censor the username/password.

Fundamentally database-js doesn't work differently with regard to tables being visible or not.

Recapping from Discord this wasn't an error relating to the FK constraints beta. The problem was that during the import, since there are multiple databases, and database-js does not pass the database name, you got the error.

Once an import is complete we expect everything is all good again. It's confusing and we'll make it better - in #163 we're adding support to set the database name. We're also thinking of inferring the database name from the database URL but have not started any work on this yet.