wip: get app version from db.

This commit is contained in:
2022-01-12 18:33:10 +08:00
parent 7531702f1b
commit cac56c42cc
5 changed files with 54 additions and 16 deletions
+28
View File
@@ -33,6 +33,7 @@ void main(List<String> args) async {
SchemeMigration(),
DownloadHistoryMigration(),
LikeRecordMigration(),
AppVersionMigration(),
]);
await runMigrations(migrationRunner, args);
}
@@ -64,3 +65,30 @@ Future doUserSeed() async {
}
return connection.close();
}
class AppVersionSeed extends Migration {
@override
void up(Schema schema) async {
await doAppVersionSeed();
}
@override
void down(Schema schema) async {}
}
Future doAppVersionSeed() async {
var connection = await connectToPostgres(configuration);
await connection.open();
var executor = PostgreSqlExecutor(connection);
var appVersionQuery = AppVersionQuery();
var one = await appVersionQuery.getOne(executor);
if (one.isEmpty) {
appVersionQuery = AppVersionQuery();
appVersionQuery.values.copyFrom(AppVersion(
versionCode: 1,
versionName: '1.0.0',
));
return appVersionQuery.insert(executor).then((value) => connection.close());
}
return connection.close();
}