© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
3 replies
dandadan

Migrations not being applied (drizzle-orm/node-postgres/migrator)

im kind of struggling with migrations... i have the following migration index.ts which i run whenever i generate a new migration
import { drizzle } from "drizzle-orm/node-postgres";
import { migrate } from "drizzle-orm/node-postgres/migrator";
import pg from "pg";
import { env } from "config";

const migrationClient = new pg.Client({
  connectionString: env.DATABASE_URL,
});

const runMigration = async () => {
  const db = drizzle(migrationClient, { logger: true });
  await migrate(db, { migrationsFolder: "migrations" });
};

runMigration()
  .then(() => {
    console.log("Migrated");
  })
  .catch((err) => {
    console.error(err);
    process.exit(1);
  });
import { drizzle } from "drizzle-orm/node-postgres";
import { migrate } from "drizzle-orm/node-postgres/migrator";
import pg from "pg";
import { env } from "config";

const migrationClient = new pg.Client({
  connectionString: env.DATABASE_URL,
});

const runMigration = async () => {
  const db = drizzle(migrationClient, { logger: true });
  await migrate(db, { migrationsFolder: "migrations" });
};

runMigration()
  .then(() => {
    console.log("Migrated");
  })
  .catch((err) => {
    console.error(err);
    process.exit(1);
  });

the generate command with drizzle-kit did generate the sql file and it looks perfectly fine, but when i attempt to run the index.ts file in order to actually run the migration (
"migrate": "node -r esbuild-register ./src/db/master/index.ts",
"migrate": "node -r esbuild-register ./src/db/master/index.ts",
) the only output i get in the console is this:
api:migrate: Query: CREATE SCHEMA IF NOT EXISTS "drizzle"
api:migrate: Query: CREATE SCHEMA IF NOT EXISTS "drizzle"


and whenever i run the application it fails with
api:dev: error: relation "sessions" does not exist
api:dev: error: relation "sessions" does not exist
(using relational queries), so im guessing the changes arent being pushed to postgres with my script...

any idea?
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Schema not ingested with drizzle-orm/node-postgres
Drizzle TeamDTDrizzle Team / help
3y ago
SQLite migrations are not being applied
Drizzle TeamDTDrizzle Team / help
3y ago
Unable to use drizzle-orm migrator with drizzle-kit
Drizzle TeamDTDrizzle Team / help
2y ago
Migrations not being applied, despite being marked as complete
Drizzle TeamDTDrizzle Team / help
10mo ago