create table statuses (
id serial primary key, title varchar
);
insert into statuses (title)
values
('Active'),
('Not active'),
('Else');
create table accounts (
id serial,
name varchar,
status_id int default 2,
FOREIGN KEY(status_id) REFERENCES statuses(id)
);
insert into accounts (name, status_id)
values
('Test account', 3);
select
*
from
accounts;
delete from
statuses
where
id = 3;
alter table
add
constraint accounts_status_id_def_fkey FOREIGN KEY(status_id) REFERENCES statuses(id) on delete
set
default;