From dd830e0097882044f9d29022842b33571f92e921 Mon Sep 17 00:00:00 2001 From: Jan Date: Tue, 8 Apr 2025 12:54:58 +0200 Subject: [PATCH] Rename "sink" references to "destination" in schema Updated column names, table names, indexes, and foreign key references to replace "sink" with "destination" for consistency and clarity. Added new cost-related fields to the "premiss_destination" table to better represent associated expenses. --- src/main/resources/schema.sql | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql index 9172b0f..062956b 100644 --- a/src/main/resources/schema.sql +++ b/src/main/resources/schema.sql @@ -137,7 +137,7 @@ CREATE TABLE IF NOT EXISTS node address VARCHAR(500) NOT NULL, external_mapping_id VARCHAR(32), predecessor_required BOOLEAN NOT NULL DEFAULT FALSE, - is_sink BOOLEAN, + is_destination BOOLEAN, is_source BOOLEAN, is_intermediate BOOLEAN, geo_lat DECIMAL(7, 4) CHECK (geo_lat BETWEEN -90 AND 90), @@ -358,26 +358,29 @@ CREATE TABLE IF NOT EXISTS premiss ); -CREATE TABLE IF NOT EXISTS premiss_sink +CREATE TABLE IF NOT EXISTS premiss_destination ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, premiss_id INT NOT NULL, annual_amount INT UNSIGNED NOT NULL COMMENT 'annual amount in single pieces', - sink_node_id INT NOT NULL, + destination_node_id INT NOT NULL, + repacking_cost DECIMAL(15, 2) DEFAULT NULL, + handling_cost DECIMAL(15, 2) DEFAULT NULL, + disposal_cost DECIMAL(15, 2) DEFAULT NULL, FOREIGN KEY (premiss_id) REFERENCES premiss (id), - FOREIGN KEY (sink_node_id) REFERENCES node (id), - INDEX idx_sink_node_id (sink_node_id), + FOREIGN KEY (destination_node_id) REFERENCES node (id), + INDEX idx_destination_node_id (destination_node_id), INDEX idx_premiss_id (premiss_id) ); CREATE TABLE IF NOT EXISTS premiss_route ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - premiss_sink_id INT NOT NULL, + premiss_destination_id INT NOT NULL, is_fastest BOOLEAN DEFAULT FALSE, is_cheapest BOOLEAN DEFAULT FALSE, is_selected BOOLEAN DEFAULT FALSE, - FOREIGN KEY (premiss_sink_id) REFERENCES premiss_sink (id) + FOREIGN KEY (premiss_destination_id) REFERENCES premiss_destination (id) ); CREATE TABLE IF NOT EXISTS premiss_route_node @@ -387,7 +390,7 @@ CREATE TABLE IF NOT EXISTS premiss_route_node user_node_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, address VARCHAR(500), - is_sink BOOLEAN DEFAULT FALSE, + is_destination BOOLEAN DEFAULT FALSE, is_intermediate BOOLEAN DEFAULT FALSE, is_source BOOLEAN DEFAULT FALSE, geo_lat DECIMAL(7, 4) CHECK (geo_lat BETWEEN -90 AND 90), @@ -546,11 +549,11 @@ CREATE TABLE IF NOT EXISTS calculation_job_risk ); -CREATE TABLE IF NOT EXISTS calculation_job_sink +CREATE TABLE IF NOT EXISTS calculation_job_destination ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, calculation_job_id INT NOT NULL, - premiss_sink_id INT NOT NULL, + premiss_destination_id INT NOT NULL, safety_stock INT UNSIGNED COMMENT 'safety stock in single pieces ?!?!', shipping_frequency INT UNSIGNED COMMENT 'annual shipping frequency', total_cost DECIMAL(15, 2) COMMENT 'aka MEK_B in EUR', @@ -562,7 +565,7 @@ CREATE TABLE IF NOT EXISTS calculation_job_sink calculation_job_transportation_id INT NOT NULL, calculation_job_airfreight_id INT NOT NULL, FOREIGN KEY (calculation_job_id) REFERENCES calculation_job (id), - FOREIGN KEY (premiss_sink_id) REFERENCES premiss_sink (id), + FOREIGN KEY (premiss_destination_id) REFERENCES premiss_destination (id), FOREIGN KEY (calculation_job_custom_id) REFERENCES calculation_job_custom (id), FOREIGN KEY (calculation_job_inventory_id) REFERENCES calculation_job_inventory (id), FOREIGN KEY (calculation_job_handling_id) REFERENCES calculation_job_handling (id), @@ -571,5 +574,5 @@ CREATE TABLE IF NOT EXISTS calculation_job_sink FOREIGN KEY (calculation_job_transportation_id) REFERENCES calculation_job_transportation (id), FOREIGN KEY (calculation_job_airfreight_id) REFERENCES calculation_job_airfreight (id), INDEX idx_calculation_job_id (calculation_job_id), - INDEX idx_premiss_sink_id (premiss_sink_id) + INDEX idx_premiss_destination_id (premiss_destination_id) );