29 lines
2.7 KiB
SQL
29 lines
2.7 KiB
SQL
-- Tabel penyimpanan hasil generate tiap fungsi report Fisik (report duatahun).
|
|
-- Satu baris = satu fungsi untuk satu So_ResultEntryID + bahasa (M_LangID).
|
|
-- Bahasa: 1 = Indonesia, 2 = English. Keduanya disimpan di tabel yang sama (bukan tabel/kolom terpisah).
|
|
-- UNIQUE key X_UNIK: satu kombinasi (So_ResultEntryID, T_OrderHeaderID, M_LangID, FunctionName) hanya satu baris (insert ulang = update).
|
|
-- Database: onedev (sama dengan so_resultentry, t_orderheader, dll)
|
|
|
|
CREATE TABLE `x_report_duatahun_fisik_result` (
|
|
`X_ReportDuaTahunFisikResultID` int(11) NOT NULL AUTO_INCREMENT,
|
|
`X_ReportDuaTahunFisikResultSo_ResultEntryID` int(11) NOT NULL COMMENT 'FK ke so_resultentry',
|
|
`X_ReportDuaTahunFisikResultT_OrderHeaderID` int(11) NOT NULL COMMENT 'Denormalized, FK ke t_orderheader',
|
|
`X_ReportDuaTahunFisikResultM_LangID` tinyint(4) NOT NULL DEFAULT 1 COMMENT '1=Indonesia, 2=English (satu tabel untuk semua bahasa)',
|
|
`X_ReportDuaTahunFisikResultFunctionName` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Nama key hasil: pribadi, keluhan_saat_ini, visus_left, dll',
|
|
`X_ReportDuaTahunFisikResultResultJSON` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Hasil generate: selalu JSON (array/object/string di-encode jadi JSON)',
|
|
`X_ReportDuaTahunFisikResultStatusVal` char(1) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Status validasi: Y=validated (val1), N=unvalidated (unval1)',
|
|
`X_ReportDuaTahunFisikResultCreatedAt` datetime NOT NULL DEFAULT current_timestamp(),
|
|
`X_ReportDuaTahunFisikResultUpdatedAt` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
|
PRIMARY KEY (`X_ReportDuaTahunFisikResultID`),
|
|
UNIQUE KEY `X_UNIK` (`X_ReportDuaTahunFisikResultSo_ResultEntryID`,`X_ReportDuaTahunFisikResultT_OrderHeaderID`,`X_ReportDuaTahunFisikResultM_LangID`,`X_ReportDuaTahunFisikResultFunctionName`),
|
|
KEY `idx_T_OrderHeaderID` (`X_ReportDuaTahunFisikResultT_OrderHeaderID`),
|
|
KEY `idx_UpdatedAt` (`X_ReportDuaTahunFisikResultUpdatedAt`),
|
|
KEY `X_ReportDuaTahunFisikResultSo_ResultEntryID` (`X_ReportDuaTahunFisikResultSo_ResultEntryID`),
|
|
KEY `X_ReportDuaTahunFisikResultM_LangID` (`X_ReportDuaTahunFisikResultM_LangID`),
|
|
KEY `X_ReportDuaTahunFisikResultFunctionName` (`X_ReportDuaTahunFisikResultFunctionName`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Cache hasil generate per-fungsi report Fisik (report duatahun)';
|
|
|
|
-- Jika tabel sudah ada, tambah kolom status validasi:
|
|
-- ALTER TABLE x_report_duatahun_fisik_result
|
|
-- ADD COLUMN X_ReportDuaTahunFisikResultStatusVal char(1) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Status validasi: Y=validated (val1), N=unvalidated (unval1)' AFTER X_ReportDuaTahunFisikResultResultJSON;
|