diff --git a/doc/deployment/docker/README.md b/doc/deployment/docker/README.md index 8ee0e05a..c363f1be 100644 --- a/doc/deployment/docker/README.md +++ b/doc/deployment/docker/README.md @@ -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 diff --git a/packages/orm/angel_migration/CHANGELOG.md b/packages/orm/angel_migration/CHANGELOG.md index d1375bab..44977d14 100755 --- a/packages/orm/angel_migration/CHANGELOG.md +++ b/packages/orm/angel_migration/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 8.2.1 + +* Updated README + ## 8.2.0 * Require Dart >= 3.3 diff --git a/packages/orm/angel_migration/README.md b/packages/orm/angel_migration/README.md index 232a633e..7b31ebb5 100755 --- a/packages/orm/angel_migration/README.md +++ b/packages/orm/angel_migration/README.md @@ -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]() 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 diff --git a/packages/orm/angel_migration/pubspec.yaml b/packages/orm/angel_migration/pubspec.yaml index d54b9e49..73c9ee85 100755 --- a/packages/orm/angel_migration/pubspec.yaml +++ b/packages/orm/angel_migration/pubspec.yaml @@ -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: diff --git a/packages/orm/angel_migration_runner/CHANGELOG.md b/packages/orm/angel_migration_runner/CHANGELOG.md index 2b8a736a..08f41f70 100755 --- a/packages/orm/angel_migration_runner/CHANGELOG.md +++ b/packages/orm/angel_migration_runner/CHANGELOG.md @@ -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 diff --git a/packages/orm/angel_migration_runner/README.md b/packages/orm/angel_migration_runner/README.md index 628fb764..8c7fe159 100755 --- a/packages/orm/angel_migration_runner/README.md +++ b/packages/orm/angel_migration_runner/README.md @@ -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 diff --git a/packages/orm/angel_migration_runner/lib/src/mariadb/runner.dart b/packages/orm/angel_migration_runner/lib/src/mariadb/runner.dart index 24473657..73ad3710 100644 --- a/packages/orm/angel_migration_runner/lib/src/mariadb/runner.dart +++ b/packages/orm/angel_migration_runner/lib/src/mariadb/runner.dart @@ -17,8 +17,8 @@ class MariaDbMigrationRunner implements MigrationRunner { MariaDbMigrationRunner(this.connection, {Iterable migrations = const [], bool connected = false}) { - if (migrations.isNotEmpty == true) migrations.forEach(addMigration); - _connected = connected == true; + if (migrations.isNotEmpty) migrations.forEach(addMigration); + _connected = connected; } @override diff --git a/packages/orm/angel_migration_runner/lib/src/mysql/runner.dart b/packages/orm/angel_migration_runner/lib/src/mysql/runner.dart index 561ace41..29d606ab 100644 --- a/packages/orm/angel_migration_runner/lib/src/mysql/runner.dart +++ b/packages/orm/angel_migration_runner/lib/src/mysql/runner.dart @@ -17,8 +17,10 @@ class MySqlMigrationRunner implements MigrationRunner { MySqlMigrationRunner(this.connection, {Iterable migrations = const [], bool connected = false}) { - if (migrations.isNotEmpty == true) migrations.forEach(addMigration); - _connected = connected == true; + if (migrations.isNotEmpty) { + migrations.forEach(addMigration); + } + _connected = connected; } @override diff --git a/packages/orm/angel_migration_runner/pubspec.yaml b/packages/orm/angel_migration_runner/pubspec.yaml index 8c649fb1..a54efa61 100755 --- a/packages/orm/angel_migration_runner/pubspec.yaml +++ b/packages/orm/angel_migration_runner/pubspec.yaml @@ -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 diff --git a/packages/orm/angel_migration_runner/test/mariadb_test.dart b/packages/orm/angel_migration_runner/test/mariadb_test.dart new file mode 100644 index 00000000..6b9bbc47 --- /dev/null +++ b/packages/orm/angel_migration_runner/test/mariadb_test.dart @@ -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(); + }); +} diff --git a/packages/orm/angel_migration_runner/test/models/todo.dart b/packages/orm/angel_migration_runner/test/models/todo.dart new file mode 100644 index 00000000..42304920 --- /dev/null +++ b/packages/orm/angel_migration_runner/test/models/todo.dart @@ -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'); +} diff --git a/packages/orm/angel_migration_runner/test/mysql_test.dart b/packages/orm/angel_migration_runner/test/mysql_test.dart new file mode 100644 index 00000000..a30c9fd2 --- /dev/null +++ b/packages/orm/angel_migration_runner/test/mysql_test.dart @@ -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(); + }); +} diff --git a/packages/orm/angel_migration_runner/test/pg_test.dart b/packages/orm/angel_migration_runner/test/pg_test.dart new file mode 100644 index 00000000..8d0db4b0 --- /dev/null +++ b/packages/orm/angel_migration_runner/test/pg_test.dart @@ -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(); + }); +}