u
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user