Updated temporal mapping

This commit is contained in:
thomashii@dukefirehawk.com 2022-07-24 13:10:23 +08:00
parent 572a134c9c
commit aff68b2f07
11 changed files with 40 additions and 16 deletions

View file

@ -5,10 +5,20 @@
[![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion)
[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_migration/LICENSE)
A database migration framework built for Angel3 ORM.
A basic database migration framework built for Angel3 ORM.
## Supported database
* PostgreSQL version 10 or later
* MariaDB 10.2.x
* MySQL 8.x
* MariaDB 10.2.x or later
* MySQL 8.x or later
## Features
* Create tables based on ORM models
* Drop tables based on ORM models
* Add new tables based ORM models
## Limitation
* Alter table/fields based on updated ORM models not supported

View file

@ -1,9 +1,10 @@
# Change Log
## 6.0.2
## 6.1.0
* Upgraded to `lints` 2.x.x
* Fixed issue #70. Incorrectly generated SQL for `defaultsTo('Default Value')`
* Mapped timestamp to datetime for MySQL and MariaDB
## 6.0.1

View file

@ -5,7 +5,7 @@
[![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion)
[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_migration_runner/LICENSE)
Command-line based database migration runner for Angel3 ORM.
Database migration runner for Angel3 ORM.
Supported database:
@ -15,10 +15,8 @@ Supported database:
## Usage
* For PostgreSQL, use `PostgresMigrationRunner` to perform the database migration.
* Use `PostgresMigrationRunner` to perform the database migration for PostgreSQL.
* For MariaDB, use `MariaDbMigrationRunner` to perform the database migration.
* Use `MySqlMigrationRunner` to perform the database migration for MySQL and MariaDB. This is implemented with [`mysql_client`](https://pub.dev/packages?q=mysql_client) driver.
* For MySQL, use `MySqlMigrationRunner` to perform the database migration.
**Important Notes** For MariaDB and MySQL, both migration runner are using different drivers. MariaDB is using `mysql1` driver while MySQL is using `mysql_client` driver. This is necessary as neither driver works correctly over both MariaDB and MySQL. Based on testing, `mysql1` driver works seamlessly with MariaDB 10.2.x while `mysql_client` works well with MySQL 8.x.
* Use `MariaDbMigrationRunner` to perform the database migration for MariaDB. [`mysql1`](https://pub.dev/packages?q=mysql1).

View file

@ -6,6 +6,11 @@ import 'package:charcode/ascii.dart';
abstract class MariaDbGenerator {
static String columnType(MigrationColumn column) {
var str = column.type.name;
// Map timestamp time to datetime
if (column.type == ColumnType.timeStamp) {
str = ColumnType.dateTime.name;
}
if (column.type.hasLength) {
return '$str(${column.length})';
} else {

View file

@ -6,6 +6,10 @@ import 'package:charcode/ascii.dart';
abstract class MySqlGenerator {
static String columnType(MigrationColumn column) {
var str = column.type.name;
// Map timestamp time to datetime
if (column.type == ColumnType.timeStamp) {
str = ColumnType.dateTime.name;
}
if (column.type.hasLength) {
return '$str(${column.length})';
} else {

View file

@ -1,5 +1,5 @@
name: angel3_migration_runner
version: 6.0.2
version: 6.1.0
description: Command-line based database migration runner for Angel3's ORM.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_migration_runner

View file

@ -1,5 +1,11 @@
# Change Log
## 6.0.0
* Fixed temporal data type
* Fixed `MariaDbExcutor` transaction
* Updated to `lints` 2.0.0
## 6.0.0-beta.3
* Fixed transaction for `MariaDbExecutor`

View file

@ -1,5 +1,5 @@
name: angel3_orm_mysql
version: 6.0.0-beta.3
version: 6.0.0
description: MySQL support for Angel3 ORM. Includes functionality for querying and transactions.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_mysql
@ -16,7 +16,7 @@ dev_dependencies:
angel3_orm_test: ^6.0.0
build_runner: ^2.0.1
test: ^1.21.0
lints: ^1.0.0
lints: ^2.0.0
dependency_overrides:
# angel3_serialize:
# path: ../../serialize/angel_serialize

View file

@ -1,9 +1,9 @@
# Change Log
## 6.0.1
## 6.1.0
* Upgraded to `lints` 2.x.x
* Fixed #71. Create a new database connection and retry.
* Fixed #71. Restablish broken connection automatically.
## 6.0.0

View file

@ -1,5 +1,5 @@
name: angel3_orm_postgres
version: 6.0.1
version: 6.1.0
description: PostgreSQL support for Angel3 ORM. Includes functionality for querying and transactions.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_postgres