I can delete my supabase folder and begin from scratch pulling the current schema of the db?

Hi everyone, I built an MVP using only the main branch where I have many customers using my app, but I want to make it scalable and maintable in a long-term, so I decided to use the branching of supabase with GitHub Integration, so I created other branch called QA-Testing but I got some errors in the migration that look like this
Applying migration 20241011_admin_impersonation.sql...
Applying migration 20241011_create_admin_impersonation_table.sql...
NOTICE (42P07): relation "admin_impersonation_logs" already exists, skipping
NOTICE (42P07): relation "idx_admin_impersonation_logs_admin_id" already exists, skipping
NOTICE (42P07): relation "idx_admin_impersonation_logs_impersonated_user_id" already exists, skipping
NOTICE (42P07): relation "idx_admin_impersonation_logs_created_at" already exists, skipping
2025/11/24 20:12:40 ERROR: syntax error at or near "NOT" (SQLSTATE 42601)
At statement: 5
-- Only admins can insert logs (for their own actions)
CREATE POLICY IF NOT EXISTS "Admins can insert their own impersonation logs" ON public.admin_impersonation_logs
Applying migration 20241011_admin_impersonation.sql...
Applying migration 20241011_create_admin_impersonation_table.sql...
NOTICE (42P07): relation "admin_impersonation_logs" already exists, skipping
NOTICE (42P07): relation "idx_admin_impersonation_logs_admin_id" already exists, skipping
NOTICE (42P07): relation "idx_admin_impersonation_logs_impersonated_user_id" already exists, skipping
NOTICE (42P07): relation "idx_admin_impersonation_logs_created_at" already exists, skipping
2025/11/24 20:12:40 ERROR: syntax error at or near "NOT" (SQLSTATE 42601)
At statement: 5
-- Only admins can insert logs (for their own actions)
CREATE POLICY IF NOT EXISTS "Admins can insert their own impersonation logs" ON public.admin_impersonation_logs
I tried to delete this table called admin_impersonation_logs from my main database and do the migration again, but I got the same errors, so I understand the branching doesn't work this way. So, my first question is when I create a new branch from supabase It takes all my migrations that I have in my main branch and execute in the new branch to create the proper schemas, right?. My another question is how I can resolve this, I was thinking to delete the migrations regarding to the wrong table like 20241011_admin_impersonation.sql and do the migration again and the other approach is to delete all my supabase folder and begin from scratch pulling a unique schema of my database, this way avoid to have all of these migrations that I have made in the main branch. It would be very helpful if someone can give me some advices, I'm new in the branching of supabase, thanks.
No description
2 Replies
ibrahim
ibrahim4d ago
i would look inside of the cli and first check if your migration history is aligned well with supabase using supabase migration list i think that CREATE POLICY IF NOT EXISTS is not valid so you need to change that
ibrahim
ibrahim4d ago
but if you are going to mess with migration files and remote migrations you might need to run repair https://supabase.com/docs/reference/cli/supabase-migration-repair
CLI Reference | Supabase Docs
CLI reference for the Supabase CLI

Did you find this page helpful?