Move settings fields from camelCase to snake_case
This commit is contained in:
parent
6810b84310
commit
de926bce0e
|
@ -17,7 +17,7 @@ class MyDatabase extends _$MyDatabase {
|
|||
MyDatabase() : super(_openConnection());
|
||||
|
||||
@override
|
||||
int get schemaVersion => 1;
|
||||
int get schemaVersion => 2;
|
||||
|
||||
@override
|
||||
MigrationStrategy get migration => MigrationStrategy(
|
||||
|
@ -27,7 +27,28 @@ class MyDatabase extends _$MyDatabase {
|
|||
if (data.isEmpty) await db.into(db.settings).insert(defaultSettings);
|
||||
},
|
||||
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
|
||||
''');
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ class _SettingsPageState extends State<_SettingsPage> {
|
|||
await migrator.createAll();
|
||||
await db.customInsert('''
|
||||
INSERT INTO gym_sets(id, name, reps, weight, created, unit, hidden, image, sets, minutes, seconds, steps)
|
||||
SELECT id, name, reps, weight, created, unit, hidden, image, sets, minutes, seconds, steps FROM sets''');
|
||||
SELECT id, name, reps, weight, created, unit, hidden, image, sets, minutes, seconds, steps FROM sets''');
|
||||
print('Migrated.');
|
||||
},
|
||||
child: const Text("Import")));
|
||||
|
|
Loading…
Reference in New Issue
Block a user