-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmigration_2fa.mjs
More file actions
32 lines (28 loc) · 794 Bytes
/
Copy pathmigration_2fa.mjs
File metadata and controls
32 lines (28 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import pkg from 'pg';
const { Pool } = pkg;
import dotenv from 'dotenv';
import path from 'path';
import { fileURLToPath } from 'url';
dotenv.config({ path: '.env.local' });
const pool = new Pool({
connectionString: process.env.POSTGRES_URL,
ssl: {
rejectUnauthorized: false
}
});
async function runMigration() {
try {
console.log('Running 2FA Migration...');
await pool.query(`
ALTER TABLE fluxbase_global.users
ADD COLUMN IF NOT EXISTS two_factor_secret TEXT,
ADD COLUMN IF NOT EXISTS two_factor_enabled BOOLEAN DEFAULT FALSE;
`);
console.log('Migration successful!');
} catch (err) {
console.error('Migration failed:', err);
} finally {
await pool.end();
}
}
runMigration();