24 lines
660 B
TypeScript
24 lines
660 B
TypeScript
|
|
import { Pool } from "pg";
|
||
|
|
import { drizzle } from "drizzle-orm/node-postgres";
|
||
|
|
import { migrate } from "drizzle-orm/node-postgres/migrator";
|
||
|
|
import path from "path";
|
||
|
|
|
||
|
|
const pool = new Pool({
|
||
|
|
connectionString: process.env.DATABASE_URL || "postgresql://sexy:sexy@localhost:5432/sexy",
|
||
|
|
});
|
||
|
|
|
||
|
|
const db = drizzle(pool);
|
||
|
|
|
||
|
|
async function main() {
|
||
|
|
console.log("Running schema migrations...");
|
||
|
|
const migrationsFolder = path.join(__dirname, "../../migrations");
|
||
|
|
await migrate(db, { migrationsFolder });
|
||
|
|
console.log("Schema migrations complete.");
|
||
|
|
await pool.end();
|
||
|
|
}
|
||
|
|
|
||
|
|
main().catch((err) => {
|
||
|
|
console.error("Migration failed:", err);
|
||
|
|
process.exit(1);
|
||
|
|
});
|