fix(database): constraints default to false (#550)

* fix(database): constraints default to false

* test(plugin-workflow): skip schedule cases

Co-authored-by: mytharcher <mytharcher@gmail.com>
This commit is contained in:
chenos 2022-06-29 23:20:00 +08:00 committed by GitHub
parent 017c6f232d
commit d3b157075e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 4 deletions

View File

@ -28,6 +28,7 @@ export class BelongsToField extends RelationField {
// define relation on sequelize model
const association = collection.model.belongsTo(Target, {
as: this.name,
constraints: false,
...omit(this.options, ['name', 'type', 'target']),
});

View File

@ -37,6 +37,7 @@ export class BelongsToManyField extends RelationField {
}
const association = collection.model.belongsToMany(Target, {
constraints: false,
...omit(this.options, ['name', 'type', 'target']),
as: this.name,
through: Through.model,

View File

@ -5,10 +5,10 @@ import {
ForeignKeyOptions,
HasManyOptions,
HasManyOptions as SequelizeHasManyOptions,
Utils,
Utils
} from 'sequelize';
import { BaseRelationFieldOptions, MultipleRelationFieldOptions, RelationField } from './relation-field';
import { MultipleRelationFieldOptions, RelationField } from './relation-field';
export interface HasManyFieldOptions extends HasManyOptions {
/**
@ -93,9 +93,10 @@ export class HasManyField extends RelationField {
}
const association = collection.model.hasMany(Target, {
constraints: false,
...omit(this.options, ['name', 'type', 'target']),
as: this.name,
foreignKey: this.foreignKey,
...omit(this.options, ['name', 'type', 'target']),
});
// inverse relation

View File

@ -92,9 +92,10 @@ export class HasOneField extends RelationField {
return false;
}
const association = collection.model.hasOne(Target, {
constraints: false,
...omit(this.options, ['name', 'type', 'target']),
as: this.name,
foreignKey: this.foreignKey,
...omit(this.options, ['name', 'type', 'target']),
});
// 建立关系之后从 pending 列表中删除
database.removePendingField(this);