forked from surajyog/nanomides
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix-migration.js
More file actions
28 lines (22 loc) · 912 Bytes
/
Copy pathfix-migration.js
File metadata and controls
28 lines (22 loc) · 912 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
import Database from 'better-sqlite3';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const dbPath = path.join(__dirname, 'data', 'bot-civilization.db');
const db = new Database(dbPath);
console.log('🔧 Fixing migration issue...');
try {
// Remove the failed migration record
db.prepare("DELETE FROM migrations WHERE name = '002_task_types'").run();
console.log('✅ Removed failed migration record');
// Drop the partially created tables
db.prepare("DROP TABLE IF EXISTS task_types").run();
db.prepare("DROP TABLE IF EXISTS task_type_categories").run();
console.log('✅ Dropped partial tables');
console.log('✅ Database fixed! You can now restart the server.');
} catch (error) {
console.error('❌ Error fixing database:', error.message);
} finally {
db.close();
}