From 709ec63f8d2f2832e7f6aad2e99ce93cd16fc2f5 Mon Sep 17 00:00:00 2001 From: 24Victor Date: Mon, 2 Dec 2024 20:46:35 +0100 Subject: [PATCH] refactor:model-database --- database/start-scripts/0-init.sql | 45 ++++++++++++++++++------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/database/start-scripts/0-init.sql b/database/start-scripts/0-init.sql index b6e56157..3322d706 100644 --- a/database/start-scripts/0-init.sql +++ b/database/start-scripts/0-init.sql @@ -34,6 +34,15 @@ create table users ( foreign key (photo_id) references photos(id) ); +create table work_orders_users( + id int auto_increment primary key, + work_order_id int not null, + user_id int not null, + created_at timestamp default current_timestamp, + foreign key (work_order_id) references work_orders(id), + foreign key (user_id) references users(id) +); + create table contracts ( id int auto_increment primary key, name varchar(255) not null, @@ -194,36 +203,36 @@ create table work_orders ( foreign key (contract_id) references contracts(id) ); -create table tasks ( +create table block_WO( id int auto_increment primary key, work_order_id int not null, - task_type_id int not null, - notes varchar(255), - route_id int, created_at timestamp default current_timestamp, - updated_at timestamp, - deleted_at timestamp, foreign key (work_order_id) references work_orders(id), - foreign key (task_type_id) references task_types(id), - foreign key (route_id) references routes(id) ); -create table tasks_users ( +create table block_WO_zones( id int auto_increment primary key, - task_id int, - user_id int, + block_WO_id int not null, + zone_id int not null, created_at timestamp default current_timestamp, - foreign key (task_id) references tasks(id), - foreign key (user_id) references users(id) + foreign key (block_WO_id) references block_WO(id), + foreign key (zone_id) references zones(id) ); -create table tasks_zones ( +create table tasks ( id int auto_increment primary key, - task_id int, - zone_id int, + task_type_id int not null, + notes varchar(255), + species varchar(255), + status int, + route_id int, + block_wo_id int, created_at timestamp default current_timestamp, - foreign key (task_id) references tasks(id), - foreign key (zone_id) references zones(id) + updated_at timestamp, + deleted_at timestamp, + foreign key (task_type_id) references task_types(id), + foreign key (route_id) references routes(id), + foreign key (block_wo_id) references block_WO(id) ); create table work_reports (