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",) the only output i get in the console is this: api:migrate: Query: CREATE SCHEMA IF NOT EXISTS "drizzle" and whenever i run the application it fails withapi: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?
3 Replies
dandadan
dandadanOP2y ago
ive also managed to run introspect on the db and its definitely empty
dandadan
dandadanOP2y ago
https://github.com/Pridestalkerr/drizzle-issue minimal example to reproduce the issue
GitHub
GitHub - Pridestalkerr/drizzle-issue
Contribute to Pridestalkerr/drizzle-issue development by creating an account on GitHub.
dandadan
dandadanOP2y ago
tried with postgres instead of pg and it works... should I open an issue or am I missing something? (maybe migrations not implemented for node-postgres?
Want results from more Discord servers?
Add your server