Updated Angel3 migration
This commit is contained in:
parent
2510b76e80
commit
cb25da3077
13 changed files with 178 additions and 22 deletions
|
@ -1,6 +1,6 @@
|
|||
# Runing Ancillary Docker Services
|
||||
# Docker Services
|
||||
|
||||
The required ancillary services required by the framework can be run using the compose files provided in this folder.
|
||||
The required applications by the framework can be run using the docker compose files provided in this folder.
|
||||
|
||||
## PostreSQL
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
# Change Log
|
||||
|
||||
## 8.2.1
|
||||
|
||||
* Updated README
|
||||
|
||||
## 8.2.0
|
||||
|
||||
* Require Dart >= 3.3
|
||||
|
|
|
@ -5,15 +5,9 @@
|
|||
[![Discord](https://img.shields.io/discord/1060322353214660698)](https://discord.gg/3X6bxTUdCM)
|
||||
[![License](https://img.shields.io/github/license/dart-backend/angel)](https://github.com/dart-backend/angel/tree/master/packages/orm/angel_migration/LICENSE)
|
||||
|
||||
A basic database migration framework built for Angel3 ORM.
|
||||
This package contains the abstract classes for implementing database migration in Angel3 framework. It is designed to work with Angel3 ORM. Please refer to the implementation in the [ORM Migration Runner](<https://pub.dev/packages/angel3_migration_runner>) package for more details.
|
||||
|
||||
## Supported database
|
||||
|
||||
* PostgreSQL version 10 or later
|
||||
* MariaDB 10.2.x or later
|
||||
* MySQL 8.x or later
|
||||
|
||||
## Features
|
||||
## Supported Features
|
||||
|
||||
* Create tables based on ORM models
|
||||
* Drop tables based on ORM models
|
||||
|
@ -21,4 +15,4 @@ A basic database migration framework built for Angel3 ORM.
|
|||
|
||||
## Limitation
|
||||
|
||||
* Alter table/fields based on updated ORM models not supported
|
||||
* Alter table/fields based on updated ORM models is not supported
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: angel3_migration
|
||||
version: 8.2.0
|
||||
description: Database migration runtime for Angel3 ORM. Use this package to define schemas.
|
||||
version: 8.2.1
|
||||
description: The abstract classes for implementing database migration in Angel3 framework. Designed to work with Angel3 ORM.
|
||||
homepage: https://angel3-framework.web.app/
|
||||
repository: https://github.com/dart-backend/angel/tree/master/packages/orm/angel_migration
|
||||
environment:
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
# Change Log
|
||||
|
||||
## 8.2.1
|
||||
|
||||
* Updated README
|
||||
* Added test cases for `PostgreSQL`
|
||||
* Added test cases for `MySQL`
|
||||
* Added test cases for `MariaDB`
|
||||
|
||||
## 8.2.0
|
||||
|
||||
* Require Dart >= 3.3
|
||||
|
|
|
@ -5,9 +5,7 @@
|
|||
[![Discord](https://img.shields.io/discord/1060322353214660698)](https://discord.gg/3X6bxTUdCM)
|
||||
[![License](https://img.shields.io/github/license/dart-backend/angel)](https://github.com/dart-backend/angel/tree/master/packages/orm/angel_migration_runner/LICENSE)
|
||||
|
||||
Database migration runner for Angel3 ORM.
|
||||
|
||||
Supported database:
|
||||
This package contains the implementation of the database migration for the following databases. It is designed to work with Angel3 ORM.
|
||||
|
||||
* PostgreSQL 10.x or greater
|
||||
* MariaDB 10.2.x or greater
|
||||
|
|
|
@ -17,8 +17,8 @@ class MariaDbMigrationRunner implements MigrationRunner {
|
|||
|
||||
MariaDbMigrationRunner(this.connection,
|
||||
{Iterable<Migration> migrations = const [], bool connected = false}) {
|
||||
if (migrations.isNotEmpty == true) migrations.forEach(addMigration);
|
||||
_connected = connected == true;
|
||||
if (migrations.isNotEmpty) migrations.forEach(addMigration);
|
||||
_connected = connected;
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -17,8 +17,10 @@ class MySqlMigrationRunner implements MigrationRunner {
|
|||
|
||||
MySqlMigrationRunner(this.connection,
|
||||
{Iterable<Migration> migrations = const [], bool connected = false}) {
|
||||
if (migrations.isNotEmpty == true) migrations.forEach(addMigration);
|
||||
_connected = connected == true;
|
||||
if (migrations.isNotEmpty) {
|
||||
migrations.forEach(addMigration);
|
||||
}
|
||||
_connected = connected;
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: angel3_migration_runner
|
||||
version: 8.2.0
|
||||
description: Command-line based database migration runner for Angel3's ORM.
|
||||
version: 8.2.1
|
||||
description: The implementation of database migration for Angel3 framework. Designed to work with Angel3 ORM.
|
||||
homepage: https://angel3-framework.web.app/
|
||||
repository: https://github.com/dart-backend/angel/tree/master/packages/orm/angel_migration_runner
|
||||
environment:
|
||||
|
@ -16,6 +16,7 @@ dependencies:
|
|||
logging: ^1.2.0
|
||||
dev_dependencies:
|
||||
lints: ^4.0.0
|
||||
test: ^1.25.0
|
||||
# dependency_overrides:
|
||||
# angel3_orm:
|
||||
# path: ../angel_orm
|
||||
|
|
31
packages/orm/angel_migration_runner/test/mariadb_test.dart
Normal file
31
packages/orm/angel_migration_runner/test/mariadb_test.dart
Normal file
|
@ -0,0 +1,31 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:mysql1/mysql1.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() async {
|
||||
late MySqlConnection conn;
|
||||
|
||||
setUp(() async {
|
||||
var host = Platform.environment['MYSQL_HOST'] ?? 'localhost';
|
||||
var database = Platform.environment['MYSQL_DB'] ?? 'orm_test';
|
||||
var username = Platform.environment['MYSQL_USERNAME'] ?? 'test';
|
||||
var password = Platform.environment['MYSQL_PASSWORD'] ?? 'test123';
|
||||
|
||||
var settings = ConnectionSettings(
|
||||
host: host,
|
||||
port: 3306,
|
||||
db: database,
|
||||
user: username,
|
||||
password: password);
|
||||
conn = await MySqlConnection.connect(settings);
|
||||
});
|
||||
|
||||
group('MariaDB', () {
|
||||
test('migrate tables', () async {});
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await conn.close();
|
||||
});
|
||||
}
|
53
packages/orm/angel_migration_runner/test/models/todo.dart
Normal file
53
packages/orm/angel_migration_runner/test/models/todo.dart
Normal file
|
@ -0,0 +1,53 @@
|
|||
import 'package:angel3_migration/angel3_migration.dart';
|
||||
import 'package:angel3_orm/angel3_orm.dart';
|
||||
|
||||
class UserMigration implements Migration {
|
||||
@override
|
||||
void up(Schema schema) {
|
||||
schema.create('users', (table) {
|
||||
table
|
||||
..serial('id').primaryKey()
|
||||
..varChar('username', length: 32).unique()
|
||||
..varChar('password')
|
||||
..boolean('account_confirmed').defaultsTo(false);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void down(Schema schema) {
|
||||
schema.drop('users');
|
||||
}
|
||||
}
|
||||
|
||||
class TodoMigration implements Migration {
|
||||
@override
|
||||
void up(Schema schema) {
|
||||
schema.create('todos', (table) {
|
||||
table
|
||||
..serial('id').primaryKey()
|
||||
..integer('user_id').references('users', 'id').onDeleteCascade()
|
||||
..varChar('text')
|
||||
..boolean('completed').defaultsTo(false);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void down(Schema schema) {
|
||||
schema.drop('todos');
|
||||
}
|
||||
}
|
||||
|
||||
class ItemMigration extends Migration {
|
||||
@override
|
||||
void up(Schema schema) {
|
||||
schema.create('items', (table) {
|
||||
table
|
||||
..serial('id').primaryKey()
|
||||
..varChar('name', length: 64)
|
||||
..timeStamp('created_at').defaultsTo(currentTimestamp);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void down(Schema schema) => schema.drop('items');
|
||||
}
|
34
packages/orm/angel_migration_runner/test/mysql_test.dart
Normal file
34
packages/orm/angel_migration_runner/test/mysql_test.dart
Normal file
|
@ -0,0 +1,34 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:mysql_client/mysql_client.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() async {
|
||||
late MySQLConnection conn;
|
||||
|
||||
setUp(() async {
|
||||
var host = Platform.environment['MYSQL_HOST'] ?? 'localhost';
|
||||
var database = Platform.environment['MYSQL_DB'] ?? 'orm_test';
|
||||
var username = Platform.environment['MYSQL_USERNAME'] ?? 'test';
|
||||
var password = Platform.environment['MYSQL_PASSWORD'] ?? 'test123';
|
||||
var secure = !('false' == Platform.environment['MYSQL_SECURE']);
|
||||
|
||||
print("$host $database $username $password $secure");
|
||||
|
||||
conn = await MySQLConnection.createConnection(
|
||||
databaseName: database,
|
||||
port: 3306,
|
||||
host: host,
|
||||
userName: username,
|
||||
password: password,
|
||||
secure: secure);
|
||||
});
|
||||
|
||||
group('Mysql', () {
|
||||
test('migrate tables', () async {});
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await conn.close();
|
||||
});
|
||||
}
|
32
packages/orm/angel_migration_runner/test/pg_test.dart
Normal file
32
packages/orm/angel_migration_runner/test/pg_test.dart
Normal file
|
@ -0,0 +1,32 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:postgres/postgres.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() async {
|
||||
late Connection conn;
|
||||
|
||||
setUp(() async {
|
||||
var host = Platform.environment['POSTGRES_HOST'] ?? 'localhost';
|
||||
var database = Platform.environment['POSTGRES_DB'] ?? 'orm_test';
|
||||
var username = Platform.environment['POSTGRES_USERNAME'] ?? 'test';
|
||||
var password = Platform.environment['POSTGRES_PASSWORD'] ?? 'test123';
|
||||
|
||||
print("$host $database $username $password");
|
||||
|
||||
conn = await Connection.open(Endpoint(
|
||||
host: host,
|
||||
port: 5432,
|
||||
database: database,
|
||||
username: username,
|
||||
password: password));
|
||||
});
|
||||
|
||||
group('PostgreSQL', () {
|
||||
test('migrate tables', () async {});
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await conn.close();
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue