This commit is contained in:
2026-03-23 01:18:08 +03:00
parent 2fe390b068
commit 4f87aa7598
9 changed files with 1128 additions and 5 deletions
+22 -2
View File
@@ -8,12 +8,32 @@ import 'tables.dart';
part 'app_database.g.dart';
@DriftDatabase(tables: [Transactions, Categories, Budgets, ExchangeRates])
@DriftDatabase(tables: [Transactions, Categories, Budgets, ExchangeRates, Accounts])
class AppDatabase extends _$AppDatabase {
AppDatabase() : super(_openConnection());
@override
int get schemaVersion => 1;
int get schemaVersion => 3;
@override
MigrationStrategy get migration => MigrationStrategy(
onUpgrade: (migrator, from, to) async {
if (from == 1) {
await migrator.createTable(accounts);
await customStatement(
'INSERT INTO accounts (name, is_main, currency, sort_order, created_at) '
'VALUES (?, ?, ?, ?, ?)',
['Main', 1, 'USD', 0, DateTime.now().millisecondsSinceEpoch],
);
}
if (from == 2) {
// Add currency column to existing accounts table
await customStatement(
'ALTER TABLE accounts ADD COLUMN currency TEXT NOT NULL DEFAULT "USD"',
);
}
},
);
// ============================================================================
// TRANSACTIONS