From 23c2085f1c5f29f436edb3a0d89f8342020377fa Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 11 Feb 2025 14:12:12 -0500 Subject: [PATCH] Remove duplicate table creates --- inventory-server/db/metrics-schema.sql | 39 +++++++------------------- inventory-server/db/schema.sql | 12 -------- mountremote.command | 4 +-- 3 files changed, 12 insertions(+), 43 deletions(-) diff --git a/inventory-server/db/metrics-schema.sql b/inventory-server/db/metrics-schema.sql index ffa9984..50bd903 100644 --- a/inventory-server/db/metrics-schema.sql +++ b/inventory-server/db/metrics-schema.sql @@ -102,19 +102,17 @@ CREATE TABLE IF NOT EXISTS product_time_aggregates ( INDEX idx_date (year, month) ); --- Create vendor details table -CREATE TABLE IF NOT EXISTS vendor_details ( - vendor VARCHAR(100) NOT NULL, +-- Create vendor_details table +CREATE TABLE vendor_details ( + vendor VARCHAR(100) PRIMARY KEY, contact_name VARCHAR(100), - email VARCHAR(100), - phone VARCHAR(20), + email VARCHAR(255), + phone VARCHAR(50), status VARCHAR(20) DEFAULT 'active', - notes TEXT, - created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (vendor), - INDEX idx_vendor_status (status) -); + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + INDEX idx_status (status) +) ENGINE=InnoDB; -- New table for vendor metrics CREATE TABLE IF NOT EXISTS vendor_metrics ( @@ -410,21 +408,4 @@ LEFT JOIN category_metrics cm ON c.cat_id = cm.category_id; -- Re-enable foreign key checks -SET FOREIGN_KEY_CHECKS = 1; - --- Create table for sales seasonality factors -CREATE TABLE IF NOT EXISTS sales_seasonality ( - month INT NOT NULL, - seasonality_factor DECIMAL(5,3) DEFAULT 0, - last_updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (month), - CHECK (month BETWEEN 1 AND 12), - CHECK (seasonality_factor BETWEEN -1.0 AND 1.0) -); - --- Insert default seasonality factors (neutral) -INSERT INTO sales_seasonality (month, seasonality_factor) -VALUES - (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), - (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0) -ON DUPLICATE KEY UPDATE last_updated = CURRENT_TIMESTAMP; \ No newline at end of file +SET FOREIGN_KEY_CHECKS = 1; \ No newline at end of file diff --git a/inventory-server/db/schema.sql b/inventory-server/db/schema.sql index ea80668..ffef4e8 100644 --- a/inventory-server/db/schema.sql +++ b/inventory-server/db/schema.sql @@ -79,18 +79,6 @@ CREATE TABLE categories ( INDEX idx_name_type (name, type) ) ENGINE=InnoDB; --- Create vendor_details table -CREATE TABLE vendor_details ( - vendor VARCHAR(100) PRIMARY KEY, - contact_name VARCHAR(100), - email VARCHAR(255), - phone VARCHAR(50), - status VARCHAR(20) DEFAULT 'active', - created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - INDEX idx_status (status) -) ENGINE=InnoDB; - -- Create product_categories junction table CREATE TABLE product_categories ( cat_id BIGINT NOT NULL, diff --git a/mountremote.command b/mountremote.command index 4e6a61e..65e1bde 100755 --- a/mountremote.command +++ b/mountremote.command @@ -1,7 +1,7 @@ #!/bin/zsh #Clear previous mount in case it’s still there -umount ~/Dev/inventory/inventory-server +umount /Users/matt/Library/Mobile Documents/com~apple~CloudDocs/Dev/inventory/inventory-server #Mount -sshfs matt@dashboard.kent.pw:/var/www/html/inventory -p 22122 ~/Dev/inventory/inventory-server/ \ No newline at end of file +sshfs matt@dashboard.kent.pw:/var/www/html/inventory -p 22122 /Users/matt/Library/Mobile Documents/com~apple~CloudDocs/Dev/inventory/inventory-server/ \ No newline at end of file