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="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart SDK" level="project" /> <orderEntry type="library" name="Dart SDK" level="project" />
<orderEntry type="library" name="Dart Packages" level="project" />
</component> </component>
</module> </module>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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