This commit is contained in:
sebseb7
2025-12-25 02:09:06 +01:00
parent 2c6ddf61f5
commit db4f27302b
3 changed files with 70 additions and 25 deletions

View File

@@ -12,7 +12,7 @@ console.log(`[Migrate] Connected to ${dbPath}`);
console.log('[Migrate] Applying schema migrations...');
try {
db.exec(`
db.exec(`
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT UNIQUE NOT NULL,
@@ -30,9 +30,20 @@ try {
FOREIGN KEY(created_by) REFERENCES users(id)
);
`);
console.log('[Migrate] Schema applied successfully.');
// Add position column if not exists
try {
db.exec("ALTER TABLE views ADD COLUMN position INTEGER DEFAULT 0");
console.log('[Migrate] Added position column to views table.');
} catch (e) {
if (!e.message.includes("duplicate column name")) {
console.log('[Migrate] NOTE: ' + e.message);
}
}
console.log('[Migrate] Schema applied successfully.');
} catch (err) {
console.error('[Migrate] Error applying schema:', err.message);
console.error('[Migrate] Error applying schema:', err.message);
} finally {
db.close();
db.close();
}