Updated migration

Signed-off-by: James Ketrenos <james_gitlab@ketrenos.com>
This commit is contained in:
James Ketrenos 2020-01-05 21:43:25 -08:00
parent 0afbd32cbb
commit 1e493198cf
2 changed files with 11 additions and 10 deletions

View File

@ -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;

View File

@ -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: {