From aa72814886c14a31999c668cf59a7452166c5382 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Sat, 18 Nov 2017 15:12:30 -0500 Subject: [PATCH] README --- README.md | 3 ++- .../test/models/author.migration.g.dart | 26 ++++++++++++++++++ .../test/models/book.migration.g.dart | 25 +++++++++++++++++ .../test/models/car.migration.g.dart | 27 +++++++++++++++++++ .../test/models/foot.migration.g.dart | 25 +++++++++++++++++ .../test/models/fruit.migration.g.dart | 25 +++++++++++++++++ .../test/models/leg.migration.g.dart | 24 +++++++++++++++++ .../test/models/role.migration.g.dart | 24 +++++++++++++++++ .../test/models/tree.migration.g.dart | 24 +++++++++++++++++ .../test/models/user.migration.g.dart | 27 +++++++++++++++++++ 10 files changed, 229 insertions(+), 1 deletion(-) create mode 100644 angel_orm_generator/test/models/author.migration.g.dart create mode 100644 angel_orm_generator/test/models/book.migration.g.dart create mode 100644 angel_orm_generator/test/models/car.migration.g.dart create mode 100644 angel_orm_generator/test/models/foot.migration.g.dart create mode 100644 angel_orm_generator/test/models/fruit.migration.g.dart create mode 100644 angel_orm_generator/test/models/leg.migration.g.dart create mode 100644 angel_orm_generator/test/models/role.migration.g.dart create mode 100644 angel_orm_generator/test/models/tree.migration.g.dart create mode 100644 angel_orm_generator/test/models/user.migration.g.dart diff --git a/README.md b/README.md index f6d8a1c3..5f30c299 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,10 @@ dev_dependencies: build_runner: ^0.5.0 ``` -`package:angel_orm_generator` exports two classes that you can include +`package:angel_orm_generator` exports three classes that you can include in a `package:build` flow: * `PostgresOrmGenerator` - Fueled by `package:source_gen`; include this within a `LibraryBuilder`. +* `MigrationGenerator` - Builds a [`package:angel_migration`](https://github.com/angel-dart/migration) migration for your models automatically. * `SqlMigrationBuilder` - This is its own `Builder`; it generates a SQL schema, as well as a SQL script to drop a generated table. You should pass an `List` containing your project's models. diff --git a/angel_orm_generator/test/models/author.migration.g.dart b/angel_orm_generator/test/models/author.migration.g.dart new file mode 100644 index 00000000..e8fb5908 --- /dev/null +++ b/angel_orm_generator/test/models/author.migration.g.dart @@ -0,0 +1,26 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ************************************************************************** +// Generator: MigrationGenerator +// ************************************************************************** + +import 'package:angel_migration/angel_migration.dart'; + +class AuthorMigration extends Migration { + @override + up(Schema schema) { + schema.create('authors', (table) { + table.serial('id')..primaryKey(); + table.varchar('name', length: 255) + ..defaultsTo('Tobe Osakwe') + ..unique(); + table.timeStamp('created_at'); + table.timeStamp('updated_at'); + }); + } + + @override + down(Schema schema) { + schema.drop('authors'); + } +} diff --git a/angel_orm_generator/test/models/book.migration.g.dart b/angel_orm_generator/test/models/book.migration.g.dart new file mode 100644 index 00000000..12ae1d13 --- /dev/null +++ b/angel_orm_generator/test/models/book.migration.g.dart @@ -0,0 +1,25 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ************************************************************************** +// Generator: MigrationGenerator +// ************************************************************************** + +import 'package:angel_migration/angel_migration.dart'; + +class BookMigration extends Migration { + @override + up(Schema schema) { + schema.create('books', (table) { + table.serial('id')..primaryKey(); + table.varchar('name'); + table.timeStamp('created_at'); + table.timeStamp('updated_at'); + table.integer('author_id').references('authors', 'id').onDeleteCascade(); + }); + } + + @override + down(Schema schema) { + schema.drop('books'); + } +} diff --git a/angel_orm_generator/test/models/car.migration.g.dart b/angel_orm_generator/test/models/car.migration.g.dart new file mode 100644 index 00000000..4714b5c5 --- /dev/null +++ b/angel_orm_generator/test/models/car.migration.g.dart @@ -0,0 +1,27 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ************************************************************************** +// Generator: MigrationGenerator +// ************************************************************************** + +import 'package:angel_migration/angel_migration.dart'; + +class CarMigration extends Migration { + @override + up(Schema schema) { + schema.create('cars', (table) { + table.serial('id')..primaryKey(); + table.varchar('make'); + table.varchar('description'); + table.boolean('family_friendly'); + table.timeStamp('recalled_at'); + table.timeStamp('created_at'); + table.timeStamp('updated_at'); + }); + } + + @override + down(Schema schema) { + schema.drop('cars'); + } +} diff --git a/angel_orm_generator/test/models/foot.migration.g.dart b/angel_orm_generator/test/models/foot.migration.g.dart new file mode 100644 index 00000000..0e365597 --- /dev/null +++ b/angel_orm_generator/test/models/foot.migration.g.dart @@ -0,0 +1,25 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ************************************************************************** +// Generator: MigrationGenerator +// ************************************************************************** + +import 'package:angel_migration/angel_migration.dart'; + +class FootMigration extends Migration { + @override + up(Schema schema) { + schema.create('foots', (table) { + table.serial('id')..primaryKey(); + table.integer('leg_id'); + table.integer('n_toes'); + table.timeStamp('created_at'); + table.timeStamp('updated_at'); + }); + } + + @override + down(Schema schema) { + schema.drop('foots'); + } +} diff --git a/angel_orm_generator/test/models/fruit.migration.g.dart b/angel_orm_generator/test/models/fruit.migration.g.dart new file mode 100644 index 00000000..a5021b2b --- /dev/null +++ b/angel_orm_generator/test/models/fruit.migration.g.dart @@ -0,0 +1,25 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ************************************************************************** +// Generator: MigrationGenerator +// ************************************************************************** + +import 'package:angel_migration/angel_migration.dart'; + +class FruitMigration extends Migration { + @override + up(Schema schema) { + schema.create('fruits', (table) { + table.serial('id')..primaryKey(); + table.integer('tree_id'); + table.varchar('common_name'); + table.timeStamp('created_at'); + table.timeStamp('updated_at'); + }); + } + + @override + down(Schema schema) { + schema.drop('fruits'); + } +} diff --git a/angel_orm_generator/test/models/leg.migration.g.dart b/angel_orm_generator/test/models/leg.migration.g.dart new file mode 100644 index 00000000..32a0ab1a --- /dev/null +++ b/angel_orm_generator/test/models/leg.migration.g.dart @@ -0,0 +1,24 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ************************************************************************** +// Generator: MigrationGenerator +// ************************************************************************** + +import 'package:angel_migration/angel_migration.dart'; + +class LegMigration extends Migration { + @override + up(Schema schema) { + schema.create('legs', (table) { + table.serial('id')..primaryKey(); + table.varchar('name'); + table.timeStamp('created_at'); + table.timeStamp('updated_at'); + }); + } + + @override + down(Schema schema) { + schema.drop('legs'); + } +} diff --git a/angel_orm_generator/test/models/role.migration.g.dart b/angel_orm_generator/test/models/role.migration.g.dart new file mode 100644 index 00000000..3eeb6492 --- /dev/null +++ b/angel_orm_generator/test/models/role.migration.g.dart @@ -0,0 +1,24 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ************************************************************************** +// Generator: MigrationGenerator +// ************************************************************************** + +import 'package:angel_migration/angel_migration.dart'; + +class RoleMigration extends Migration { + @override + up(Schema schema) { + schema.create('roles', (table) { + table.serial('id')..primaryKey(); + table.varchar('name'); + table.timeStamp('created_at'); + table.timeStamp('updated_at'); + }); + } + + @override + down(Schema schema) { + schema.drop('roles'); + } +} diff --git a/angel_orm_generator/test/models/tree.migration.g.dart b/angel_orm_generator/test/models/tree.migration.g.dart new file mode 100644 index 00000000..11ed9d2f --- /dev/null +++ b/angel_orm_generator/test/models/tree.migration.g.dart @@ -0,0 +1,24 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ************************************************************************** +// Generator: MigrationGenerator +// ************************************************************************** + +import 'package:angel_migration/angel_migration.dart'; + +class TreeMigration extends Migration { + @override + up(Schema schema) { + schema.create('trees', (table) { + table.serial('id')..primaryKey(); + table.integer('rings')..unique(); + table.timeStamp('created_at'); + table.timeStamp('updated_at'); + }); + } + + @override + down(Schema schema) { + schema.drop('trees'); + } +} diff --git a/angel_orm_generator/test/models/user.migration.g.dart b/angel_orm_generator/test/models/user.migration.g.dart new file mode 100644 index 00000000..c3654957 --- /dev/null +++ b/angel_orm_generator/test/models/user.migration.g.dart @@ -0,0 +1,27 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ************************************************************************** +// Generator: MigrationGenerator +// ************************************************************************** + +import 'package:angel_migration/angel_migration.dart'; + +class UserMigration extends Migration { + @override + up(Schema schema) { + schema.create('users', (table) { + table.serial('id')..primaryKey(); + table.varchar('username'); + table.varchar('password'); + table.varchar('email'); + table.timeStamp('created_at'); + table.timeStamp('updated_at'); + table.integer('role_id').references('roles', 'id'); + }); + } + + @override + down(Schema schema) { + schema.drop('users'); + } +}