fix: большой фикс недочетов и фикс пары язв

This commit is contained in:
Jganenok
2026-06-09 01:00:04 +07:00
parent 73ad6dd1e6
commit 580e30897b
32 changed files with 590 additions and 244 deletions
+17 -1
View File
@@ -159,7 +159,7 @@ class AppDatabase {
final dbPath = await getDatabasesPath();
return openDatabase(
join(dbPath, 'komet.db'),
version: 10,
version: 11,
onOpen: (db) => db.execute('PRAGMA foreign_keys = ON'),
onCreate: (db, _) => _createTables(db),
onUpgrade: (db, oldVersion, newVersion) async {
@@ -209,6 +209,9 @@ class AppDatabase {
'ALTER TABLE chats_cache ADD COLUMN admins TEXT',
);
}
if (oldVersion < 11) {
await _createIndexes(db);
}
},
);
}
@@ -234,6 +237,19 @@ class AppDatabase {
await db.execute(_chatsCacheSchema);
await db.execute(_contactsSchema);
await db.execute(_messagesSchema);
await _createIndexes(db);
}
static Future<void> _createIndexes(Database db) async {
await db.execute(
'CREATE INDEX IF NOT EXISTS idx_messages_chat ON messages(account_id, chat_id, time DESC)',
);
await db.execute(
'CREATE INDEX IF NOT EXISTS idx_chats_account ON chats_cache(account_id, last_event_time DESC)',
);
await db.execute(
'CREATE INDEX IF NOT EXISTS idx_contacts_account ON contacts(account_id)',
);
}
static const _contactsSchema = '''