README
This commit is contained in:
parent
97989a6250
commit
aa72814886
10 changed files with 229 additions and 1 deletions
|
@ -25,9 +25,10 @@ dev_dependencies:
|
||||||
build_runner: ^0.5.0
|
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:
|
in a `package:build` flow:
|
||||||
* `PostgresOrmGenerator` - Fueled by `package:source_gen`; include this within a `LibraryBuilder`.
|
* `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.
|
* `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<String>` containing your project's models.
|
You should pass an `List<String>` containing your project's models.
|
||||||
|
|
26
angel_orm_generator/test/models/author.migration.g.dart
Normal file
26
angel_orm_generator/test/models/author.migration.g.dart
Normal file
|
@ -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');
|
||||||
|
}
|
||||||
|
}
|
25
angel_orm_generator/test/models/book.migration.g.dart
Normal file
25
angel_orm_generator/test/models/book.migration.g.dart
Normal file
|
@ -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');
|
||||||
|
}
|
||||||
|
}
|
27
angel_orm_generator/test/models/car.migration.g.dart
Normal file
27
angel_orm_generator/test/models/car.migration.g.dart
Normal file
|
@ -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');
|
||||||
|
}
|
||||||
|
}
|
25
angel_orm_generator/test/models/foot.migration.g.dart
Normal file
25
angel_orm_generator/test/models/foot.migration.g.dart
Normal file
|
@ -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');
|
||||||
|
}
|
||||||
|
}
|
25
angel_orm_generator/test/models/fruit.migration.g.dart
Normal file
25
angel_orm_generator/test/models/fruit.migration.g.dart
Normal file
|
@ -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');
|
||||||
|
}
|
||||||
|
}
|
24
angel_orm_generator/test/models/leg.migration.g.dart
Normal file
24
angel_orm_generator/test/models/leg.migration.g.dart
Normal file
|
@ -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');
|
||||||
|
}
|
||||||
|
}
|
24
angel_orm_generator/test/models/role.migration.g.dart
Normal file
24
angel_orm_generator/test/models/role.migration.g.dart
Normal file
|
@ -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');
|
||||||
|
}
|
||||||
|
}
|
24
angel_orm_generator/test/models/tree.migration.g.dart
Normal file
24
angel_orm_generator/test/models/tree.migration.g.dart
Normal file
|
@ -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');
|
||||||
|
}
|
||||||
|
}
|
27
angel_orm_generator/test/models/user.migration.g.dart
Normal file
27
angel_orm_generator/test/models/user.migration.g.dart
Normal file
|
@ -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');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue