Remove build.yaml targets in gen
This commit is contained in:
parent
7c5eef9dc2
commit
6e61ec355a
5 changed files with 19 additions and 9 deletions
|
@ -177,15 +177,21 @@ class MigrationGenerator extends GeneratorForAnnotation<Orm> {
|
||||||
refer('RawSql').constInstance([literalString(value)]);
|
refer('RawSql').constInstance([literalString(value)]);
|
||||||
} else if (type is InterfaceType && type.element.isEnum) {
|
} else if (type is InterfaceType && type.element.isEnum) {
|
||||||
// Default to enum index.
|
// Default to enum index.
|
||||||
|
try {
|
||||||
var index =
|
var index =
|
||||||
ConstantReader(defaultValue).read('index').intValue;
|
ConstantReader(defaultValue).read('index')?.intValue;
|
||||||
defaultExpr = literalNum(index);
|
if (index != null) defaultExpr = literalNum(index);
|
||||||
|
} catch (_) {
|
||||||
|
// Extremely weird error occurs here: `Not an instance of int`.
|
||||||
|
// Definitely an analyzer issue.
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
defaultExpr = new CodeExpression(
|
defaultExpr = new CodeExpression(
|
||||||
new Code(dartObjectToString(defaultValue)),
|
new Code(dartObjectToString(defaultValue)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (defaultExpr != null)
|
||||||
cascade.add(refer('defaultsTo').call([defaultExpr]));
|
cascade.add(refer('defaultsTo').call([defaultExpr]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ FieldElement findPrimaryFieldInList(
|
||||||
var column = reviveColumn(new ConstantReader(columnAnnotation));
|
var column = reviveColumn(new ConstantReader(columnAnnotation));
|
||||||
// print(
|
// print(
|
||||||
// ' * Found column on ${field.name} with indexType = ${column.indexType}');
|
// ' * Found column on ${field.name} with indexType = ${column.indexType}');
|
||||||
|
// print(element.metadata);
|
||||||
if (column.indexType == IndexType.primaryKey) return field;
|
if (column.indexType == IndexType.primaryKey) return field;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,6 +302,11 @@ Column reviveColumn(ConstantReader cr) {
|
||||||
cr.peek('indexType')?.objectValue?.getField('index')?.toIntValue() ??
|
cr.peek('indexType')?.objectValue?.getField('index')?.toIntValue() ??
|
||||||
IndexType.none.index];
|
IndexType.none.index];
|
||||||
|
|
||||||
|
if (const TypeChecker.fromRuntime(PrimaryKey)
|
||||||
|
.isAssignableFromType(cr.objectValue.type)) {
|
||||||
|
indexType = IndexType.primaryKey;
|
||||||
|
}
|
||||||
|
|
||||||
if (columnObj != null) {
|
if (columnObj != null) {
|
||||||
columnType = new _ColumnType(columnObj);
|
columnType = new _ColumnType(columnObj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,7 @@ class AuthorMigration extends Migration {
|
||||||
up(Schema schema) {
|
up(Schema schema) {
|
||||||
schema.create('authors', (table) {
|
schema.create('authors', (table) {
|
||||||
table.serial('id')..primaryKey();
|
table.serial('id')..primaryKey();
|
||||||
table.varChar('name', length: 255)
|
table.varChar('name', length: 255)..defaultsTo('Tobe Osakwe');
|
||||||
..defaultsTo('Tobe Osakwe')
|
|
||||||
..unique();
|
|
||||||
table.timeStamp('created_at');
|
table.timeStamp('created_at');
|
||||||
table.timeStamp('updated_at');
|
table.timeStamp('updated_at');
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,7 +11,7 @@ class HasCarMigration extends Migration {
|
||||||
up(Schema schema) {
|
up(Schema schema) {
|
||||||
schema.create('has_cars', (table) {
|
schema.create('has_cars', (table) {
|
||||||
table.serial('id')..primaryKey();
|
table.serial('id')..primaryKey();
|
||||||
table.integer('type')..defaultsTo(0);
|
table.integer('type');
|
||||||
table.timeStamp('created_at');
|
table.timeStamp('created_at');
|
||||||
table.timeStamp('updated_at');
|
table.timeStamp('updated_at');
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,7 +10,7 @@ class UnorthodoxMigration extends Migration {
|
||||||
@override
|
@override
|
||||||
up(Schema schema) {
|
up(Schema schema) {
|
||||||
schema.create('unorthodoxes', (table) {
|
schema.create('unorthodoxes', (table) {
|
||||||
table.varChar('name')..primaryKey();
|
table.varChar('name');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue