Add calculate history tracking

This commit is contained in:
2025-02-02 20:41:23 -05:00
parent e62c6ac8ee
commit b926aba9ff
2 changed files with 201 additions and 50 deletions

View File

@@ -171,6 +171,32 @@ ORDER BY
c.name,
st.vendor;
-- Update calculate_history table to track all record types
ALTER TABLE calculate_history
ADD COLUMN total_orders INT DEFAULT 0 AFTER total_products,
ADD COLUMN total_purchase_orders INT DEFAULT 0 AFTER total_orders,
CHANGE COLUMN products_processed processed_products INT DEFAULT 0,
ADD COLUMN processed_orders INT DEFAULT 0 AFTER processed_products,
ADD COLUMN processed_purchase_orders INT DEFAULT 0 AFTER processed_orders;
CREATE TABLE IF NOT EXISTS calculate_history (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
start_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
end_time TIMESTAMP NULL,
duration_seconds INT,
duration_minutes DECIMAL(10,2) GENERATED ALWAYS AS (duration_seconds / 60.0) STORED,
total_products INT DEFAULT 0,
total_orders INT DEFAULT 0,
total_purchase_orders INT DEFAULT 0,
processed_products INT DEFAULT 0,
processed_orders INT DEFAULT 0,
processed_purchase_orders INT DEFAULT 0,
status ENUM('running', 'completed', 'failed', 'cancelled') DEFAULT 'running',
error_message TEXT,
additional_info JSON,
INDEX idx_status_time (status, start_time)
);
CREATE TABLE IF NOT EXISTS sync_status (
table_name VARCHAR(50) PRIMARY KEY,
last_sync_timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,