Thanks to visit codestin.com
Credit goes to github.com

Skip to content

onDelete not applying in migration #308

@rickharrison

Description

@rickharrison

In my migration I have a column definition like this:

table.integer('user_id').notNullable().references('id').inTable('users').onDelete('cascade');

In knex 0.5, this worked correctly, but on 0.6.12, it is not applying the onDelete clause. Here are the queries made under debug: true

{ __cid: '__cid1',
  sql: 'create table "user_tokens" ("id" serial primary key, "user_id" integer not null, "token" text not null, "created_at" timestamptz default now(), "updated_at" timestamptz default now())',
  bindings: [] }
{ __cid: '__cid1',
  sql: 'alter table "user_tokens" add constraint user_tokens_user_id_foreign foreign key ("user_id") references "users" ("id")',
  bindings: [] }
{ __cid: '__cid1',
  sql: 'alter table "user_tokens" add constraint user_tokens_token_unique unique ("token")',
  bindings: [] }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions