cli icon indicating copy to clipboard operation
cli copied to clipboard

Cannot start local project from a remote one, db reset isn't working - ERROR: type already exists

Open pduthoit opened this issue 9 months ago • 0 comments

Describe the bug When initing a local project from an existing remote one. It seems migrations are ran two times and then ending in double declarations :

ERROR: type "access" already exists (SQLSTATE 42710)
At statement 20:                                            
CREATE TYPE "public"."access" AS ENUM (             
    'private',                                              
    'public'                                                
)

Here it's an enum but it could have been any sql statements afterwards. (it's just the first one that fails)

To Reproduce

What I did :

  1. Make sure all data are wiped.
supabase stop
docker volume rm supabase_config_my-project supabase_db_my-project supabase_inbucket_my-project supabase_storage_my-project
rm -rf supabase
supabase init
supabase start
supabase link

supabase db pull
Connecting to remote database...
Schema written to supabase/migrations/20250513153147_remote_schema.sql
Update remote migration history table? [Y/n] Y
NOTICE (42P06): schema "supabase_migrations" already exists, skipping
NOTICE (42P07): relation "schema_migrations" already exists, skipping
NOTICE (42701): column "statements" of relation "schema_migrations" already exists, skipping
NOTICE (42701): column "name" of relation "schema_migrations" already exists, skipping
Repaired migration history: [20250513153147] => applied
Finished supabase db pull.
The auth and storage schemas are excluded. Run supabase db pull --schema auth,storage again to diff them.

supabase db pull --schema auth,storage
Connecting to remote database...
Initialising schema...base...
Seeding globals from roles.sql...
Applying migration 20250513153147_remote_schema.sql...
Schema written to supabase/migrations/20250513153240_remote_schema.sql
Update remote migration history table? [Y/n] Y
NOTICE (42P06): schema "supabase_migrations" already exists, skipping
NOTICE (42P07): relation "schema_migrations" already exists, skipping
NOTICE (42701): column "statements" of relation "schema_migrations" already exists, skipping
NOTICE (42701): column "name" of relation "schema_migrations" already exists, skipping
Repaired migration history: [20250513153240] => applied
Finished supabase db pull.

supabase db reset --debug
Supabase CLI 2.22.12
Resetting local database...
Recreating database...
2025/05/13 17:36:07 PG Send: {"Type":"StartupMessage","ProtocolVersion":196608,"Parameters":{"database":"postgres","user":"postgres"}}
2025/05/13 17:36:07 PG Recv: {"Type":"AuthenticationSASL","AuthMechanisms":["SCRAM-SHA-256"]}
2025/05/13 17:36:07 PG Send: {"Type":"SASLInitialResponse","AuthMechanism":"SCRAM-SHA-256","Data":"n,,n=,r=1yMebgHk11IWqVeg/UZTbqlg"}
2025/05/13 17:36:07 PG Recv: {"Type":"AuthenticationSASLContinue","Data":"r=1yMebgHk11IWqVeg/UZTbqlg/7OyXsj21W2Wdg5bM9CzEZEg,s=bfojCXcFMuvaw3scW0ml+Q==,i=4096"}
2025/05/13 17:36:07 PG Send: {"Type":"SASLResponse","Data":"c=biws,r=1yMebgHk11IWqVeg/UZTbqlg/7OyXsj21W2Wdg5bM9CzEZEg,p=b0XU+nDU7zhnBY73Vf1/6mGfAs0ztBW0L5SAHwlXUtQ="}
2025/05/13 17:36:07 PG Recv: {"Type":"AuthenticationSASLFinal","Data":"v=xTGRPf/yxjvQ4qnYCPBXXF02+dWrwAEAJ/hBz4h8VnY="}
2025/05/13 17:36:07 PG Recv: {"Type":"AuthenticationOK"}
2025/05/13 17:36:07 PG Recv: {"Type":"ParameterStatus","Name":"application_name","Value":""}
2025/05/13 17:36:07 PG Recv: {"Type":"ParameterStatus","Name":"client_encoding","Value":"UTF8"}
2025/05/13 17:36:07 PG Recv: {"Type":"ParameterStatus","Name":"DateStyle","Value":"ISO, MDY"}
2025/05/13 17:36:07 PG Recv: {"Type":"ParameterStatus","Name":"default_transaction_read_only","Value":"off"}
2025/05/13 17:36:07 PG Recv: {"Type":"ParameterStatus","Name":"in_hot_standby","Value":"off"}
2025/05/13 17:36:07 PG Recv: {"Type":"ParameterStatus","Name":"integer_datetimes","Value":"on"}
2025/05/13 17:36:07 PG Recv: {"Type":"ParameterStatus","Name":"IntervalStyle","Value":"postgres"}
2025/05/13 17:36:07 PG Recv: {"Type":"ParameterStatus","Name":"is_superuser","Value":"off"}
2025/05/13 17:36:07 PG Recv: {"Type":"ParameterStatus","Name":"server_encoding","Value":"UTF8"}
2025/05/13 17:36:07 PG Recv: {"Type":"ParameterStatus","Name":"server_version","Value":"15.8"}
2025/05/13 17:36:07 PG Recv: {"Type":"ParameterStatus","Name":"session_authorization","Value":"postgres"}
2025/05/13 17:36:07 PG Recv: {"Type":"ParameterStatus","Name":"standard_conforming_strings","Value":"on"}
2025/05/13 17:36:07 PG Recv: {"Type":"ParameterStatus","Name":"TimeZone","Value":"UTC"}
2025/05/13 17:36:07 PG Recv: {"Type":"BackendKeyData","ProcessID":7773,"SecretKey":2089102415}
2025/05/13 17:36:07 PG Recv: {"Type":"ReadyForQuery","TxStatus":"I"}
Initialising schema...
+ ulimit -n
+ '[' '!' -z '' ']'
+ export ERL_CRASH_DUMP=/tmp/erl_crash.dump
+ ERL_CRASH_DUMP=/tmp/erl_crash.dump
+ '[' false = true ']'
+ echo 'Running migrations'
+ sudo -E -u nobody /app/bin/migrate
+ '[' true = true ']'
+ echo 'Seeding selfhosted Realtime'
+ sudo -E -u nobody /app/bin/realtime eval 'Realtime.Release.seeds(Realtime.Repo)'
+ echo 'Starting Realtime'
+ ulimit -n
+ exec /app/bin/realtime eval '{:ok, _} = Application.ensure_all_started(:realtime)
{:ok, _} = Realtime.Tenants.health_check("realtime-dev")'
[os_mon] memory supervisor port (memsup): Erlang has closed
[os_mon] cpu supervisor port (cpu_sup): Erlang has closed
Seeding globals from roles.sql...
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"SET lock_timeout = '4s'","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"CREATE SCHEMA IF NOT EXISTS supabase_migrations","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"CREATE TABLE IF NOT EXISTS supabase_migrations.schema_migrations (version text NOT NULL PRIMARY KEY)","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"ALTER TABLE supabase_migrations.schema_migrations ADD COLUMN IF NOT EXISTS statements text[]","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"ALTER TABLE supabase_migrations.schema_migrations ADD COLUMN IF NOT EXISTS name text","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Sync"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"NoData"}
2025/05/13 17:36:25 PG Recv: {"Type":"CommandComplete","CommandTag":"SET"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"NoData"}
2025/05/13 17:36:25 PG Recv: {"Severity":"NOTICE","SeverityUnlocalized":"NOTICE","Code":"42P06","Message":"schema \"supabase_migrations\" already exists, skipping","Detail":"","Hint":"","Position":0,"InternalPosition":0,"InternalQuery":"","Where":"","SchemaName":"","TableName":"","ColumnName":"","DataTypeName":"","ConstraintName":"","File":"schemacmds.c","Line":131,"Routine":"CreateSchemaCommand","UnknownFields":null}
NOTICE (42P06): schema "supabase_migrations" already exists, skipping
2025/05/13 17:36:25 PG Recv: {"Type":"CommandComplete","CommandTag":"CREATE SCHEMA"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"NoData"}
2025/05/13 17:36:25 PG Recv: {"Severity":"NOTICE","SeverityUnlocalized":"NOTICE","Code":"42P07","Message":"relation \"schema_migrations\" already exists, skipping","Detail":"","Hint":"","Position":0,"InternalPosition":0,"InternalQuery":"","Where":"","SchemaName":"","TableName":"","ColumnName":"","DataTypeName":"","ConstraintName":"","File":"parse_utilcmd.c","Line":207,"Routine":"transformCreateStmt","UnknownFields":null}
NOTICE (42P07): relation "schema_migrations" already exists, skipping
2025/05/13 17:36:25 PG Recv: {"Type":"CommandComplete","CommandTag":"CREATE TABLE"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"NoData"}
2025/05/13 17:36:25 PG Recv: {"Severity":"NOTICE","SeverityUnlocalized":"NOTICE","Code":"42701","Message":"column \"statements\" of relation \"schema_migrations\" already exists, skipping","Detail":"","Hint":"","Position":0,"InternalPosition":0,"InternalQuery":"","Where":"","SchemaName":"","TableName":"","ColumnName":"","DataTypeName":"","ConstraintName":"","File":"tablecmds.c","Line":7216,"Routine":"check_for_column_name_collision","UnknownFields":null}
NOTICE (42701): column "statements" of relation "schema_migrations" already exists, skipping
2025/05/13 17:36:25 PG Recv: {"Type":"CommandComplete","CommandTag":"ALTER TABLE"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"NoData"}
2025/05/13 17:36:25 PG Recv: {"Severity":"NOTICE","SeverityUnlocalized":"NOTICE","Code":"42701","Message":"column \"name\" of relation \"schema_migrations\" already exists, skipping","Detail":"","Hint":"","Position":0,"InternalPosition":0,"InternalQuery":"","Where":"","SchemaName":"","TableName":"","ColumnName":"","DataTypeName":"","ConstraintName":"","File":"tablecmds.c","Line":7216,"Routine":"check_for_column_name_collision","UnknownFields":null}
NOTICE (42701): column "name" of relation "schema_migrations" already exists, skipping
2025/05/13 17:36:25 PG Recv: {"Type":"CommandComplete","CommandTag":"ALTER TABLE"}
2025/05/13 17:36:25 PG Recv: {"Type":"ReadyForQuery","TxStatus":"I"}
Applying migration 20250513153147_remote_schema.sql...
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"SET statement_timeout = 0","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"SET lock_timeout = 0","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"SET idle_in_transaction_session_timeout = 0","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"SET client_encoding = 'UTF8'","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"SET standard_conforming_strings = on","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"SELECT pg_catalog.set_config('search_path', '', false)","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"SET check_function_bodies = false","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"SET xmloption = content","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"SET client_min_messages = warning","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"SET row_security = off","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"CREATE EXTENSION IF NOT EXISTS \"pg_cron\" WITH SCHEMA \"pg_catalog\"","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"CREATE EXTENSION IF NOT EXISTS \"pgsodium\"","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"COMMENT ON SCHEMA \"public\" IS '@graphql({\"inflect_names\": true})'","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"CREATE EXTENSION IF NOT EXISTS \"pg_graphql\" WITH SCHEMA \"graphql\"","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"CREATE EXTENSION IF NOT EXISTS \"pg_stat_statements\" WITH SCHEMA \"extensions\"","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"CREATE EXTENSION IF NOT EXISTS \"pgcrypto\" WITH SCHEMA \"extensions\"","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"CREATE EXTENSION IF NOT EXISTS \"pgjwt\" WITH SCHEMA \"extensions\"","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"CREATE EXTENSION IF NOT EXISTS \"supabase_vault\" WITH SCHEMA \"vault\"","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"CREATE EXTENSION IF NOT EXISTS \"unaccent\" WITH SCHEMA \"extensions\"","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\" WITH SCHEMA \"extensions\"","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"CREATE TYPE \"public\".\"access\" AS ENUM (\n    'private',\n    'public'\n)","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"RESET ALL","ParameterOIDs":null}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Parse","Name":"","Query":"INSERT INTO supabase_migrations.schema_migrations(version, name, statements) VALUES($1, $2, $3)","ParameterOIDs":[25,25,1009]}
2025/05/13 17:36:25 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":[0,0,1],"Parameters":[{"text":"20250513153147"},{"text":"remote_schema"},{"binary":"0000000100000000000000190000001600000001000000195345542073746174656d656e745f74696d656f7574203d203000000014534554206c6f636b5f74696d656f7574203d20300000002b5345542069646c655f696e5f7472616e73616374696f6e5f73657373696f6e5f74696d656f7574203d20300000001c53455420636c69656e745f656e636f64696e67203d2027555446382700000024534554207374616e646172645f636f6e666f726d696e675f737472696e6773203d206f6e0000003653454c4543542070675f636174616c6f672e7365745f636f6e66696728277365617263685f70617468272c2027272c2066616c7365290000002153455420636865636b5f66756e6374696f6e5f626f64696573203d2066616c73650000001753455420786d6c6f7074696f6e203d20636f6e74656e740000002153455420636c69656e745f6d696e5f6d65737361676573203d207761726e696e670000001653455420726f775f7365637572697479203d206f66660000004143524541544520455854454e53494f4e204946204e4f5420455849535453202270675f63726f6e22205749544820534348454d41202270675f636174616c6f67220000002943524541544520455854454e53494f4e204946204e4f542045584953545320227067736f6469756d2200000041434f4d4d454e54204f4e20534348454d4120227075626c6963222049532027406772617068716c287b22696e666c6563745f6e616d6573223a20747275657d29270000004143524541544520455854454e53494f4e204946204e4f5420455849535453202270675f6772617068716c22205749544820534348454d4120226772617068716c220000004c43524541544520455854454e53494f4e204946204e4f5420455849535453202270675f737461745f73746174656d656e747322205749544820534348454d412022657874656e73696f6e73220000004243524541544520455854454e53494f4e204946204e4f54204558495354532022706763727970746f22205749544820534348454d412022657874656e73696f6e73220000003f43524541544520455854454e53494f4e204946204e4f5420455849535453202270676a777422205749544820534348454d412022657874656e73696f6e73220000004343524541544520455854454e53494f4e204946204e4f5420455849535453202273757061626173655f7661756c7422205749544820534348454d4120227661756c74220000004243524541544520455854454e53494f4e204946204e4f54204558495354532022756e616363656e7422205749544820534348454d412022657874656e73696f6e73220000004343524541544520455854454e53494f4e204946204e4f54204558495354532022757569642d6f73737022205749544820534348454d412022657874656e73696f6e73220000004d435245415445205459504520227075626c6963222e226465726f756c655f6163636573732220415320454e554d20280a202020202770726976617465272c0a20202020277075626c6963270a2900000009524553455420414c4c"}],"ResultFormatCodes":[]}
2025/05/13 17:36:25 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2025/05/13 17:36:25 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2025/05/13 17:36:25 PG Send: {"Type":"Sync"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"NoData"}
2025/05/13 17:36:25 PG Recv: {"Type":"CommandComplete","CommandTag":"SET"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"NoData"}
2025/05/13 17:36:25 PG Recv: {"Type":"CommandComplete","CommandTag":"SET"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"NoData"}
2025/05/13 17:36:25 PG Recv: {"Type":"CommandComplete","CommandTag":"SET"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"NoData"}
2025/05/13 17:36:25 PG Recv: {"Type":"CommandComplete","CommandTag":"SET"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"NoData"}
2025/05/13 17:36:25 PG Recv: {"Type":"CommandComplete","CommandTag":"SET"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"RowDescription","Fields":[{"Name":"set_config","TableOID":0,"TableAttributeNumber":0,"DataTypeOID":25,"DataTypeSize":-1,"TypeModifier":-1,"Format":0}]}
2025/05/13 17:36:25 PG Recv: {"Type":"DataRow","Values":[{"text":""}]}
2025/05/13 17:36:25 PG Recv: {"Type":"CommandComplete","CommandTag":"SELECT 1"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"NoData"}
2025/05/13 17:36:25 PG Recv: {"Type":"CommandComplete","CommandTag":"SET"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"NoData"}
2025/05/13 17:36:25 PG Recv: {"Type":"CommandComplete","CommandTag":"SET"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"NoData"}
2025/05/13 17:36:25 PG Recv: {"Type":"CommandComplete","CommandTag":"SET"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"NoData"}
2025/05/13 17:36:25 PG Recv: {"Type":"CommandComplete","CommandTag":"SET"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"NoData"}
2025/05/13 17:36:25 PG Recv: {"Type":"CommandComplete","CommandTag":"CREATE EXTENSION"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"NoData"}
2025/05/13 17:36:25 PG Recv: {"Type":"CommandComplete","CommandTag":"CREATE EXTENSION"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"NoData"}
2025/05/13 17:36:25 PG Recv: {"Type":"CommandComplete","CommandTag":"COMMENT"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"NoData"}
2025/05/13 17:36:25 PG Recv: {"Type":"CommandComplete","CommandTag":"CREATE EXTENSION"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"NoData"}
2025/05/13 17:36:25 PG Recv: {"Type":"CommandComplete","CommandTag":"CREATE EXTENSION"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"NoData"}
2025/05/13 17:36:25 PG Recv: {"Type":"CommandComplete","CommandTag":"CREATE EXTENSION"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"NoData"}
2025/05/13 17:36:25 PG Recv: {"Type":"CommandComplete","CommandTag":"CREATE EXTENSION"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"NoData"}
2025/05/13 17:36:25 PG Recv: {"Type":"CommandComplete","CommandTag":"CREATE EXTENSION"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"NoData"}
2025/05/13 17:36:25 PG Recv: {"Type":"CommandComplete","CommandTag":"CREATE EXTENSION"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"NoData"}
2025/05/13 17:36:25 PG Recv: {"Type":"CommandComplete","CommandTag":"CREATE EXTENSION"}
2025/05/13 17:36:25 PG Recv: {"Type":"ParseComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"BindComplete"}
2025/05/13 17:36:25 PG Recv: {"Type":"NoData"}
2025/05/13 17:36:25 PG Recv: {"Type":"ErrorResponse","Severity":"ERROR","SeverityUnlocalized":"ERROR","Code":"42710","Message":"type \"access\" already exists","Detail":"","Hint":"","Position":0,"InternalPosition":0,"InternalQuery":"","Where":"","SchemaName":"","TableName":"","ColumnName":"","DataTypeName":"","ConstraintName":"","File":"typecmds.c","Line":1167,"Routine":"DefineEnum","UnknownFields":null}
2025/05/13 17:36:25 PG Recv: {"Type":"ReadyForQuery","TxStatus":"I"}
2025/05/13 17:36:25 PG Send: {"Type":"Terminate"}
ERROR: type "access" already exists (SQLSTATE 42710)
At statement 20:                                            
CREATE TYPE "public"."access" AS ENUM (             
    'private',                                              
    'public'                                                
)

my supabase/migrations/20250513153147_remote_schema.sql file (reduced further sql on purpose only to keep CREATE TYPE "public"."access" AS ENUM query)

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

CREATE EXTENSION IF NOT EXISTS "pg_cron" WITH SCHEMA "pg_catalog";
CREATE EXTENSION IF NOT EXISTS "pgsodium";
COMMENT ON SCHEMA "public" IS '@graphql({"inflect_names": true})';
CREATE EXTENSION IF NOT EXISTS "pg_graphql" WITH SCHEMA "graphql";
CREATE EXTENSION IF NOT EXISTS "pg_stat_statements" WITH SCHEMA "extensions";
CREATE EXTENSION IF NOT EXISTS "pgcrypto" WITH SCHEMA "extensions";
CREATE EXTENSION IF NOT EXISTS "pgjwt" WITH SCHEMA "extensions";
CREATE EXTENSION IF NOT EXISTS "supabase_vault" WITH SCHEMA "vault";
CREATE EXTENSION IF NOT EXISTS "unaccent" WITH SCHEMA "extensions";
CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA "extensions";
CREATE TYPE "public"."access" AS ENUM (
    'private',
    'public'
);

-- other sql queries

RESET ALL;
  1. See error

Expected behavior Database should start from a clean schema reproducing remote one

System information

  • Ticket ID: 0967e39f6a814270a5a0fc16f7dad3f4
  • Version of OS: Ubuntu 24.04 (running on Windows WSL)
  • Version of CLI: v2.22.12
  • Version of Docker: v26.1.1
  • Versions of services:
SERVICE IMAGE LOCAL LINKED
supabase/postgres 15.8.1.082 15.8.1.082
supabase/gotrue v2.172.1 v2.172.1
postgrest/postgrest v12.2.3 v12.2.3
supabase/realtime v2.34.47 -
supabase/storage-api v1.22.11 -
supabase/edge-runtime v1.67.4 -
supabase/studio 2025.05.05-sha-3c3fe9b -
supabase/postgres-meta v0.88.9 -
supabase/logflare 1.12.0 -
supabase/supavisor 2.5.1 -

Additional context Getting this issue for quite some time now (so it's not necessarily specific to this new cli version), not able to run a local supabase project.

Few guesses on this :

  • For an unknown reason maybe migrations are ran multiple times. (ERROR: type "access" already exists (SQLSTATE 42710))
  • Even if it seems db is set as local, could it be that the migration are ran on the remote where for example the enum is already set.
  • Even if I removed i think all data, volumes and local db, migrations list is not up to date with the db status.

Any idea on this issue ? maybe you would have more clues and ideas about it, maybe just a dumb thing. (Probably, as I haven't found any other ticket about it)

pduthoit avatar May 14 '25 07:05 pduthoit