2021-05-18 14:47:56 +00:00
|
|
|
import 'package:angel3_migration/angel3_migration.dart';
|
|
|
|
import 'package:angel3_migration_runner/angel3_migration_runner.dart';
|
|
|
|
import 'package:angel3_migration_runner/postgres.dart';
|
2022-01-02 07:21:17 +00:00
|
|
|
import 'package:angel3_migration_runner/mysql.dart';
|
2021-05-18 14:47:56 +00:00
|
|
|
import 'package:angel3_orm/angel3_orm.dart';
|
2019-02-14 17:15:34 +00:00
|
|
|
import 'package:postgres/postgres.dart';
|
2022-01-02 07:21:17 +00:00
|
|
|
import 'package:mysql1/mysql1.dart';
|
|
|
|
|
2021-05-18 14:47:56 +00:00
|
|
|
import 'todo.dart';
|
2019-02-14 17:15:34 +00:00
|
|
|
|
2022-01-02 07:21:17 +00:00
|
|
|
var postgresqlMigrationRunner = PostgresMigrationRunner(
|
|
|
|
PostgreSQLConnection('127.0.0.1', 5432, 'demo',
|
|
|
|
username: 'demouser', password: 'demo123'),
|
|
|
|
migrations: [
|
|
|
|
UserMigration(),
|
|
|
|
TodoMigration(),
|
|
|
|
FooMigration(),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
|
|
|
|
var mysqlMigrationRunner = MysqlMigrationRunner(
|
|
|
|
ConnectionSettings(
|
|
|
|
host: 'localhost',
|
|
|
|
port: 3306,
|
|
|
|
user: 'demouser',
|
|
|
|
password: 'demo123',
|
|
|
|
db: 'demo'),
|
2019-02-14 17:15:34 +00:00
|
|
|
migrations: [
|
2021-05-18 14:47:56 +00:00
|
|
|
UserMigration(),
|
|
|
|
TodoMigration(),
|
|
|
|
FooMigration(),
|
2019-02-14 17:15:34 +00:00
|
|
|
],
|
|
|
|
);
|
|
|
|
|
2022-01-02 07:21:17 +00:00
|
|
|
void main(List<String> args) => runMigrations(postgresqlMigrationRunner, args);
|
2019-04-04 20:30:53 +00:00
|
|
|
|
|
|
|
class FooMigration extends Migration {
|
|
|
|
@override
|
|
|
|
void up(Schema schema) {
|
|
|
|
schema.create('foos', (table) {
|
|
|
|
table
|
|
|
|
..serial('id').primaryKey()
|
|
|
|
..varChar('bar', length: 64)
|
|
|
|
..timeStamp('created_at').defaultsTo(currentTimestamp);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void down(Schema schema) => schema.drop('foos');
|
|
|
|
}
|