Cascading auto-drops
This commit is contained in:
parent
00cffcf200
commit
4aed69fb78
2 changed files with 13 additions and 2 deletions
|
@ -3,6 +3,7 @@
|
|||
* Handle cases where the class is not a `Model`.
|
||||
* Stop assuming things have `id`, etc.
|
||||
* Resolve a bug where the `indexType` of `@Column` annotations. would not be found.
|
||||
* Add `cascade: true` to drops for hasOne/hasMany/ManyToMany migrations.
|
||||
|
||||
# 2.0.0-dev.6
|
||||
* Fix bug where an extra field would be inserted into joins and botch the result.
|
||||
|
|
|
@ -237,8 +237,18 @@ class MigrationGenerator extends GeneratorForAnnotation<Orm> {
|
|||
..annotations.add(refer('override'))
|
||||
..requiredParameters.add(_schemaParam)
|
||||
..body = new Block((b) {
|
||||
b.addExpression(
|
||||
_schema.property('drop').call([literalString(ctx.tableName)]));
|
||||
var named = <String, Expression>{};
|
||||
|
||||
if (ctx.relations.values.any((r) =>
|
||||
r.type == RelationshipType.hasOne ||
|
||||
r.type == RelationshipType.hasMany ||
|
||||
r.isManyToMany)) {
|
||||
named['cascade'] = literalTrue;
|
||||
}
|
||||
|
||||
b.addExpression(_schema
|
||||
.property('drop')
|
||||
.call([literalString(ctx.tableName)], named));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue