mirror of
https://github.com/ajnart/homarr.git
synced 2026-01-30 11:19:12 +01:00
29 lines
709 B
TypeScript
29 lines
709 B
TypeScript
import Database from "better-sqlite3";
|
|
import { drizzle } from "drizzle-orm/better-sqlite3";
|
|
import { migrate } from "drizzle-orm/better-sqlite3/migrator";
|
|
|
|
import { schema } from "../..";
|
|
import { seedDataAsync } from "../seed";
|
|
|
|
const migrationsFolder = process.argv[2] ?? ".";
|
|
|
|
const migrateAsync = async () => {
|
|
const sqlite = new Database(process.env.DB_URL?.replace("file:", ""));
|
|
|
|
const db = drizzle(sqlite, { schema, casing: "snake_case" });
|
|
|
|
migrate(db, { migrationsFolder });
|
|
|
|
await seedDataAsync(db);
|
|
};
|
|
|
|
migrateAsync()
|
|
.then(() => {
|
|
console.log("Migration complete");
|
|
process.exit(0);
|
|
})
|
|
.catch((err) => {
|
|
console.log("Migration failed", err);
|
|
process.exit(1);
|
|
});
|