Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from dvalnn/dev
Browse files Browse the repository at this point in the history
client orders api v1
  • Loading branch information
dvalnn authored Feb 15, 2024
2 parents 4547970 + dd27aba commit 3edee9a
Show file tree
Hide file tree
Showing 15 changed files with 432 additions and 284 deletions.

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.

7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ sqlx = { version = "0.7", features = [
"tls-rustls",
"macros",
] }
dotenv = "0.15.0"
16 changes: 9 additions & 7 deletions migrations/001_t_client_orders.sql
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)
);
37 changes: 19 additions & 18 deletions migrations/002_t_supplier_data.sql
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');
16 changes: 11 additions & 5 deletions migrations/004_t_pieces.sql
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
);
Loading

0 comments on commit 3edee9a

Please sign in to comment.