Move settings fields from camelCase to snake_case

This commit is contained in:
Brandon Presley 2023-11-10 18:32:37 +13:00
parent 6810b84310
commit de926bce0e
2 changed files with 24 additions and 3 deletions

View File

@ -17,7 +17,7 @@ class MyDatabase extends _$MyDatabase {
MyDatabase() : super(_openConnection()); MyDatabase() : super(_openConnection());
@override @override
int get schemaVersion => 1; int get schemaVersion => 2;
@override @override
MigrationStrategy get migration => MigrationStrategy( MigrationStrategy get migration => MigrationStrategy(
@ -27,7 +27,28 @@ class MyDatabase extends _$MyDatabase {
if (data.isEmpty) await db.into(db.settings).insert(defaultSettings); if (data.isEmpty) await db.into(db.settings).insert(defaultSettings);
}, },
onUpgrade: (Migrator m, int from, int to) async { onUpgrade: (Migrator m, int from, int to) async {
// no migrations yet if (from == 1) {
await m.addColumn(settings, settings.darkColor);
await db.customStatement('''
UPDATE settings SET dark_color = darkColor
''');
await m.addColumn(settings, settings.lightColor);
await db.customStatement('''
UPDATE settings SET light_color = lightColor
''');
await m.addColumn(settings, settings.showDate);
await db.customStatement('''
UPDATE settings SET show_date = showDate
''');
await m.addColumn(settings, settings.showSets);
await db.customStatement('''
UPDATE settings SET show_sets = showSets
''');
await m.addColumn(settings, settings.showUnit);
await db.customStatement('''
UPDATE settings SET show_unit = showUnit
''');
}
}, },
); );
} }