-- phpMyAdmin SQL Dump
-- version 5.2.3
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Jan 06, 2026 at 06:24 PM
-- Server version: 12.1.2-MariaDB-log
-- PHP Version: 8.4.15

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `aether_dev`
--

-- --------------------------------------------------------

--
-- Table structure for table `event_badge`
--

CREATE TABLE `event_badge` (
  `id` int(11) NOT NULL,
  `id_random` varchar(22) NOT NULL,
  `external_id` varchar(100) DEFAULT NULL,
  `external_event_id` varchar(75) DEFAULT NULL COMMENT 'externally generated event ID',
  `external_registration_id` varchar(75) DEFAULT NULL COMMENT 'registration ID generated by external system (was external_reg_id)',
  `external_person_id` varchar(75) DEFAULT NULL COMMENT 'person ID generated by external system (was external_sys_id)',
  `event_id_only` int(11) DEFAULT NULL COMMENT 'This should only be used when the event_person record can not be created.',
  `event_person_id` int(11) DEFAULT NULL,
  `event_badge_template_id` int(11) DEFAULT NULL COMMENT 'if null then use the "default" template for the event',
  `pronouns` varchar(50) DEFAULT NULL COMMENT 'preferred pronouns',
  `pronouns_override` varchar(50) DEFAULT NULL COMMENT 'override for pronouns',
  `informal_name` varchar(50) DEFAULT NULL COMMENT 'nickname',
  `title_names` varchar(100) DEFAULT NULL COMMENT 'prefix',
  `given_name` varchar(50) DEFAULT NULL COMMENT 'first name',
  `middle_name` varchar(50) DEFAULT NULL,
  `family_name` varchar(100) DEFAULT NULL COMMENT 'last name',
  `designations` varchar(100) DEFAULT NULL COMMENT 'designations and suffix',
  `professional_title` varchar(150) DEFAULT NULL COMMENT 'includes degrees and credentials',
  `professional_title_override` varchar(200) DEFAULT NULL COMMENT 'override for professional title',
  `full_name` varchar(200) DEFAULT NULL,
  `full_name_override` varchar(150) DEFAULT NULL COMMENT 'was display_name',
  `affiliations` text DEFAULT NULL,
  `affiliations_override` varchar(200) DEFAULT NULL COMMENT 'override for affiliations',
  `email` varchar(254) DEFAULT NULL,
  `email_override` varchar(254) DEFAULT NULL COMMENT 'override for email',
  `phone` varchar(25) DEFAULT NULL,
  `phone_override` varchar(25) DEFAULT NULL COMMENT 'override for phone',
  `address_line_1` varchar(200) DEFAULT NULL,
  `address_line_2` varchar(200) DEFAULT NULL,
  `address_line_3` varchar(200) DEFAULT NULL,
  `city` varchar(100) DEFAULT NULL,
  `country_subdivision_code` varchar(8) DEFAULT NULL,
  `state_province` varchar(100) DEFAULT NULL,
  `state_province_abb` varchar(10) DEFAULT NULL COMMENT 'state/province abbreviation',
  `postal_code` varchar(25) DEFAULT NULL,
  `country_alpha_2_code` varchar(2) DEFAULT NULL,
  `country` varchar(100) DEFAULT NULL,
  `full_address` varchar(200) DEFAULT NULL,
  `location` varchar(200) DEFAULT NULL,
  `location_override` varchar(200) DEFAULT NULL COMMENT 'override for location',
  `location_short` varchar(100) DEFAULT NULL COMMENT 'auto gen with trigger',
  `location_long` varchar(200) DEFAULT NULL COMMENT 'auto gen with trigger',
  `query_str` varchar(150) DEFAULT NULL,
  `badge_type_code` varchar(50) DEFAULT NULL,
  `badge_type_code_override` varchar(50) DEFAULT NULL,
  `badge_type` varchar(100) DEFAULT NULL,
  `badge_type_override` varchar(100) DEFAULT NULL,
  `member_type_code` varchar(50) DEFAULT NULL,
  `member_type` varchar(100) DEFAULT NULL,
  `member_status` varchar(50) DEFAULT NULL,
  `registration_type_code` varchar(50) DEFAULT NULL,
  `registration_type` varchar(100) DEFAULT NULL,
  `other_1` varchar(100) DEFAULT NULL,
  `other_2` varchar(100) DEFAULT NULL,
  `ticket_1_code` varchar(100) DEFAULT NULL,
  `ticket_2_code` varchar(100) DEFAULT NULL,
  `ticket_3_code` varchar(100) DEFAULT NULL,
  `ticket_4_code` varchar(100) DEFAULT NULL,
  `ticket_5_code` varchar(100) DEFAULT NULL,
  `ticket_6_code` varchar(100) DEFAULT NULL,
  `ticket_7_code` varchar(100) DEFAULT NULL,
  `ticket_8_code` varchar(100) DEFAULT NULL,
  `allow_tracking` tinyint(1) DEFAULT NULL,
  `allow_tracking_field_li` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '[''given_name'', ''family_name'', ''email'']' CHECK (json_valid(`allow_tracking_field_li`)),
  `agree_to_tc` tinyint(1) DEFAULT NULL COMMENT 'agree to terms and conditions',
  `print_first_datetime` datetime DEFAULT NULL,
  `print_last_datetime` datetime DEFAULT NULL,
  `print_count` int(11) DEFAULT NULL,
  `data_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`data_json`)),
  `cfg_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`cfg_json`)),
  `hide` tinyint(1) DEFAULT 0,
  `priority` tinyint(1) DEFAULT NULL,
  `sort` int(11) DEFAULT NULL,
  `group` varchar(100) DEFAULT NULL,
  `enable` tinyint(1) DEFAULT 1,
  `default_qry_str` text DEFAULT NULL COMMENT 'for FULLTEXT indexed searches',
  `notes` text DEFAULT NULL,
  `created_on` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_on` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Triggers `event_badge`
--
DELIMITER $$
CREATE TRIGGER `before_insert_event_badge` BEFORE INSERT ON `event_badge` FOR EACH ROW BEGIN
    BEGIN
        IF (NEW.id_random IS NULL OR NEW.id_random = '' OR LENGTH(NEW.id_random) < 6)
        THEN
            SET NEW.id_random = gen_rand_pattern('4C-2N-2N-2N');
            /* SET NEW.id_random = gen_rand_str(11, 'URL'); */
        END IF;
        
        SET NEW.full_name = name_for_full_name(NEW.informal_name, NEW.title_names, NEW.given_name, NEW.middle_name, NEW.family_name, NEW.designations);
        
        IF (NEW.location IS NULL OR NEW.location = '')
        THEN
            SET NEW.location = make_location_str(NEW.city, NEW.state_province, NEW.country);
        END IF;
        
        IF (NEW.full_address IS NULL OR NEW.full_address = '')
        THEN
            SET NEW.full_address = make_full_address_str(NEW.address_line_1, NEW.address_line_2, NEW.address_line_3, NEW.city, NEW.state_province, NEW.postal_code, NEW.country);
            /*SET NEW.notes = CONCAT(COALESCE(`NEW`.`notes`,''), ';;sys::overide empty full_address');*/
        END IF;
       
        IF (NEW.city IS NOT NULL OR NEW.state_province IS NOT NULL OR NEW.country IS NOT NULL)
        THEN
            SET NEW.location_long = badge_full_address(NEW.city, NEW.state_province, NEW.country);
            /*SET NEW.notes = CONCAT(COALESCE(`NEW`.`notes`,''), ';;sys::overide empty location');*/
        END IF;
        
        IF (NEW.city IS NOT NULL OR NEW.state_province_abb IS NOT NULL OR NEW.country_alpha_2_code IS NOT NULL)
        THEN
            SET NEW.location_short = badge_location_short(NEW.city, NEW.state_province_abb, NEW.country_alpha_2_code);
            /*SET NEW.notes = CONCAT(COALESCE(`NEW`.`notes`,''), ';;sys::overide empty location');*/
        END IF;
        
        SET NEW.default_qry_str = event_badge_default_qry_str(NEW.id_random, NEW.full_name, NEW.full_name_override, NEW.affiliations, NEW.affiliations_override, NEW.email, NEW.email_override, NEW.location, NEW.location_override);
        SET NEW.query_str = badge_query_str(NEW.id_random, NEW.informal_name, NEW.given_name, NEW.middle_name, NEW.family_name, NEW.email);
    END;
END
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER `before_update_event_badge` BEFORE UPDATE ON `event_badge` FOR EACH ROW BEGIN
    BEGIN
        IF (NEW.id_random IS NULL OR NEW.id_random = '' OR LENGTH(NEW.id_random) < 6)
        THEN
            SET NEW.id_random = gen_rand_pattern('4C-2N-2N-2N');
        END IF;
        
        SET NEW.full_name = name_for_full_name(NEW.informal_name, NEW.title_names, NEW.given_name, NEW.middle_name, NEW.family_name, NEW.designations);
        
        IF (NEW.location IS NULL OR NEW.location = '')
        THEN
            SET NEW.location = make_location_str(NEW.city, NEW.state_province, NEW.country);
        END IF;
        
        IF (NEW.full_address IS NULL OR NEW.full_address = '')
        THEN
            SET NEW.full_address = make_full_address_str(NEW.address_line_1, NEW.address_line_2, NEW.address_line_3, NEW.city, NEW.state_province, NEW.postal_code, NEW.country);
            /*SET NEW.notes = CONCAT(COALESCE(`NEW`.`notes`,''), ';;sys::overide empty full_address');*/
        END IF;
       
        IF (NEW.city IS NOT NULL OR NEW.state_province IS NOT NULL OR NEW.country IS NOT NULL)
        THEN
            SET NEW.location_long = badge_full_address(NEW.city, NEW.state_province, NEW.country);
            /*SET NEW.notes = CONCAT(COALESCE(`NEW`.`notes`,''), ';;sys::overide empty location');*/
        END IF;
        
        IF (NEW.city IS NOT NULL OR NEW.state_province_abb IS NOT NULL OR NEW.country_alpha_2_code IS NOT NULL)
        THEN
            SET NEW.location_short = badge_location_short(NEW.city, NEW.state_province_abb, NEW.country_alpha_2_code);
            /*SET NEW.notes = CONCAT(COALESCE(`NEW`.`notes`,''), ';;sys::overide empty location');*/
        END IF;
        
        SET NEW.default_qry_str = event_badge_default_qry_str(NEW.id_random, NEW.full_name, NEW.full_name_override, NEW.affiliations, NEW.affiliations_override, NEW.email, NEW.email_override, NEW.location, NEW.location_override);
        SET NEW.query_str = badge_query_str(NEW.id_random, NEW.informal_name, NEW.given_name, NEW.middle_name, NEW.family_name, NEW.email);
    END;
END
$$
DELIMITER ;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `event_badge`
--
ALTER TABLE `event_badge`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `id_random` (`id_random`),
  ADD KEY `external_id` (`external_id`),
  ADD KEY `event_person_id` (`event_person_id`),
  ADD KEY `given_name` (`given_name`),
  ADD KEY `family_name` (`family_name`),
  ADD KEY `display_name` (`full_name_override`),
  ADD KEY `email` (`email`),
  ADD KEY `badge_type_code` (`badge_type_code`),
  ADD KEY `member_type_code` (`member_type_code`),
  ADD KEY `registration_type_code` (`registration_type_code`),
  ADD KEY `enable` (`enable`),
  ADD KEY `created_on` (`created_on`),
  ADD KEY `updated_on` (`updated_on`),
  ADD KEY `external_event_id` (`external_event_id`),
  ADD KEY `event_badge_template_id` (`event_badge_template_id`);
ALTER TABLE `event_badge` ADD FULLTEXT KEY `query_str` (`query_str`);
ALTER TABLE `event_badge` ADD FULLTEXT KEY `tbl_fulltext_default_qry_str` (`default_qry_str`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `event_badge`
--
ALTER TABLE `event_badge`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
