first commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user