Files
Jani Pulkkinen 0756da8b7b Lootaherra
2025-05-29 20:33:15 +03:00

42 lines
1.2 KiB
SQL

-- Lootakalenteri migration tables
create table loota_admin
(
id uuid primary key not null default gen_random_uuid(),
identifier varchar not null,
created_time timestamp with time zone not null default now()
);
create table loota_customer
(
id uuid primary key not null default gen_random_uuid(),
identifier varchar not null,
created_time timestamp with time zone not null default now()
);
create table loota_order
(
id uuid primary key not null default gen_random_uuid(),
customer_id uuid not null,
location varchar not null,
created_time timestamp with time zone not null default now()
);
alter table loota_order
add constraint fk_customer_id foreign key (customer_id)
references loota_customer (id) on delete cascade;
create table loota_box
(
id uuid primary key not null default gen_random_uuid(),
order_id uuid not null,
delivery_date timestamp with time zone,
pickup_date timestamp with time zone,
created_time timestamp with time zone not null default now()
);
alter table loota_box
add constraint fk_order_id foreign key (order_id)
references loota_order (id) on delete cascade;