fix: Add migration SQL files to repository

This commit is contained in:
mwpn
2025-12-17 10:56:14 +07:00
parent 97e1cb1d44
commit f829e251a7
3 changed files with 61 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
-- Migration: Create hourly_summary table
-- Description: Rekap per jam untuk kebutuhan grafik dashboard
-- Date: 2024-12-28
CREATE TABLE IF NOT EXISTS hourly_summary (
summary_date DATE NOT NULL,
summary_hour TINYINT UNSIGNED NOT NULL COMMENT '0-23',
location_code VARCHAR(64) NOT NULL,
gate_code VARCHAR(64) NOT NULL,
category VARCHAR(64) NOT NULL,
total_count INT UNSIGNED NOT NULL DEFAULT 0,
total_amount BIGINT UNSIGNED NOT NULL DEFAULT 0,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (summary_date, summary_hour, location_code, gate_code, category),
INDEX idx_summary_date_location (summary_date, location_code),
INDEX idx_summary_date_hour (summary_date, summary_hour)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;