diff --git a/internal/migrate/dialect_sqlite3.go b/internal/migrate/dialect_sqlite3.go index 90436b22a..cde83826e 100644 --- a/internal/migrate/dialect_sqlite3.go +++ b/internal/migrate/dialect_sqlite3.go @@ -40,7 +40,7 @@ var DialectSQLite3 = Migrations{ { ID: "20220329-082000", Dialect: "sqlite3", - Statements: []string{"UPDATE files SET media_id = CASE WHEN file_uid <> '' AND photo_id > 0 AND file_missing = 0 AND deleted_at IS NULL THEN (HEX(100000000000 - photo_id) || '-' || (1 + file_sidecar - file_primary) || '-' || file_uid) ELSE NULL END WHERE media_id IS NULL;"}, + Statements: []string{"UPDATE files SET media_id = CASE WHEN file_uid <> '' AND photo_id > 0 AND file_missing = 0 AND deleted_at IS NULL THEN (HEX(100000000000 - photo_id) || '-' || (1 + file_sidecar - file_primary) || '-' || file_uid) ELSE NULL END WHERE photo_id IS NOT NULL;"}, }, { ID: "20220329-091000", @@ -50,6 +50,6 @@ var DialectSQLite3 = Migrations{ { ID: "20220329-092000", Dialect: "sqlite3", - Statements: []string{"UPDATE files SET time_index = CASE WHEN media_id IS NOT NULL AND photo_taken_at IS NOT NULL THEN ((100000000000000 - CAST(photo_taken_at AS UNSIGNED)) || '-' || media_id) ELSE NULL END WHERE time_index IS NULL;"}, + Statements: []string{"UPDATE files SET time_index = CASE WHEN media_id IS NOT NULL AND photo_taken_at IS NOT NULL THEN ((100000000000000 - CAST(photo_taken_at AS UNSIGNED)) || '-' || media_id) ELSE NULL END WHERE photo_id IS NOT NULL;"}, }, } diff --git a/internal/migrate/sqlite3/20220329-082000.sql b/internal/migrate/sqlite3/20220329-082000.sql index 035096f2b..46915f5b2 100644 --- a/internal/migrate/sqlite3/20220329-082000.sql +++ b/internal/migrate/sqlite3/20220329-082000.sql @@ -1 +1 @@ -UPDATE files SET media_id = CASE WHEN file_uid <> '' AND photo_id > 0 AND file_missing = 0 AND deleted_at IS NULL THEN (HEX(100000000000 - photo_id) || '-' || (1 + file_sidecar - file_primary) || '-' || file_uid) ELSE NULL END WHERE media_id IS NULL; \ No newline at end of file +UPDATE files SET media_id = CASE WHEN file_uid <> '' AND photo_id > 0 AND file_missing = 0 AND deleted_at IS NULL THEN (HEX(100000000000 - photo_id) || '-' || (1 + file_sidecar - file_primary) || '-' || file_uid) ELSE NULL END WHERE photo_id IS NOT NULL; \ No newline at end of file diff --git a/internal/migrate/sqlite3/20220329-092000.sql b/internal/migrate/sqlite3/20220329-092000.sql index eade63ea6..020dcae95 100644 --- a/internal/migrate/sqlite3/20220329-092000.sql +++ b/internal/migrate/sqlite3/20220329-092000.sql @@ -1 +1 @@ -UPDATE files SET time_index = CASE WHEN media_id IS NOT NULL AND photo_taken_at IS NOT NULL THEN ((100000000000000 - CAST(photo_taken_at AS UNSIGNED)) || '-' || media_id) ELSE NULL END WHERE time_index IS NULL; \ No newline at end of file +UPDATE files SET time_index = CASE WHEN media_id IS NOT NULL AND photo_taken_at IS NOT NULL THEN ((100000000000000 - CAST(photo_taken_at AS UNSIGNED)) || '-' || media_id) ELSE NULL END WHERE photo_id IS NOT NULL; \ No newline at end of file