feat(state): replace in-memory Map with SQLite-backed stateService (#59)
- Create src/services/stateService.js with get/set/delete/has API - Create migration 004_user_states.js (chat_id PK, state_data JSON, updated_at) - TTL of 24 hours — expired states auto-deleted - Cleanup job runs every hour (setInterval) - Replace src/context/userStates.js Map with async stateService proxy - Add await to all 45 userStates.get/set/delete/has calls across 13 files - Add initStates() call in index.js startup sequence - All state survives bot restarts now 18 files changed, 172 insertions, 46 deletions
This commit is contained in:
@@ -38,6 +38,7 @@ export async function runMigrations() {
|
||||
(await import('./001_initial_schema.js')).default,
|
||||
(await import('./002_add_columns.js')).default,
|
||||
(await import('./003_add_indexes.js')).default,
|
||||
(await import('./004_user_states.js')).default,
|
||||
];
|
||||
|
||||
for (let i = currentVersion; i < migrations.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user