mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-09 21:44:51 +02:00
Add new schema
This commit is contained in:
parent
f8ed090a83
commit
06ee87ac2c
7 changed files with 202 additions and 106 deletions
27
scripts/runMigrations.ts
Normal file
27
scripts/runMigrations.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import { drizzle } from 'drizzle-orm/better-sqlite3';
|
||||
import { migrate } from 'drizzle-orm/better-sqlite3/migrator';
|
||||
import Database from 'better-sqlite3';
|
||||
|
||||
const runMigrations = async () => {
|
||||
// Create a new SQLite database connection
|
||||
const sqlite = new Database('./config/db/db.sqlite');
|
||||
|
||||
// Create a Drizzle instance
|
||||
const db = drizzle(sqlite);
|
||||
|
||||
console.log('Running migrations...');
|
||||
|
||||
try {
|
||||
// Run the migrations
|
||||
await migrate(db, { migrationsFolder: './server/migrations' });
|
||||
console.log('Migrations completed successfully.');
|
||||
} catch (error) {
|
||||
console.error('Error running migrations:', error);
|
||||
process.exit(1);
|
||||
} finally {
|
||||
// Close the database connection
|
||||
sqlite.close();
|
||||
}
|
||||
};
|
||||
|
||||
runMigrations();
|
Loading…
Add table
Add a link
Reference in a new issue