Skip to content
Snippets Groups Projects
Commit 9632e321 authored by timothycarambat's avatar timothycarambat
Browse files

check table for migration

parent a126b5f5
No related branches found
No related tags found
No related merge requests found
...@@ -249,6 +249,20 @@ async function migrateTable(tableName, migrateRowFunc) { ...@@ -249,6 +249,20 @@ async function migrateTable(tableName, migrateRowFunc) {
filename: BACKUP_PATH, filename: BACKUP_PATH,
driver: sqlite3.Database, driver: sqlite3.Database,
}); });
// Check table exists
const exists =
(await db.get(
`SELECT COUNT(*) FROM sqlite_master WHERE name='${tableName}'`
)) > 0;
if (!exists) {
console.log(
`${tableName} does not exist in legacy DB - nothing to migrate - skipping.`
);
return;
}
const upserts = []; const upserts = [];
const rows = await db.all(`SELECT * FROM ${tableName}`); const rows = await db.all(`SELECT * FROM ${tableName}`);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment