Skip to content

postgrelize / ConstraintOptions

Type Alias: ConstraintOptions ​

ConstraintOptions = Readonly<{ deferrable?: DeferrableValue; enforced?: boolean; exclude?: readonly ExcludeElement[]; fields?: readonly string[]; include?: readonly string[]; name?: string; notValid?: boolean; nullsNotDistinct?: boolean; onDelete?: string; onUpdate?: string; period?: boolean; references?: Readonly<{ field: string; fields?: readonly string[]; table: TableName; }>; type: "check" | "unique" | "primary key" | "foreign key" | "exclude" | "CHECK" | "UNIQUE" | "PRIMARY KEY" | "FOREIGN KEY" | "EXCLUDE"; using?: string; where?: unknown; withoutOverlaps?: boolean; }>

Defined in: src/ddl/ddl-types.ts:182

Options of addConstraint (Sequelize v6).

Example ​

ts
const options: ConstraintOptions = {
  type: 'foreign key',
  fields: ['userId'],
  name: 'posts_user_fk',
  references: { table: 'users', field: 'id' },
  onDelete: 'CASCADE',
};
await queryInterface.addConstraint('posts', options);

Released under the MIT License.