Closed totzk9 closed 1 year ago
Hi @totzk9, I need to know more about your schema to help with debugging. Could you create a support ticket by going to Help > Contact Support via the dashboard?
Just had to create a new project then added the same tables. It's now working. But I think it's still a bug for the previous project.
Sounds like the difference is this prompt
Update remote migration history table? [Y/n] n
You want to answer Y here so that existing migrations are not applied twice. Since add constraint
is not idempotent, applying twice would throw an error.
No it was still an issue even I answered Y
and another error occurs
Do you have the logs for the other error? It wouldn't be possible to debug a new error with existing logs.
I'm having same issue, started on clean slate but still got the same error:
ERROR: multiple primary keys for table "schema_migrations" are not allowed (SQLSTATE 42P16) At statement 48: ALTER TABLE ONLY "supabase_migrations"."schema_migrations" ADD CONSTRAINT "schema_migrations_pkey" PRIMARY KEY ("version")
Update remote migration history table? [Y/n]
I did answer "Yes" here.
I also have the same issue as well
I also have the same issue with a fresh project!
I was able to work around this and fix the error. Delele all the migration files and to start fresh.
Insted of using the command
supabase db pull
to pull my schema from my remote DB. I used this command
supabase db diff -f migration_file_name --linked
make sure you have liked to your supabase instace to your CLI before running the above command ☝🏼
Note --linked
means you have you DB on supabase.com, if you have a self hosted instance you replace --linked
with --db-url DB_URL
After you have succesfully have your new migration files populated, run the command
supabsae db reset
Hope it helps you all
I believe this is a regression introduced by this PR https://github.com/supabase/cli/pull/1783. I will work on a fix.
Having the same issue.
I believe the issues still exists ... having the same issue. supabase CLI version - 1.131.5
supabase db pull
error output
Connecting to remote database...
Setting up initial schema....
Applying migration 20240117205057_remote_schema.sql...
ERROR: multiple primary keys for table "schema_migrations" are not allowed (SQLSTATE 42P16)
At statement 90: ALTER TABLE ONLY "supabase_migrations"."schema_migrations"
ADD CONSTRAINT "schema_migrations_pkey" PRIMARY KEY ("version")
Try rerunning the command with --debug to troubleshoot the error.
@AmitMirgal you need to use the beta version for now npx supabase@beta db pull
The fix will be released to stable next Tuesday.
I am still experiencing the same issue with npx supabase@beta
npx supabase@beta db pull
npx supabase@beta migration up
Connecting to local database...
Applying migration 20240121013831_remote_schema.sql...
ERROR: multiple primary keys for table "schema_migrations" are not allowed (SQLSTATE 42P16)
At statement 23: ALTER TABLE ONLY "supabase_migrations"."schema_migrations"
ADD CONSTRAINT "schema_migrations_pkey" PRIMARY KEY ("version")
Try rerunning the command with --debug to troubleshoot the error.
I am facing a similar issue while trying to setup a local instance. (also tried the beta pull.
Same...
Same
Seems like too many errors caused by having supabase_migrations
schema pulled as a migration. I've reverted that behaviour in beta release v1.138.1.
For those having errors, please rerun npx supabase@beta db pull
. Apologies for the inconvenience.
@sweatybridge New errors using the @beta portion
$ npx supabase@beta db pull --workdir ./src --linked --schema public
Enter your database password:
Connecting to remote database...
Skipping migration .DS_Store... (file name must match pattern "<timestamp>_name.sql")
pg_dump: error: no matching extensions were found
error running container: exit 1
The auth and storage schemas are excluded. Run supabase db pull --schema auth,storage again to diff them.
error Command failed with exit code 1.
droping the @beta portion then worked for me.
@MaximusMcCann ~please run beta again with db dump --create-ticket
flag. I need more system info to reproduce~
EDIT: I found the issue after enabling --debug
logs. A new beta release is ~on the way~ done.
I have a similar problem to @AmitMirgal when trying to run the 'Deploy Migrations to Staging' workflow:
supabase db push
error output
Connecting to remote database...
Applying migration 20240202123856_remote_schema.sql...
ERROR: multiple primary keys for table "schema_migrations" are not allowed (SQLSTATE 42P16)
At statement 71: ALTER TABLE ONLY "supabase_migrations"."schema_migrations"
ADD CONSTRAINT "schema_migrations_pkey" PRIMARY KEY ("version")
Try rerunning the command with --debug to troubleshoot the error.
I was following the instructions from here, copying example file .github/workflows/staging.yml. I have already tried changing to using the pre-release version v1.138.2 (which should include PR #1889) instead of 'latest'. This doesn't seem to make a difference, though.
I'm currently setting up my development environment with local/staging/production and my staging project is still empty. This was supposed to be the first push to the staging project. For the CI GitHub action I'm currently using pre-release version v1.137.3, due to another problem I ran into, not sure if that could make any difference.
https://github.com/supabase/supabase/issues/20405#issuecomment-1902276878
this fixed it for me
Describe the bug ERROR: multiple primary keys for table.
To Reproduce Steps to reproduce the behavior:
Expected behavior Should not error
Screenshots
Desktop (please complete the following information):
Additional context Add any other context about the problem here.