-- Local dev only. Applies the change SQL (company, BO modules) and creates one admin login. -- Admin login: admin / colite-dev-admin (dev password, documented in local/README.md). -- Keep the statements below in step with openspec/changes/*/sql/ (and the archive once archived). -- The release package (add-release-ci-packaging/sql/03-colite.sql) is frozen; this seed equals that -- package plus the later change SQL listed in docs/deployment.md section 3, plus the dev admin login. USE `service-system`; -- add-admin-auth-users-roles/sql/01-company.sql CREATE TABLE `company` ( `id` bigint NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `create_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; INSERT INTO `company` (`id`, `name`) VALUES (1, 'Co-Lite'); ALTER TABLE `user` ADD COLUMN `company_id` bigint NULL; -- add-admin-auth-users-roles/sql/02-bo-modules.sql INSERT INTO `module` (`id`, `name`, `desc`, `area`, `type`, `parent`, `url`, `icon_name`) VALUES (40000000, 'BO_ROOT', 'Back Office', 'BO', 'R', 0, NULL, NULL), (40700000, 'BO_USERS', 'Users', 'BO', 'M', 40000000, '/users', 'UserCog'), (40800000, 'BO_ROLES', 'Roles', 'BO', 'M', 40000000, '/roles', 'ShieldCheck'); -- add-admin-events/sql/02-bo-events-module.sql INSERT INTO `module` (`id`, `name`, `desc`, `area`, `type`, `parent`, `url`, `icon_name`) VALUES (40100000, 'BO_EVENTS', 'Events', 'BO', 'M', 40000000, '/events', 'CalendarDays'); -- add-event-lead-capture/sql/02-lead-modules.sql INSERT INTO `module` (`id`, `name`, `desc`, `area`, `type`, `parent`, `url`, `icon_name`) VALUES (40200000, 'BO_EVENT_LEADS', 'Event leads', 'BO', 'M', 40000000, '/event-leads', 'ClipboardList'), (40300000, 'BO_INTERESTS', 'Interests', 'BO', 'M', 40000000, '/interests', 'Tags'); -- Dev admin: super admin, company 1, password already set (login 'Y', no first-login change). INSERT INTO `user` (`id`, `email`, `enabled`, `name`, `password`, `username`, `groupid`, `branchid`, `login`, `status`, `type`, `create_by`, `create_date`, `done_by`, `company_id`) VALUES (1, 'admin@co-lite.local', b'1', 'Admin', '$2a$10$RakIbSfLlImTHUz1d5ROceRxnQsVb3K3UoKu2FCk7LccN/kBsw88S', 'admin', 5, 1, 'Y', 'Y', 'A', 'seed', NOW(), 'seed', 1); INSERT INTO `users_roles` (`user_id`, `role_id`) VALUES (1, 1); -- add-admin-events/sql/01-event-salesperson.sql USE `service-counter`; CREATE TABLE `event_salesperson` ( `id` bigint NOT NULL AUTO_INCREMENT, `company_id` bigint NOT NULL, `event_uuid` bigint NOT NULL, `user_id` bigint NOT NULL, `create_by` varchar(255) DEFAULT NULL, `create_date_time` datetime DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `uk_event_salesperson_event_user` (`event_uuid`, `user_id`), KEY `idx_event_salesperson_event` (`event_uuid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- add-event-lead-capture/sql/01-lead-tables.sql (still USE `service-counter` from above) CREATE TABLE `lead` ( `id` bigint NOT NULL AUTO_INCREMENT, `uuid` bigint NOT NULL, `company_id` bigint NOT NULL, `name` varchar(100) NOT NULL, `mobile_e164` varchar(20) DEFAULT NULL, `email_normalised` varchar(254) DEFAULT NULL, `company_name` varchar(150) DEFAULT NULL, `job_title` varchar(100) DEFAULT NULL, `notes` text, `created_by` varchar(255) DEFAULT NULL, `created_at` datetime DEFAULT CURRENT_TIMESTAMP, `updated_by` varchar(255) DEFAULT NULL, `updated_at` datetime DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `uk_lead_uuid` (`uuid`), KEY `idx_lead_company_mobile` (`company_id`, `mobile_e164`), KEY `idx_lead_company_email` (`company_id`, `email_normalised`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; CREATE TABLE `event_lead` ( `id` bigint NOT NULL AUTO_INCREMENT, `uuid` bigint NOT NULL, `company_id` bigint NOT NULL, `event_uuid` bigint NOT NULL, `lead_uuid` bigint NOT NULL, `salesperson_user_id` bigint DEFAULT NULL, `lead_type` varchar(8) NOT NULL, `temperature` varchar(4) DEFAULT NULL, `status` varchar(10) NOT NULL DEFAULT 'OPEN', `next_follow_up_date` date DEFAULT NULL, `notes` text, `captured_by` varchar(255) DEFAULT NULL, `captured_at` datetime DEFAULT CURRENT_TIMESTAMP, `updated_by` varchar(255) DEFAULT NULL, `updated_at` datetime DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `uk_event_lead_uuid` (`uuid`), UNIQUE KEY `uk_event_lead_event_lead` (`event_uuid`, `lead_uuid`), KEY `idx_event_lead_company_event` (`company_id`, `event_uuid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; CREATE TABLE `interest` ( `id` bigint NOT NULL AUTO_INCREMENT, `company_id` bigint NOT NULL, `name` varchar(100) NOT NULL, `active` bit(1) NOT NULL DEFAULT b'1', `sort_order` int NOT NULL DEFAULT 0, PRIMARY KEY (`id`), UNIQUE KEY `uk_interest_company_name` (`company_id`, `name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; CREATE TABLE `event_lead_interest` ( `event_lead_id` bigint NOT NULL, `interest_id` bigint NOT NULL, `company_id` bigint NOT NULL, PRIMARY KEY (`event_lead_id`, `interest_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- add-lead-listing-export/sql/01-lead-index.sql (still USE `service-counter` from above) ALTER TABLE `event_lead` ADD KEY `idx_event_lead_company_lead` (`company_id`, `lead_uuid`); -- add-lead-listing-export/sql/02-lead-modules.sql USE `service-system`; INSERT INTO `module` (`id`, `name`, `desc`, `area`, `type`, `parent`, `url`, `icon_name`) VALUES (40400000, 'BO_LEADS', 'Leads', 'BO', 'M', 40000000, '/leads', 'Users'), (40500000, 'BO_LEADS_EDIT', 'Edit leads', 'BO', 'M', 40000000, NULL, NULL), (40600000, 'BO_LEADS_EXPORT', 'Export leads', 'BO', 'M', 40000000, NULL, NULL); -- add-admin-email-listing/sql/01-email-module.sql INSERT INTO `module` (`id`, `name`, `desc`, `area`, `type`, `parent`, `url`, `icon_name`) VALUES (40900000, 'BO_EMAILS', 'Emails', 'BO', 'M', 40000000, '/emails', 'Mail'); -- add-admin-login-security/sql/01-login-audit.sql CREATE TABLE IF NOT EXISTS `login_audit` ( `id` bigint NOT NULL AUTO_INCREMENT, `company_id` bigint NULL COMMENT 'the user''s company when the username matches a user', `username` varchar(191) COLLATE utf8mb4_general_ci NOT NULL COMMENT 'compared like `user`.`username`', `datetime` datetime NOT NULL, `event` varchar(20) NOT NULL COMMENT 'LOGIN_SUCCESS | LOGIN_FAIL | LOGIN_LOCKED | LOGOUT | UNLOCK_RESET | PASSWORD_CHANGED', `ip_address` varchar(64) NULL, `user_agent` varchar(512) NULL, `message` varchar(255) NULL, PRIMARY KEY (`id`), KEY `idx_login_audit_username_dt` (`username`, `datetime`), KEY `idx_login_audit_event_dt` (`event`, `datetime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- add-admin-login-security/sql/02-lockout-settings.sql INSERT INTO `system_property` (`param`, `status`, `type`, `value`) SELECT 'ADMIN_LOGIN_MAX_ATTEMPT', 'Y', 'ADMIN_LOGIN_BLOCK', '5' WHERE NOT EXISTS (SELECT 1 FROM `system_property` WHERE `param` = 'ADMIN_LOGIN_MAX_ATTEMPT' AND `type` = 'ADMIN_LOGIN_BLOCK'); UPDATE `system_property` SET `value` = '15', `status` = 'Y' WHERE `param` = 'ADMIN_LOGIN_BLOCK_PERIOD' AND `type` = 'ADMIN_LOGIN_BLOCK'; -- add-admin-login-security/sql/03-login-security-module.sql INSERT INTO `module` (`id`, `name`, `desc`, `area`, `type`, `parent`, `url`, `icon_name`) VALUES (41000000, 'BO_LOGIN_SECURITY', 'Login security', 'BO', 'M', 40000000, '/login-security', 'Shield'); -- add-admin-audit-log/sql/02-audit-log-module.sql (still USE `service-system` from above) INSERT INTO `module` (`id`, `name`, `desc`, `area`, `type`, `parent`, `url`, `icon_name`) VALUES (41100000, 'BO_AUDIT_LOG', 'Audit log', 'BO', 'M', 40000000, '/audit-log', 'ScrollText'); -- add-admin-audit-log/sql/01-audit-event.sql USE `service-log`; CREATE TABLE IF NOT EXISTS `audit_event` ( `id` bigint NOT NULL AUTO_INCREMENT, `company_id` bigint NULL, `occurred_at` datetime(6) NOT NULL, `actor` varchar(191) NOT NULL, `module` varchar(64) NULL, `action` varchar(128) NOT NULL, `http_method` varchar(16) NULL, `path_template` varchar(255) NULL, `target_id` varchar(128) NULL, `outcome` varchar(16) NOT NULL COMMENT 'SUCCESS | FAILURE', `http_status` int NULL, `client_ip` varchar(64) NULL, `changes` text NULL COMMENT 'JSON: allow-listed before/after, or changed field names', PRIMARY KEY (`id`), KEY `idx_audit_event_occurred_at` (`occurred_at`), KEY `idx_audit_event_actor` (`actor`, `occurred_at`), KEY `idx_audit_event_module_action` (`module`, `action`, `occurred_at`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- add-company-scoping/sql/01-company-code-status.sql USE `service-system`; ALTER TABLE `company` ADD COLUMN `code` varchar(20) NULL AFTER `name`, ADD COLUMN `status` char(1) NOT NULL DEFAULT 'A' COMMENT 'A active, I inactive' AFTER `code`; UPDATE `company` SET `name` = 'INS', `code` = 'INS' WHERE `id` = 1; INSERT INTO `company` (`name`, `code`, `status`) VALUES ('CV', 'CV', 'A'); ALTER TABLE `company` MODIFY COLUMN `code` varchar(20) NOT NULL, ADD UNIQUE KEY `uk_company_code` (`code`); -- add-company-scoping/sql/02-company-columns.sql USE `service-counter`; ALTER TABLE `event` ADD COLUMN `company_id` bigint NULL, ADD KEY `idx_event_company` (`company_id`); UPDATE `event` SET `company_id` = 1 WHERE `company_id` IS NULL; ALTER TABLE `interest` DROP INDEX `uk_interest_company_name`, MODIFY COLUMN `company_id` bigint NULL, ADD UNIQUE KEY `uk_interest_name` (`name`); USE `service-email`; ALTER TABLE `email` ADD COLUMN `company_id` bigint NULL, ADD KEY `idx_email_company` (`company_id`); UPDATE `email` SET `company_id` = 1 WHERE `company_id` IS NULL; -- add-company-scoping/sql/03-admin-login-names.sql USE `service-system`; DROP PROCEDURE IF EXISTS `colite_check_admin_usernames`; DELIMITER // CREATE PROCEDURE `colite_check_admin_usernames`() BEGIN IF EXISTS (SELECT 1 FROM `user` WHERE `type` = 'A' AND `username` LIKE '%@%') THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'An admin username contains @; rename it before running this script'; END IF; END // DELIMITER ; CALL `colite_check_admin_usernames`(); DROP PROCEDURE `colite_check_admin_usernames`; UPDATE `user` u SET u.`company_id` = NULL WHERE u.`type` = 'A' AND EXISTS (SELECT 1 FROM `users_roles` r WHERE r.`user_id` = u.`id` AND r.`role_id` = 1); UPDATE `user` u SET u.`company_id` = 1, u.`username` = CONCAT(u.`username`, '@INS') WHERE u.`type` = 'A' AND NOT EXISTS (SELECT 1 FROM `users_roles` r WHERE r.`user_id` = u.`id` AND r.`role_id` = 1); -- add-lead-dashboard/sql/01-status-change.sql (02 backfill has nothing to do on an empty volume) USE `service-counter`; CREATE TABLE IF NOT EXISTS `event_lead_status_change` ( `id` bigint NOT NULL AUTO_INCREMENT, `company_id` bigint NOT NULL, `event_lead_id` bigint NOT NULL, `from_status` varchar(10) NULL, `to_status` varchar(10) NOT NULL, `changed_at` datetime NOT NULL, `changed_by` varchar(255) NULL, PRIMARY KEY (`id`), KEY `idx_elsc_event_lead` (`event_lead_id`, `changed_at`), KEY `idx_elsc_company_to_changed` (`company_id`, `to_status`, `changed_at`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- Dashboard capture query: captures by company and capture time. ALTER TABLE `event_lead` ADD KEY `idx_event_lead_company_captured` (`company_id`, `captured_at`); -- add-lead-dashboard/sql/03-dashboard-module.sql USE `service-system`; INSERT INTO `module` (`id`, `name`, `desc`, `area`, `type`, `parent`, `url`, `icon_name`) VALUES (40050000, 'BO_DASHBOARD', 'Dashboard', 'BO', 'M', 40000000, '/', 'LayoutDashboard'); -- add-qr-self-registration/sql/01-registration-link.sql USE `service-counter`; CREATE TABLE IF NOT EXISTS `registration_link` ( `id` bigint NOT NULL AUTO_INCREMENT, `company_id` bigint NOT NULL, `event_uuid` bigint NOT NULL, `salesperson_user_id` bigint NULL, `token` varchar(32) NOT NULL, `enabled` bit(1) NOT NULL DEFAULT b'1', `created_by` varchar(255) NULL, `created_at` datetime NULL DEFAULT CURRENT_TIMESTAMP, `updated_by` varchar(255) NULL, `updated_at` datetime NULL, PRIMARY KEY (`id`), UNIQUE KEY `uk_registration_link_token` (`token`), KEY `idx_registration_link_event` (`event_uuid`, `salesperson_user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; ALTER TABLE `event_lead` ADD COLUMN `source` varchar(8) NOT NULL DEFAULT 'STAFF' AFTER `lead_type`, ADD COLUMN `consent_at` datetime NULL AFTER `notes`, ADD COLUMN `consent_notice_id` bigint NULL AFTER `consent_at`; -- add-qr-self-registration/sql/02-company-privacy-notice.sql USE `service-system`; CREATE TABLE IF NOT EXISTS `company_privacy_notice` ( `id` bigint NOT NULL AUTO_INCREMENT, `company_id` bigint NOT NULL, `text_en` text NOT NULL, `text_ms` text NOT NULL, `created_by` varchar(255) NULL, `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `idx_company_privacy_notice_company` (`company_id`, `id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- created_at in Malaysian time, like the rows the services write (the server clock may be UTC). INSERT INTO `company_privacy_notice` (`company_id`, `text_en`, `text_ms`, `created_by`, `created_at`) SELECT c.`id`, REPLACE('{company} collects the details you enter on this form (your name, mobile number, email, company, job title and interests) to contact you about our products, services and events, including by phone, SMS, WhatsApp and email. Your details are used only by {company} and the service providers who run this system for us, and are not sold to anyone. We keep them for as long as you remain a contact of ours or until you ask us to delete them. You may ask to see or correct your details, or withdraw this consent, at any time by contacting {company}. Giving your details is voluntary, but without them we cannot follow up with you.', '{company}', c.`name`), REPLACE('{company} mengumpul butiran yang anda masukkan dalam borang ini (nama, nombor telefon bimbit, e-mel, syarikat, jawatan dan minat anda) untuk menghubungi anda mengenai produk, perkhidmatan dan acara kami, termasuk melalui telefon, SMS, WhatsApp dan e-mel. Butiran anda hanya digunakan oleh {company} dan pembekal perkhidmatan yang mengendalikan sistem ini bagi pihak kami, dan tidak dijual kepada sesiapa. Kami menyimpannya selagi anda kekal sebagai kenalan kami atau sehingga anda meminta kami memadamnya. Anda boleh meminta untuk melihat atau membetulkan butiran anda, atau menarik balik persetujuan ini, pada bila-bila masa dengan menghubungi {company}. Pemberian butiran adalah secara sukarela, tetapi tanpanya kami tidak dapat menghubungi anda.', '{company}', c.`name`), 'default', DATE_ADD(UTC_TIMESTAMP(), INTERVAL 8 HOUR) FROM `company` c WHERE NOT EXISTS (SELECT 1 FROM `company_privacy_notice` n WHERE n.`company_id` = c.`id`); -- add-event-invitations/sql/01-event-guests.sql USE `service-counter`; CREATE TABLE IF NOT EXISTS `event_guest` ( `id` bigint NOT NULL AUTO_INCREMENT, `company_id` bigint NOT NULL, `event_uuid` bigint NOT NULL, `name` varchar(100) NOT NULL, `mobile_e164` varchar(20) NULL, `email` varchar(254) NULL, `company_name` varchar(150) NULL, `salesperson_user_id` bigint NULL, `token` varchar(32) NOT NULL, `invited_at` datetime NULL, `invite_sent_count` int NOT NULL DEFAULT 0, `registered_at` datetime NULL, `event_lead_id` bigint NULL, `created_by` varchar(255) NULL, `created_at` datetime NULL DEFAULT CURRENT_TIMESTAMP, `updated_by` varchar(255) NULL, `updated_at` datetime NULL, PRIMARY KEY (`id`), UNIQUE KEY `uk_event_guest_token` (`token`), UNIQUE KEY `uk_event_guest_mobile` (`event_uuid`, `mobile_e164`), UNIQUE KEY `uk_event_guest_email` (`event_uuid`, `email`), KEY `idx_event_guest_lead` (`event_lead_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; ALTER TABLE `event` ADD COLUMN `capacity` int NULL, ADD COLUMN `invitation_cap` int NULL, ADD COLUMN `checkin_token` varchar(32) NULL, ADD UNIQUE KEY `uk_event_checkin_token` (`checkin_token`); ALTER TABLE `event_lead` ADD COLUMN `attended_at` datetime NULL AFTER `consent_notice_id`; -- add-event-invitations/sql/02-event-guests-module.sql USE `service-system`; INSERT INTO `module` (`id`, `name`, `desc`, `area`, `type`, `parent`, `url`, `icon_name`) VALUES (41150000, 'BO_EVENT_GUESTS', 'Event guests', 'BO', 'M', 40000000, NULL, NULL); -- polish-e2e-followups/sql/01-soft-delete.sql ALTER TABLE `service-counter`.`interest` ADD COLUMN `deleted_at` datetime NULL; ALTER TABLE `service-system`.`role` ADD COLUMN `deleted_at` datetime NULL; -- add-whatsapp-inbox/sql/01-whatsapp-schema.sql CREATE DATABASE IF NOT EXISTS `service-whatsapp` CHARACTER SET utf8mb4; USE `service-whatsapp`; CREATE TABLE `wa_conversation` ( `id` bigint NOT NULL AUTO_INCREMENT, `uuid` varchar(36) NOT NULL, `company_id` bigint NOT NULL, `phone_number_id` varchar(32) NOT NULL, `contact_wa_id` varchar(20) NOT NULL COMMENT 'E.164 digits, no leading +', `contact_name` varchar(255) NULL, `lead_uuid` bigint NULL, `owner_user_id` bigint NULL, `owner_manual` boolean NOT NULL DEFAULT false, `last_inbound_at` datetime NULL, `last_message_at` datetime NULL, `last_message_preview` varchar(80) NULL, `created_at` datetime NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `uk_wa_conversation_uuid` (`uuid`), UNIQUE KEY `uk_wa_conversation_contact` (`company_id`, `contact_wa_id`), KEY `idx_wa_conversation_owner` (`company_id`, `owner_user_id`, `last_message_at`), KEY `idx_wa_conversation_last_message` (`company_id`, `last_message_at`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; CREATE TABLE `wa_message` ( `id` bigint NOT NULL AUTO_INCREMENT, `uuid` varchar(36) NOT NULL, `conversation_id` bigint NOT NULL, `direction` varchar(3) NOT NULL COMMENT 'IN | OUT', `wamid` varchar(128) NULL COMMENT 'NULL while an OUT message is pending, before Meta answers', `type` varchar(16) NOT NULL COMMENT 'text | template | image | document | audio | video | sticker | location | unsupported', `body` text NULL, `template_name` varchar(255) NULL, `media_id` varchar(128) NULL, `media_mime` varchar(128) NULL, `media_filename` varchar(255) NULL, `location_lat` decimal(10,7) NULL, `location_lng` decimal(10,7) NULL, `location_name` varchar(255) NULL, `status` varchar(16) NULL COMMENT 'OUT only: pending | sent | delivered | read | failed', `error_code` varchar(32) NULL, `error_title` varchar(255) NULL, `sent_by_user_id` bigint NULL, `created_at` datetime NOT NULL, `status_at` datetime NULL, PRIMARY KEY (`id`), UNIQUE KEY `uk_wa_message_uuid` (`uuid`), UNIQUE KEY `uk_wa_message_wamid` (`wamid`), KEY `idx_wa_message_conversation` (`conversation_id`, `id`), CONSTRAINT `fk_wa_message_conversation` FOREIGN KEY (`conversation_id`) REFERENCES `wa_conversation` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; CREATE TABLE `wa_read` ( `conversation_id` bigint NOT NULL, `user_id` bigint NOT NULL, `last_read_message_id` bigint NOT NULL, PRIMARY KEY (`conversation_id`, `user_id`), CONSTRAINT `fk_wa_read_conversation` FOREIGN KEY (`conversation_id`) REFERENCES `wa_conversation` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; CREATE TABLE `wa_template` ( `id` bigint NOT NULL AUTO_INCREMENT, `company_id` bigint NOT NULL, `name` varchar(255) NOT NULL, `language` varchar(16) NOT NULL, `category` varchar(32) NULL, `status` varchar(32) NOT NULL, `body_text` text NULL, `param_count` int NOT NULL DEFAULT 0, `synced_at` datetime NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `uk_wa_template` (`company_id`, `name`, `language`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- add-whatsapp-inbox/sql/02-whatsapp-modules.sql USE `service-system`; INSERT INTO `module` (`id`, `name`, `desc`, `area`, `type`, `parent`, `url`, `icon_name`) VALUES (41200000, 'BO_WHATSAPP', 'WhatsApp', 'BO', 'M', 40000000, '/whatsapp', 'MessageCircle'), (41300000, 'BO_WHATSAPP_ADMIN', 'WhatsApp admin', 'BO', 'M', 40000000, NULL, NULL); -- add-zh-cn-messages: language registry, catalog version, Translations and Languages modules SET NAMES utf8mb4; USE `service-system`; CREATE TABLE `supported_locale` ( `id` bigint NOT NULL AUTO_INCREMENT, `code` varchar(35) NOT NULL COMMENT 'Matches the language keys of message.content', `label` varchar(100) NOT NULL, `enabled` tinyint(1) NOT NULL DEFAULT 1, `sort_order` int NOT NULL DEFAULT 0, PRIMARY KEY (`id`), UNIQUE KEY `uk_supported_locale_code` (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; INSERT INTO `supported_locale` (`code`, `label`, `enabled`, `sort_order`) VALUES ('en_US', 'English', 1, 1), ('zh_CN', '简体中文', 1, 2), ('ms_MY', 'Bahasa Melayu', 0, 3), ('zh_TW', '繁體中文', 0, 4), ('in_ID', 'Bahasa Indonesia', 0, 5); CREATE TABLE `catalog_meta` ( `id` bigint NOT NULL, `version` bigint NOT NULL DEFAULT 0, `updated_at` datetime NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; INSERT INTO `catalog_meta` (`id`, `version`, `updated_at`) VALUES (1, 0, NOW()); USE `service-system`; INSERT INTO `module` (`id`, `name`, `desc`, `area`, `type`, `parent`, `url`, `icon_name`) VALUES (41400000, 'BO_MESSAGES', 'Translations', 'BO', 'M', 40000000, '/messages', 'Languages'), (41500000, 'BO_LOCALES', 'Languages', 'BO', 'M', 40000000, '/locales', 'Globe'); -- add-landing-pages: pages, page images, web sign-up origin, company branding, Pages module SET NAMES utf8mb4; USE `service-counter`; CREATE TABLE `cms_page` ( `id` bigint NOT NULL AUTO_INCREMENT, `company_id` bigint NOT NULL, `slug` varchar(80) NOT NULL COMMENT 'Lower-case words joined by hyphens; unique per company', `title` varchar(120) NOT NULL, `meta_description` varchar(160) NULL, `status` varchar(10) NOT NULL DEFAULT 'DRAFT' COMMENT 'DRAFT or PUBLISHED', `blocks` json NOT NULL COMMENT 'Ordered list of typed blocks; replaced as a whole on save', `created_by` varchar(255) NULL, `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_by` varchar(255) NULL, `updated_at` datetime NULL, PRIMARY KEY (`id`), UNIQUE KEY `uk_cms_page_company_slug` (`company_id`, `slug`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; CREATE TABLE `page_image` ( `id` bigint NOT NULL AUTO_INCREMENT, `company_id` bigint NOT NULL, `content_type` varchar(20) NOT NULL COMMENT 'image/png, image/jpeg or image/webp, from the magic bytes', `bytes` mediumblob NOT NULL COMMENT 'At most 2 MB', `created_by` varchar(255) NULL, `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `idx_page_image_company` (`company_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; SET NAMES utf8mb4; USE `service-counter`; ALTER TABLE `event_lead` ADD COLUMN `page_path` varchar(200) NULL COMMENT 'Public address of the landing page, e.g. /p/INS/hotel-technology', ADD COLUMN `utm_source` varchar(100) NULL, ADD COLUMN `utm_medium` varchar(100) NULL, ADD COLUMN `utm_campaign` varchar(100) NULL; SET NAMES utf8mb4; USE `service-system`; ALTER TABLE `company` ADD COLUMN `logo_image_id` bigint NULL, ADD COLUMN `accent_color` varchar(7) NULL COMMENT '#RRGGBB'; USE `service-system`; INSERT INTO `module` (`id`, `name`, `desc`, `area`, `type`, `parent`, `url`, `icon_name`) VALUES (40250000, 'BO_PAGES', 'Pages', 'BO', 'M', 40000000, '/pages', 'PanelsTopLeft'); -- add-custom-html-block: the hide-header page option USE `service-counter`; ALTER TABLE `cms_page` ADD COLUMN `hide_header` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Hide the company header and the page title on the public page' AFTER `status`; -- add-lead-notifications: the staff notification bell USE `service-system`; ALTER TABLE `notification` CONVERT TO CHARACTER SET utf8mb4, ADD COLUMN `recipient_type` char(1) NULL COMMENT 'A = staff user' AFTER `receiver`, ADD COLUMN `company_id` bigint NULL AFTER `recipient_type`, ADD COLUMN `title` varchar(255) NULL COMMENT 'Message code' AFTER `company_id`, ADD COLUMN `type` varchar(45) NULL COMMENT 'LEAD_ASSIGNED, WEB_SIGNUP, WHATSAPP_MESSAGE, FOLLOW_UP_DUE' AFTER `message`, ADD COLUMN `link` varchar(512) NULL COMMENT 'Portal path opened on click' AFTER `type`, ADD COLUMN `collapse_key` varchar(100) NULL COMMENT 'An unread row with the same receiver and key is updated, not duplicated' AFTER `link`, ADD COLUMN `seen` tinyint(1) NOT NULL DEFAULT 0 AFTER `collapse_key`, ADD COLUMN `read_at` datetime NULL AFTER `seen`, ADD INDEX `idx_notification_inbox` (`recipient_type`, `receiver`, `seen`, `create_date_time`), ADD INDEX `idx_notification_collapse` (`receiver`, `collapse_key`, `seen`); -- add-page-drafts-and-templates: a published page's unpublished draft USE `service-counter`; ALTER TABLE `cms_page` ADD COLUMN `draft` json NULL COMMENT 'Unpublished changes of a published page: slug, title, metaDescription, hideHeader, blocks' AFTER `blocks`;