Есть таблички:
create table "user" (
id serial not null constraint account_pkey primary key,
email text not null,
password text not null,
);
create table user_role (
user_id integer not null constraint account_role_account_id_fkey references "user",
role_id integer not null,
created_at timestamp(0) default timezone('UTC'::text, now()) not null,
constraint account_role_pkey primary key (user_id, role_id)
);
Хочу удалить юзера. Делаю так:
DELETE FROM "user" CASCADE;
Получаю
update or delete on table "user" violates foreign key constraint "account_role_account_id_fkey" on table "user_role"
В чём причина?
DELETE FROM "user" CASCADE;
- синтаксис DELETE statement не предусматривает опцииCASCADE
(даже слова такого на странице нету...).