fixing schemas and making migrations not crash
This commit is contained in:
@@ -693,15 +693,12 @@ function runMigrations(db: Database.Database): void {
|
||||
db.exec('ALTER TABLE photo_providers DROP COLUMN config');
|
||||
},
|
||||
() => {
|
||||
const columns = db.prepare("PRAGMA table_info('trip_photos')").all() as Array<{ name: string }>;
|
||||
const names = new Set(columns.map(c => c.name));
|
||||
if (names.has('asset_id') && !names.has('immich_asset_id')) return;
|
||||
db.exec('ALTER TABLE `trip_photos` RENAME COLUMN immich_asset_id TO asset_id');
|
||||
},
|
||||
() => {
|
||||
db.exec('ALTER TABLE `trip_photos` ADD COLUMN provider TEXT NOT NULL DEFAULT "immich"');
|
||||
},
|
||||
() => {
|
||||
db.exec('ALTER TABLE `trip_album_links` ADD COLUMN provider TEXT NOT NULL DEFAULT "immich"');
|
||||
},
|
||||
() => {
|
||||
db.exec('ALTER TABLE `trip_album_links` RENAME COLUMN immich_album_id TO album_id');
|
||||
},
|
||||
];
|
||||
|
||||
@@ -18,6 +18,8 @@ function createTables(db: Database.Database): void {
|
||||
mfa_enabled INTEGER DEFAULT 0,
|
||||
mfa_secret TEXT,
|
||||
mfa_backup_codes TEXT,
|
||||
immich_url TEXT,
|
||||
immich_access_token TEXT,
|
||||
synology_url TEXT,
|
||||
synology_username TEXT,
|
||||
synology_password TEXT,
|
||||
@@ -166,6 +168,7 @@ function createTables(db: Database.Database): void {
|
||||
place_id INTEGER REFERENCES places(id) ON DELETE SET NULL,
|
||||
assignment_id INTEGER REFERENCES day_assignments(id) ON DELETE SET NULL,
|
||||
title TEXT NOT NULL,
|
||||
accommodation_id TEXT,
|
||||
reservation_time TEXT,
|
||||
reservation_end_time TEXT,
|
||||
location TEXT,
|
||||
|
||||
Reference in New Issue
Block a user