List each email once when the recipient join returns it twice. The proposal, design and handover now say Emails exposes every saved email, including member verification codes and form submissions, not only password emails. The design names the single catch-all proxy, the later-SQL table sits after the 04 check, and the seed header says the release package is frozen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
127 lines
5.8 KiB
SQL
127 lines
5.8 KiB
SQL
-- 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');
|