Skip to content

Commit

Permalink
add on delete constraint to schema
Browse files Browse the repository at this point in the history
  • Loading branch information
ronenlu committed Sep 18, 2023
1 parent ccec372 commit 9affaa8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ts/src/sequelize_schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export const loadSequelizeModels = (dialect: string, models: ModelCtor[]) => {
// @ts-ignore
sequelize
.getQueryInterface()
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
.queryGenerator.createTableQuery(
def.tableName,
attr,
Expand Down
4 changes: 3 additions & 1 deletion ts/testdata/models/Email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ class Email extends Model {
@Column(DataType.INTEGER)
contact_id!: number;

@BelongsTo(() => Contact)
@BelongsTo(() => Contact, {
onDelete: "CASCADE",
})
contact!: Contact;

@CreatedAt
Expand Down
4 changes: 3 additions & 1 deletion ts/testdata/models/Phone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ class Phone extends Model {
@Column(DataType.INTEGER)
contact_id!: number;

@BelongsTo(() => Contact)
@BelongsTo(() => Contact, {
onDelete: "CASCADE",
})
contact!: Contact;

@CreatedAt
Expand Down

0 comments on commit 9affaa8

Please sign in to comment.