mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-31 06:59:33 +02:00
fix: resolve build errors and improve database migration system
- Remove unused SQLite migration script 1.8.1.ts that was causing TypeScript compilation errors during PostgreSQL builds - Fix verifyTotp.ts type error by adding proper null check for password parameter before passing to verifyPassword function - Fix SQLite migration script 1.7.0.ts syntax errors in transaction structure and error handling **- Update SQLite migration system to not drop tables by default, as this was used during testing and should not be in production.** Fixes build failures for both "make build" (SQLite) and "make build-pg" (PostgreSQL) Docker image builds.
This commit is contained in:
parent
5278c4d6f2
commit
ec8d3569d3
10 changed files with 96 additions and 114 deletions
|
@ -17,12 +17,17 @@ export default async function migration() {
|
|||
db.exec(`
|
||||
ALTER TABLE orgs ADD COLUMN passwordResetTokenExpiryHours INTEGER NOT NULL DEFAULT 1;
|
||||
`);
|
||||
})(); // <-- executes the transaction immediately
|
||||
})(); // executes the transaction immediately
|
||||
db.pragma("foreign_keys = ON");
|
||||
console.log(`Added passwordResetTokenExpiryHours column to orgs table`);
|
||||
} catch (e) {
|
||||
console.log("Error adding passwordResetTokenExpiryHours column to orgs table:");
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
try {
|
||||
db.pragma("foreign_keys = OFF");
|
||||
db.transaction(() => {
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS securityKey (
|
||||
credentialId TEXT PRIMARY KEY,
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
import { db } from "@server/db";
|
||||
|
||||
export default async function migrate() {
|
||||
try {
|
||||
console.log("Starting table rename migration...");
|
||||
|
||||
// Rename the table
|
||||
await db.run(`
|
||||
ALTER TABLE securityKeyChallenge RENAME TO webauthnChallenge;
|
||||
`);
|
||||
console.log("Successfully renamed table");
|
||||
|
||||
// Rename the index
|
||||
await db.run(`
|
||||
DROP INDEX IF EXISTS idx_securityKeyChallenge_expiresAt;
|
||||
CREATE INDEX IF NOT EXISTS idx_webauthnChallenge_expiresAt ON webauthnChallenge(expiresAt);
|
||||
`);
|
||||
console.log("Successfully updated index");
|
||||
|
||||
console.log(`Renamed securityKeyChallenge table to webauthnChallenge`);
|
||||
return true;
|
||||
} catch (error: any) {
|
||||
console.error("Unable to rename securityKeyChallenge table:", error);
|
||||
console.error("Error details:", error.message);
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue