Fix: Add database migration for new_jackpot_delay_minutes column
Existing databases were missing the new column, causing SQLITE_ERROR when updating group settings. Added migration logic to add missing columns.
This commit is contained in:
@@ -120,9 +120,30 @@ class BotDatabase {
|
||||
CREATE INDEX IF NOT EXISTS idx_cycle_participants_telegram_id ON cycle_participants(telegram_id);
|
||||
`);
|
||||
|
||||
// Run migrations for existing databases
|
||||
this.runMigrations();
|
||||
|
||||
logger.debug('Database tables created/verified');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run migrations for existing databases
|
||||
*/
|
||||
private runMigrations(): void {
|
||||
if (!this.db) return;
|
||||
|
||||
// Check if new_jackpot_delay_minutes column exists in groups table
|
||||
const groupColumns = this.db.prepare(`PRAGMA table_info(groups)`).all() as any[];
|
||||
const hasNewJackpotDelay = groupColumns.some(col => col.name === 'new_jackpot_delay_minutes');
|
||||
|
||||
if (!hasNewJackpotDelay) {
|
||||
logger.info('Running migration: adding new_jackpot_delay_minutes column to groups');
|
||||
this.db.exec(`ALTER TABLE groups ADD COLUMN new_jackpot_delay_minutes INTEGER DEFAULT 5`);
|
||||
}
|
||||
|
||||
logger.debug('Database migrations completed');
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
// USER METHODS
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
Reference in New Issue
Block a user