When pushing migrations to Supabase, it skips saying the schema "drizzle" already exists.

When I update my schema and try to push the migration to Supabase, I get the following error. How can I move forward with pushing it as opposed to having it skip?

I guess part of the issue is I don't understand how migrations really work so not sure what this error is telling me is wrong. In my database, I already have 2 entries in a table called __drizzle_migrations under the drizzle schema that was auto-created by drizzle-kit when migrating the first few times

Migrating...
{
  severity_local: 'NOTICE',
  severity: 'NOTICE',
  code: '42P06',
  message: 'schema "drizzle" already exists, skipping',
  file: 'schemacmds.c',
  line: '128',
  routine: 'CreateSchemaCommand'
}
{
  severity_local: 'NOTICE',
  severity: 'NOTICE',
  code: '42P07',
  message: 'relation "__drizzle_migrations" already exists, skipping',
  file: 'parse_utilcmd.c',
  line: '209',
  routine: 'transformCreateStmt'
}


My migration file looks like this:
import postgres from "postgres";
import { drizzle, PostgresJsDatabase } from "drizzle-orm/postgres-js";
import { migrate } from "drizzle-orm/postgres-js/migrator";

import { env } from "@core/env";

const client = postgres(env.POSTGRES_DB_URL, {
    ssl: { rejectUnauthorized: false },
});

async function postgresMigrate() {
    try {
        const db: PostgresJsDatabase = drizzle(client);

        // Migrate
        console.log("Migrating...");
        await migrate(db, { migrationsFolder: "drizzle" });
        console.log("Done!");
    } finally {
        process.exit(0);
    }
}

postgresMigrate();
Was this page helpful?