Migrated angel_migration_runner

This commit is contained in:
thomashii@dukefirehawk.com 2021-05-02 19:44:38 +08:00
parent af36c3b339
commit ad4558cd0f
6 changed files with 21 additions and 27 deletions

View file

@ -34,8 +34,8 @@
* Migrated angel_orm to 3.0.0 (0/0 tests passed)
* Migrated angel_migration to 3.0.0 (0/0 tests passed)
* Added inflection2 and migrated to 1.0.0 (28/32 tests passed)
* Updated angel_orm_generator to 3.0.0 (in progress)
* Updated angel_migration_runner to 3.0.0 (in progress)
* Updated angel_orm_generator to 4.0.0 (0/0 tests passed)
* Updated angel_migration_runner to 3.0.0 (0/0 tests passed)
* Updated angel_orm_test to 1.0.0 (in progress)
* Updated angel_orm_postgres to 2.0.0 (in progress)
* Update orm-sdk-2.12.x boilerplate (in progress) <= Milestone 2
@ -69,8 +69,8 @@
* Updated angel_serialize_generator to 3.0.0 (33/33 tests passed)
* Updated angel_orm to 3.0.0 (0/0 tests passed)
* Updated angel_migration to 3.0.0 (0/0 tests passed)
* Updated angel_orm_generator to 3.0.0 (use a fork of postgres)
* Updated angel_migration_runner to 3.0.0
* Updated angel_orm_generator to 3.0.0 (0/0 tests passed, use a fork of postgres)
* Updated angel_migration_runner to 3.0.0 (0/0 tests passed)
* Updated angel_orm_test to 1.0.0
* Updated angel_orm_postgres to 2.0.0
* Update orm-sdk-2.12.x boilerplate

View file

@ -14,7 +14,7 @@ class PostgresMigrationRunner implements MigrationRunner {
PostgresMigrationRunner(this.connection,
{Iterable<Migration> migrations = const [], bool connected: false}) {
if (migrations?.isNotEmpty == true) migrations.forEach(addMigration);
if (migrations.isNotEmpty == true) migrations.forEach(addMigration);
_connected = connected == true;
}
@ -62,7 +62,7 @@ class PostgresMigrationRunner implements MigrationRunner {
int batch = curBatch + 1;
for (var k in toRun) {
var migration = migrations[k];
var migration = migrations[k]!;
var schema = new PostgresSchema();
migration.up(schema);
print('Bringing up "$k"...');
@ -93,7 +93,7 @@ class PostgresMigrationRunner implements MigrationRunner {
if (toRun.isNotEmpty) {
for (var k in toRun.reversed) {
var migration = migrations[k];
var migration = migrations[k]!;
var schema = new PostgresSchema();
migration.down(schema);
print('Bringing down "$k"...');
@ -117,7 +117,7 @@ class PostgresMigrationRunner implements MigrationRunner {
if (toRun.isNotEmpty) {
for (var k in toRun.reversed) {
var migration = migrations[k];
var migration = migrations[k]!;
var schema = new PostgresSchema();
migration.down(schema);
print('Bringing down "$k"...');

View file

@ -5,7 +5,7 @@ import 'package:charcode/ascii.dart';
abstract class PostgresGenerator {
static String columnType(MigrationColumn column) {
var str = column.type.name;
var str = column.type!.name;
if (column.length != null)
return '$str(${column.length})';
else
@ -53,7 +53,7 @@ abstract class PostgresGenerator {
static String compileReference(MigrationColumnReference ref) {
var buf = new StringBuffer(
'REFERENCES "${ref.foreignTable}"("${ref.foreignKey}")');
if (ref.behavior != null) buf.write(' ' + ref.behavior);
if (ref.behavior != null) buf.write(' ' + ref.behavior!);
return buf.toString();
}
}
@ -143,7 +143,7 @@ class PostgresAlterTable extends Table implements MutableTable {
}
@override
void changeColumnType(String name, ColumnType type, {int length}) {
void changeColumnType(String name, ColumnType type, {int? length}) {
_stack.add('ALTER COLUMN "$name" TYPE ' +
PostgresGenerator.columnType(
new MigrationColumn(type, length: length)));

View file

@ -4,10 +4,10 @@ import 'dart:mirrors';
Future<String> absoluteSourcePath(Type type) async {
var mirror = reflectType(type);
var uri = mirror.location.sourceUri;
var uri = mirror.location!.sourceUri;
if (uri.scheme == 'package') {
uri = await Isolate.resolvePackageUri(uri);
uri = await (Isolate.resolvePackageUri(uri) as FutureOr<Uri>);
}
return uri.toFilePath() + '#' + MirrorSystem.getName(mirror.simpleName);

View file

@ -1,24 +1,21 @@
name: angel_migration_runner
version: 3.0.0
version: 4.0.0
description: Command-line based database migration runner for Angel's ORM.
author: Tobe O <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/migration
homepage: https://github.com/dukefirehawk/angel
publish_to: none
environment:
sdk: '>=2.10.0 <3.0.0'
sdk: '>=2.12.0 <3.0.0'
dependencies:
angel_migration:
git:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x
ref: sdk-2.12.x_nnbd
path: packages/orm/angel_migration
angel_orm:
git:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x
ref: sdk-2.12.x_nnbd
path: packages/orm/angel_orm
args: ^2.0.0
args: ^2.1.0
charcode: ^1.2.0
postgres:
git:
url: https://github.com/dukefirehawk/postgresql-dart
postgres: ^2.3.2

View file

@ -40,7 +40,7 @@ dependencies:
path: ^1.8.0
recase: ^4.0.0
source_gen: ^1.0.0
collection: ^1.15.0-nullsafety.4
collection: ^1.15.0
dev_dependencies:
angel_framework:
git:
@ -54,9 +54,6 @@ dev_dependencies:
path: packages/orm/angel_migration
#angel_test: ^1.0.0
build_runner: ^2.0.1
collection: ^1.15.0
pedantic: ^1.11.0
postgres: ^2.3.2
# git:
# url: https://github.com/dukefirehawk/postgresql-dart
test: ^1.17.3