protevus/bin/migrate.dart

41 lines
1.2 KiB
Dart
Raw Permalink Normal View History

2021-06-14 00:08:25 +00:00
import 'package:angel/src/config/plugins/orm.dart';
import 'package:angel/models.dart';
2021-06-11 04:00:10 +00:00
import 'package:angel3_configuration/angel3_configuration.dart';
import 'package:angel3_migration_runner/angel3_migration_runner.dart';
2022-04-30 02:14:23 +00:00
import 'package:angel3_migration_runner/mariadb.dart';
2022-05-01 09:46:14 +00:00
//import 'package:angel3_migration_runner/mysql.dart';
2019-01-12 00:44:28 +00:00
import 'package:file/local.dart';
2021-07-25 09:11:58 +00:00
import 'package:logging/logging.dart';
2019-01-12 00:44:28 +00:00
2021-02-19 14:34:24 +00:00
void main(List<String> args) async {
2021-07-25 09:11:58 +00:00
// 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);
}
});
2019-01-12 00:44:28 +00:00
var fs = LocalFileSystem();
var configuration = await loadStandaloneConfiguration(fs);
2022-04-30 02:14:23 +00:00
// MariaDB database
var connection = await connectToMariaDb(configuration);
var migrationRunner = MariaDbMigrationRunner(connection, migrations: [
2019-01-12 00:44:28 +00:00
GreetingMigration(),
]);
2022-04-30 02:14:23 +00:00
2022-05-01 09:46:14 +00:00
// MySQL database
/*
var connection = await connectToMysql(configuration);
var migrationRunner = MySqlMigrationRunner(connection, migrations: [
GreetingMigration(),
]);
*/
2022-04-30 02:14:23 +00:00
await runMigrations(migrationRunner, args);
2019-01-12 00:44:28 +00:00
}