From 1e493198cf0a6b17da6ff4ac919f7fe5e9f9905f Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Sun, 5 Jan 2020 21:43:25 -0800 Subject: [PATCH] Updated migration Signed-off-by: James Ketrenos --- migration | 18 +++++++++--------- server/face-recognizer.js | 3 ++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/migration b/migration index 7da2de7..1b8f945 100644 --- a/migration +++ b/migration @@ -1,10 +1,10 @@ -cat << EOF | ./query.sh -pragma foreign_keys=off; -begin transaction; -alter table photos rename to photos_; +PRAGMA foreign_keys=OFF; +PRAGMA legacy_alter_table=ON; +BEGIN TRANSACTION; +ALTER TABLES photos RENAME TO photos_; CREATE TABLE `photos` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` VARCHAR(255), `filename` VARCHAR(255), `added` DATETIME, `modified` DATETIME, `updated` DATETIME, `scanned` DATETIME, `taken` DATETIME, `width` INTEGER, `height` INTEGER, `size` INTEGER, `duplicate` TINYINT(1) DEFAULT 0, `deleted` TINYINT(1) DEFAULT 0, `albumId` INTEGER REFERENCES `albums` (`id`), `faces` INTEGER DEFAULT -1); -insert into photos (id,name,filename,added,modified,updated,scanned,taken,width,height,size,duplicate,deleted,albumId,faces) select id,name,filename,added,modified,updated,scanned,taken,width,height,size,duplicate,deleted,albumId,faces from photos_; -commit; -drop photos_; -pragma foreign_keys=on; -EOF +INSERT INTO photos (id,name,filename,added,modified,updated,scanned,taken,width,height,size,duplicate,deleted,albumId,faces) SELECT id,name,filename,added,modified,updated,scanned,taken,width,height,size,duplicate,deleted,albumId,faces FROM photos_; +COMMIT; +DROP TABLE photos_; +PRAGMA foreign_keys=ON; +PRAGMA legacy_alter_table=OFF; diff --git a/server/face-recognizer.js b/server/face-recognizer.js index 7cecf1f..217ea54 100644 --- a/server/face-recognizer.js +++ b/server/face-recognizer.js @@ -71,7 +71,7 @@ require("./db/photos").then(function(db) { let remaining = total, processed = 0, lastStatus = Date.now(); - + console.log(`${needToScan.length} photos have not had faces scanned.`); return Promise.map(needToScan, (photo) => { @@ -173,6 +173,7 @@ require("./db/photos").then(function(db) { }); }); }).catch((error) => { + console.log(error); console.warn("Skipping out on image " + photoPath + " and marking to 0 faces to prevent future scanning."); return photoDB.sequelize.query("UPDATE photos SET faces=:faces WHERE id=:id", { replacements: {