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