Fixed errant build, pushed +5

This commit is contained in:
Tobe O 2017-11-20 13:09:23 -05:00
parent aa72814886
commit 6468522b5a
13 changed files with 22 additions and 17 deletions

View file

@ -16,6 +16,5 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart SDK" level="project" />
<orderEntry type="library" name="Dart Packages" level="project" />
</component>
</module>

View file

@ -142,7 +142,7 @@ Future<PostgresBuildContext> buildContext(
);
}
if (column != null) {
if (column != null && column.type == null) {
column = new Column(
nullable: column.nullable,
length: column.length,

View file

@ -48,18 +48,19 @@ class MigrationGenerator extends GeneratorForAnnotation<ORM> {
var clazz = new ClassBuilder('${ctx.modelClassName}Migration',
asExtends: new TypeBuilder('Migration'));
clazz..addMethod(buildUpMigration(ctx))..addMethod(buildDownMigration(ctx));
clazz..addMethod(buildUpMigration(ctx, lib))..addMethod(buildDownMigration(ctx));
return lib..addMember(clazz);
}
MethodBuilder buildUpMigration(PostgresBuildContext ctx) {
MethodBuilder buildUpMigration(PostgresBuildContext ctx, LibraryBuilder lib) {
var meth = new MethodBuilder('up')..addPositional(_schemaParam);
var closure = new MethodBuilder.closure()
..addPositional(parameter('table'));
var table = reference('table');
List<String> dup = [];
bool hasOrmImport = false;
ctx.columnInfo.forEach((name, col) {
var key = ctx.resolveFieldName(name);
@ -81,8 +82,7 @@ class MigrationGenerator extends GeneratorForAnnotation<ORM> {
List<ExpressionBuilder> positional = [literal(key)];
Map<String, ExpressionBuilder> named = {};
if (autoIdAndDateFields != false && name == 'id')
methodName = 'serial';
if (autoIdAndDateFields != false && name == 'id') methodName = 'serial';
if (methodName == null) {
switch (col.type) {
@ -115,6 +115,11 @@ class MigrationGenerator extends GeneratorForAnnotation<ORM> {
methodName = 'timeStamp';
break;
default:
if (!hasOrmImport) {
hasOrmImport = true;
lib.addDirective(new ImportBuilder('package:angel_orm/angel_orm.dart'));
}
ExpressionBuilder provColumn;
var colType = new TypeBuilder('Column');
var columnTypeType = new TypeBuilder('ColumnType');

View file

@ -1,5 +1,5 @@
CREATE TEMPORARY TABLE "authors" (
"id" varchar,
"id" serial,
"name" varchar UNIQUE,
"created_at" timestamp,
"updated_at" timestamp,

View file

@ -1,5 +1,5 @@
CREATE TEMPORARY TABLE "books" (
"id" varchar,
"id" serial,
"name" varchar,
"created_at" timestamp,
"updated_at" timestamp,

View file

@ -1,5 +1,5 @@
CREATE TEMPORARY TABLE "cars" (
"id" varchar,
"id" serial,
"make" varchar,
"description" varchar,
"family_friendly" boolean,

View file

@ -1,5 +1,5 @@
CREATE TEMPORARY TABLE "foots" (
"id" varchar,
"id" serial,
"leg_id" int,
"n_toes" int,
"created_at" timestamp,

View file

@ -1,5 +1,5 @@
CREATE TEMPORARY TABLE "fruits" (
"id" varchar,
"id" serial,
"tree_id" int,
"common_name" varchar,
"created_at" timestamp,

View file

@ -1,5 +1,5 @@
CREATE TEMPORARY TABLE "legs" (
"id" varchar,
"id" serial,
"name" varchar,
"created_at" timestamp,
"updated_at" timestamp,

View file

@ -1,5 +1,5 @@
CREATE TEMPORARY TABLE "roles" (
"id" varchar,
"id" serial,
"name" varchar,
"created_at" timestamp,
"updated_at" timestamp,

View file

@ -5,13 +5,14 @@
// **************************************************************************
import 'package:angel_migration/angel_migration.dart';
import 'package:angel_orm/angel_orm.dart';
class TreeMigration extends Migration {
@override
up(Schema schema) {
schema.create('trees', (table) {
table.serial('id')..primaryKey();
table.integer('rings')..unique();
table.declare('rings', new ColumnType('smallint'))..unique();
table.timeStamp('created_at');
table.timeStamp('updated_at');
});

View file

@ -1,6 +1,6 @@
CREATE TEMPORARY TABLE "trees" (
"id" varchar,
"rings" int UNIQUE,
"id" serial,
"rings" smallint UNIQUE,
"created_at" timestamp,
"updated_at" timestamp,
UNIQUE(rings),

View file

@ -1,5 +1,5 @@
CREATE TEMPORARY TABLE "users" (
"id" varchar,
"id" serial,
"username" varchar,
"password" varchar,
"email" varchar,