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