initial db
This commit is contained in:
26
db/migration/base/002.up.company.sql
Normal file
26
db/migration/base/002.up.company.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
create table company (
|
||||
clid dmn_clid,
|
||||
id bigint generated by default as identity PRIMARY key,
|
||||
code dmn_code,
|
||||
title text,
|
||||
is_active boolean default true not null,
|
||||
|
||||
notes text,
|
||||
|
||||
zlins_dttm timestamptz,
|
||||
zlupd_dttm timestamptz,
|
||||
|
||||
constraint uq_company unique (clid, code)
|
||||
);
|
||||
|
||||
CREATE TRIGGER zl_company before INSERT or UPDATE ON company
|
||||
FOR EACH ROW EXECUTE FUNCTION zllog();
|
||||
|
||||
create table company_usr (
|
||||
id bigint generated by default as identity PRIMARY key,
|
||||
company_id bigint not null,
|
||||
usr_id dmn_usrid,
|
||||
constraint uq_company_usr unique (company_id, usr_id),
|
||||
constraint fk_company_usr_company foreign key (company_id)
|
||||
references company(id) on update cascade on delete cascade
|
||||
);
|
||||
Reference in New Issue
Block a user