PostgresError: relation "public.artist" does not exist

Hi, I'm new to drizzle. I am getting this error while trying to apply migrations,
  npm run db:migrate

> app@0.0.1 db:migrate
> tsx src/lib/database/migrate.ts

{
  severity_local: 'NOTICE',
  severity: 'NOTICE',
  code: '42P06',
  message: 'schema "drizzle" already exists, skipping',
  file: 'schemacmds.c',
  line: '131',
  routine: 'CreateSchemaCommand'
}
{
  severity_local: 'NOTICE',
  severity: 'NOTICE',
  code: '42P07',
  message: 'relation "__drizzle_migrations" already exists, skipping',
  file: 'parse_utilcmd.c',
  line: '217',
  routine: 'transformCreateStmt'
}
node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

PostgresError: relation "public.artist" does not exist
    at ErrorResponse (file:///home/apoorv/repos/app/node_modules/postgres/src/connection.js:788:26)
    at handle (file:///home/apoorv/repos/app/node_modules/postgres/src/connection.js:474:6)
    at Socket.data (file:///home/apoorv/repos/app/node_modules/postgres/src/connection.js:315:9)
    at Socket.emit (node:events:517:28)
    at addChunk (node:internal/streams/readable:368:12)
    at readableAddChunk (node:internal/streams/readable:341:9)
    at Readable.push (node:internal/streams/readable:278:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
  severity_local: 'ERROR',
  severity: 'ERROR',
  code: '42P01',
  where: 'SQL statement "ALTER TABLE "album" ADD CONSTRAINT "album_artist_id_artist_id_fk" FOREIGN KEY ("artist_id") REFERENCES "public"."artist"("id") ON DELETE cascade ON UPDATE no action"\n' +
    'PL/pgSQL function inline_code_block line 2 at SQL statement',
  file: 'namespace.c',
  line: '427',
  routine: 'RangeVarGetRelidExtended'
}

Node.js v18.19.0
Was this page helpful?