mirror of
https://github.com/koloideal/Casha.git
synced 2026-06-10 10:25:28 +03:00
update
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user