protevus/bin/migrate.dart
2022-05-01 17:46:14 +08:00

40 lines
1.2 KiB
Dart

import 'package:angel/src/config/plugins/orm.dart';
import 'package:angel/models.dart';
import 'package:angel3_configuration/angel3_configuration.dart';
import 'package:angel3_migration_runner/angel3_migration_runner.dart';
import 'package:angel3_migration_runner/mariadb.dart';
//import 'package:angel3_migration_runner/mysql.dart';
import 'package:file/local.dart';
import 'package:logging/logging.dart';
void main(List<String> args) async {
// Enable the logging
Logger.root.level = Level.INFO;
Logger.root.onRecord.listen((rec) {
print('${rec.time}: ${rec.level.name}: ${rec.loggerName}: ${rec.message}');
if (rec.error != null) {
print(rec.error);
print(rec.stackTrace);
}
});
var fs = LocalFileSystem();
var configuration = await loadStandaloneConfiguration(fs);
// MariaDB database
var connection = await connectToMariaDb(configuration);
var migrationRunner = MariaDbMigrationRunner(connection, migrations: [
GreetingMigration(),
]);
// MySQL database
/*
var connection = await connectToMysql(configuration);
var migrationRunner = MySqlMigrationRunner(connection, migrations: [
GreetingMigration(),
]);
*/
await runMigrations(migrationRunner, args);
}