Error while using prisma migrate init: The above error occurred in the <TabIndexProvider> component: #521
Comments
I am seeing the same error. I have followed the same instructions, the only difference that I am on I used the example model definition in the startup guide. I also see the same result with a stripped down
Interestingly, the Generating the client before running migrations does not appear to make a difference. I don't see the This issue is a blocker for some work I'm doing, so I will continue to dig down and try to find a root cause and try to provide any more observations which might be relevant. |
I have tried down-grading versions. I see the same error on
|
Good find!
This one sounds like a db specific error, I'm not sure. I'm guessing it should work fine for sqlite. Let me know if it works for a different DB. I should be able to proceed with sqlite then. Thanks @timleslie |
@joelewis Haven't tried it with sqlite, I'm kind of tied to postgres for my current use case. Running with
|
Adding more debug env vars:
|
@timleslie Never knew this. Once used, it revealed the actual error. I had a model with no unique id column and the migration was successful once I fixed my .schema file. The cause of failure should have been revealed even without the DEBUG flag. Thanks for the tip. |
Tracking down the postgres logs I see the following:
This suggests the the query causing the issue is in libs/sql-schema-describer/src/postgres.rs at line 434 with the query: SELECT
indexInfos.relname as name,
columnInfos.attname AS column_name,
rawIndex.indisunique AS is_unique,
rawIndex.indisprimary AS is_primary_key,
tableInfos.relname AS table_name,
rawIndex.indkeyidx,
pg_get_serial_sequence('"' || $1 || '"."' || tableInfos.relname || '"', columnInfos.attname) AS sequence_name
FROM
-- pg_class stores infos about tables, indices etc: https://www.postgresql.org/docs/current/catalog-pg-class.html
pg_class tableInfos,
pg_class indexInfos,
-- pg_index stores indices: https://www.postgresql.org/docs/current/catalog-pg-index.html
(
SELECT
indrelid,
indexrelid,
indisunique,
indisprimary,
pg_index.indkey AS indkey,
generate_subscripts(pg_index.indkey, 1) AS indkeyidx
FROM pg_index
GROUP BY indrelid, indexrelid, indisunique, indisprimary, indkeyidx, indkey
ORDER BY indrelid, indexrelid, indkeyidx
) rawIndex,
-- pg_attribute stores infos about columns: https://www.postgresql.org/docs/current/catalog-pg-attribute.html
pg_attribute columnInfos,
-- pg_namespace stores info about the schema
pg_namespace schemaInfo
WHERE
-- find table info for index
tableInfos.oid = rawIndex.indrelid
-- find index info
AND indexInfos.oid = rawIndex.indexrelid
-- find table columns
AND columnInfos.attrelid = tableInfos.oid
AND columnInfos.attnum = rawIndex.indkey[rawIndex.indkeyidx]
-- we only consider ordinary tables
AND tableInfos.relkind = 'r'
-- we only consider stuff out of one specific schema
AND tableInfos.relnamespace = schemaInfo.oid
AND schemaInfo.nspname = $1
GROUP BY tableInfos.relname, indexInfos.relname, rawIndex.indisunique, rawIndex.indisprimary, columnInfos.attname, rawIndex.indkeyidx
ORDER BY rawIndex.indkeyidx Running this query from within
|
I spun up a completely brand new database and re-ran the init migration and everything works fine. I'm concluding that the database I have been using for testing has somehow become internally corrupted, which is what's causing the obscure failures. The original problem described in this issue regarding Thanks @joelewis for letting me know that you were able to get migrate to work after seeing the error and fixing your schema, it helped point me towards something unique in my setup, rather than something wrong in the core of prisma 👍 |
bumping as I am also experiencing this when upgrading to 2.2.2 from 2.2.0 today |
I'm starting to play around with prisma. And wanted to create my db tables using prisma migrate. Following the guide from https://www.prisma.io/docs/getting-started/setup-prisma/start-from-scratch-prisma-migrate-typescript-postgres
After defining my prisma.schema file, I'm trying to generate the migrations using
npx prisma migrate save --name init --experimental
But it's ending up with a blunt error in my terminal as below:
Machine/OS: Mac OS Mojave
Default Terminal Application
How to reproduce
Steps to reproduce the behavior:
npx prisma migrate save --name init --experimental
Expected behavior
Expected a successful command execution
Environment & setup
The text was updated successfully, but these errors were encountered: