diff --git a/server/src/db/connection.ts b/server/src/db/connection.ts index 1dd8805..40b2e16 100644 --- a/server/src/db/connection.ts +++ b/server/src/db/connection.ts @@ -93,6 +93,8 @@ const runMigrations = () => { )) .join(', '); + // Disable foreign key checks while rebuilding the users table. + db.exec('PRAGMA foreign_keys = OFF'); db.exec('BEGIN'); db.exec('ALTER TABLE users RENAME TO users_old'); db.exec(` @@ -107,6 +109,7 @@ const runMigrations = () => { `); db.exec('DROP TABLE users_old'); db.exec('COMMIT'); + db.exec('PRAGMA foreign_keys = ON'); userTableInfo2 = db.prepare("PRAGMA table_info(users)").all() as { name: string }[]; } if (didDropApiKeyColumns) {