Trying this again...
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m48s

This commit is contained in:
2026-01-17 01:32:07 -07:00
parent bebc4b2743
commit aae8693dd3
5 changed files with 1178 additions and 1 deletions

42
scripts/migrate.js Normal file
View File

@@ -0,0 +1,42 @@
import { drizzle } from "drizzle-orm/libsql";
import { migrate } from "drizzle-orm/libsql/migrator";
import { createClient } from "@libsql/client";
import path from "path";
async function runMigrate() {
console.log("Running migrations...");
let url = process.env.DATABASE_URL;
if (!url) {
url = `file:${path.resolve(process.cwd(), "chronus.db")}`;
console.log(`No DATABASE_URL found, using default: ${url}`);
} else if (
!url.startsWith("file:") &&
!url.startsWith("libsql:") &&
!url.startsWith("http:") &&
!url.startsWith("https:")
) {
url = `file:${url}`;
}
const authToken = process.env.DATABASE_AUTH_TOKEN;
const client = createClient({
url,
authToken,
});
const db = drizzle(client);
try {
await migrate(db, { migrationsFolder: "./drizzle" });
console.log("Migrations completed successfully");
} catch (error) {
console.error("Migration failed:", error);
process.exit(1);
} finally {
client.close();
}
}
runMigrate();