22 lines
617 B
JavaScript
22 lines
617 B
JavaScript
import { readFileSync } from "fs";
|
|
import { join } from "path";
|
|
import postgres from "postgres";
|
|
|
|
const connectionString = process.env.DATABASE_URL;
|
|
if (!connectionString) {
|
|
console.error("DATABASE_URL is not set");
|
|
process.exit(1);
|
|
}
|
|
|
|
const sql = postgres(connectionString, { max: 1 });
|
|
const migrationPath = join(process.cwd(), "drizzle/migrations/0000_init.sql");
|
|
const migration = readFileSync(migrationPath, "utf-8");
|
|
|
|
try {
|
|
await sql.unsafe(migration);
|
|
await sql.end();
|
|
console.log("Migrations applied successfully");
|
|
} catch (error) {
|
|
console.error("Migration failed:", error);
|
|
process.exit(1);
|
|
} |