-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
client orders api v1
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,4 @@ sqlx = { version = "0.7", features = [ | |
"tls-rustls", | ||
"macros", | ||
] } | ||
dotenv = "0.15.0" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
CREATE TABLE IF NOT EXISTS client_orders ( | ||
order_number bigint NOT NULL primary key, | ||
client_name_id varchar NOT NULL, | ||
work_piece varchar NOT NULL, | ||
quantity int NOT NULL, | ||
due_date int NOT NULL, | ||
late_pen money NOT NULL, | ||
early_pen money NOT NULL | ||
client_name_id varchar , | ||
order_number bigint , | ||
work_piece varchar NOT NULL, | ||
quantity int NOT NULL, | ||
due_date int NOT NULL, | ||
late_pen money NOT NULL, | ||
early_pen money NOT NULL, | ||
|
||
PRIMARY KEY (client_name_id, order_number) | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,33 @@ | ||
CREATE TABLE IF NOT EXISTS suppliers ( | ||
supplier_id varchar NOT NULL primary key, | ||
name varchar NOT NULL, | ||
piece varchar NOT NULL, | ||
min_order int NOT NULL, | ||
price_per_piece money NOT NULL, | ||
delivery_time interval NOT NULL | ||
name varchar , | ||
piece varchar , | ||
min_order int NOT NULL, | ||
price_per_piece money NOT NULL, | ||
delivery_time interval NOT NULL, | ||
|
||
PRIMARY KEY (name, piece) | ||
); | ||
|
||
INSERT INTO suppliers ( | ||
supplier_id, name, piece, min_order, price_per_piece, delivery_time | ||
) VALUES ('A_P1', 'Supplier A', 'P1', 16, '$30', '4 days'); | ||
name, piece, min_order, price_per_piece, delivery_time | ||
) VALUES ('Supplier A', 'P1', 16, '$30', '4 days'); | ||
|
||
INSERT INTO suppliers ( | ||
supplier_id, name, piece, min_order, price_per_piece, delivery_time | ||
) VALUES ('A_P2', 'Supplier A', 'P2', 16, '$10', '4 days'); | ||
name, piece, min_order, price_per_piece, delivery_time | ||
) VALUES ('Supplier A', 'P2', 16, '$10', '4 days'); | ||
|
||
INSERT INTO suppliers ( | ||
supplier_id, name, piece, min_order, price_per_piece, delivery_time | ||
) VALUES ('B_P1', 'Supplier B', 'P1', 8, '$45', '2 days'); | ||
name, piece, min_order, price_per_piece, delivery_time | ||
) VALUES ('Supplier B', 'P1', 8, '$45', '2 days'); | ||
|
||
INSERT INTO suppliers ( | ||
supplier_id, name, piece, min_order, price_per_piece, delivery_time | ||
) VALUES ('B_P2', 'Supplier B', 'P2', 8, '$15', '2 days'); | ||
name, piece, min_order, price_per_piece, delivery_time | ||
) VALUES ('Supplier B', 'P2', 8, '$15', '2 days'); | ||
|
||
INSERT INTO suppliers ( | ||
supplier_id, name, piece, min_order, price_per_piece, delivery_time | ||
) VALUES ('C_P1', 'Supplier C', 'P1', 4, '$55', '1 days'); | ||
name, piece, min_order, price_per_piece, delivery_time | ||
) VALUES ('Supplier C', 'P1', 4, '$55', '1 days'); | ||
|
||
INSERT INTO suppliers ( | ||
supplier_id, name, piece, min_order, price_per_piece, delivery_time | ||
) VALUES ('C_P2', 'Supplier C', 'P2', 4, '$18', '1 days'); | ||
name, piece, min_order, price_per_piece, delivery_time | ||
) VALUES ('Supplier C', 'P2', 4, '$18', '1 days'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
-- TODO: Rethink this table design afte more of the | ||
-- sistem funcionality comes online | ||
CREATE TABLE IF NOT EXISTS pieces ( | ||
id bigserial NOT NULL primary key, | ||
piece_type varchar NOT NULL , | ||
-- Probably not necessary? | ||
client_order int NOT NULL references client_orders(order_number), | ||
piece_id int GENERATED ALWAYS AS IDENTITY, | ||
piece_type varchar , | ||
client_name varchar , | ||
order_number bigint , | ||
raw_mat_cost money NOT NULL , -- raw material cost | ||
raw_mat_arr_date int NOT NULL , -- raw material arrival date | ||
dispatch_date int , -- Query to MES | ||
total_prod_time int -- Query to MES (in seconds) | ||
total_prod_time int , -- Query to MES (in seconds) | ||
|
||
PRIMARY KEY (piece_id), | ||
|
||
CONSTRAINT fk_client_order | ||
FOREIGN KEY(client_name, order_number) REFERENCES client_orders(client_name_id, order_number) | ||
ON DELETE SET NULL -- NOTE: may be able to be altered to ON DELETE CASCADE | ||
); |