Files
lootakalenteri-backend/migrations/2025-04-10-064257_create_lootakalenteri/up.sql
Jani Pulkkinen 27a51916a3 Initial version
2025-04-16 15:03:30 +03:00

35 lines
1.0 KiB
SQL

-- Lootakalenteri migration tables
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;