-- phpMyAdmin SQL Dump
-- version 5.2.3
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Jan 06, 2026 at 06:26 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_session`
--

CREATE TABLE `event_session` (
  `id` int(11) NOT NULL,
  `id_random` varchar(22) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
  `external_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `code` varchar(100) DEFAULT NULL,
  `number` int(11) DEFAULT NULL,
  `for_type` varchar(50) DEFAULT NULL COMMENT 'avoid using',
  `for_id` int(11) DEFAULT NULL COMMENT 'avoid using',
  `event_id` int(11) DEFAULT NULL,
  `event_type_id` int(11) DEFAULT NULL,
  `type_id` int(11) DEFAULT NULL COMMENT 'not used',
  `type_code` varchar(25) DEFAULT NULL COMMENT 'from client',
  `event_location_id` int(11) DEFAULT NULL,
  `event_track_id` int(11) DEFAULT NULL,
  `poc_event_person_id` int(11) DEFAULT NULL COMMENT 'still needed?',
  `poc_person_id` int(11) DEFAULT NULL,
  `poc_agree` tinyint(1) DEFAULT NULL COMMENT 'catchall for agreement or consent',
  `poc_kv_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'advocate, chair, champion, moderator, organizer',
  `passcode` varchar(25) DEFAULT NULL COMMENT 'for basic access',
  `name` varchar(300) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `proposal_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'responses to proposal questions in JSON format' CHECK (json_valid(`proposal_json`)),
  `start_datetime` datetime DEFAULT NULL,
  `end_datetime` datetime DEFAULT NULL,
  `attend_url` text DEFAULT NULL,
  `attend_url_text` text DEFAULT NULL,
  `attend_url_passcode` varchar(15) DEFAULT NULL,
  `attend_phone` varchar(15) DEFAULT NULL,
  `attend_phone_passcode` varchar(15) DEFAULT NULL,
  `attend_text` text DEFAULT NULL,
  `rehearsal_start_datetime` datetime DEFAULT NULL,
  `rehearsal_end_datetime` datetime DEFAULT NULL,
  `rehearsal_url` text DEFAULT NULL,
  `rehearsal_url_passcode` varchar(15) DEFAULT NULL COMMENT 'remove field?',
  `rehearsal_phone` varchar(15) DEFAULT NULL COMMENT 'remove field?',
  `rehearsal_phone_passcode` varchar(15) DEFAULT NULL COMMENT 'remove field?',
  `rehearsal_text` text DEFAULT NULL,
  `image_path` varchar(7) DEFAULT NULL COMMENT 'remove field?',
  `download_start_datetime` datetime DEFAULT NULL,
  `download_end_datetime` datetime DEFAULT NULL,
  `internal_use` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'hide from non-support people',
  `record_audio` tinyint(1) DEFAULT 0 COMMENT 'record presentations',
  `record_video` tinyint(1) DEFAULT 0 COMMENT 'record presentations',
  `internal_notes` text DEFAULT NULL COMMENT 'general notes',
  `internal_notes_access` text DEFAULT NULL COMMENT 'accessibility and accommodations',
  `internal_notes_av` text DEFAULT NULL COMMENT 'audio video',
  `internal_notes_fb` text DEFAULT NULL COMMENT 'food and beverage',
  `internal_notes_it` text DEFAULT NULL COMMENT 'IT and networking',
  `internal_notes_staff` text DEFAULT NULL COMMENT 'staffing and labor',
  `ux_mode` varchar(50) DEFAULT NULL COMMENT 'colloquium, lecture, panel, poster, symposium, workshop; replaces type_code',
  `enable` tinyint(1) NOT NULL DEFAULT 1,
  `enable_after_datetime` datetime DEFAULT NULL,
  `enable_before_datetime` datetime DEFAULT NULL,
  `enable_event_file_approval_option` tinyint(1) DEFAULT NULL,
  `hide` tinyint(1) DEFAULT 0,
  `public` tinyint(1) DEFAULT NULL,
  `public_hide` tinyint(1) DEFAULT NULL,
  `hide_event_launcher` tinyint(1) DEFAULT NULL,
  `status` int(11) DEFAULT NULL,
  `review` tinyint(1) DEFAULT NULL COMMENT 'ready for or needs review',
  `approve` tinyint(1) DEFAULT NULL COMMENT 'approved',
  `ready` tinyint(1) DEFAULT NULL,
  `ready_on` datetime DEFAULT NULL,
  `archive` tinyint(1) DEFAULT NULL,
  `archive_on` datetime DEFAULT NULL,
  `alert` tinyint(1) DEFAULT NULL,
  `alert_msg` text DEFAULT NULL COMMENT 'a short message from user',
  `priority` tinyint(1) DEFAULT 0,
  `sort` int(11) DEFAULT 0,
  `group` varchar(100) DEFAULT NULL,
  `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_session`
--
DELIMITER $$
CREATE TRIGGER `after_update_event_session` AFTER UPDATE ON `event_session` FOR EACH ROW BEGIN
    IF (NEW.event_location_id) THEN       
        UPDATE `event_file`
        SET `event_file`.event_location_id = NEW.event_location_id
        WHERE `event_file`.event_session_id = OLD.id OR (`event_file`.for_type = 'event_session' AND `event_file`.for_id = OLD.id);
    END IF;
END
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER `before_insert_event_session` BEFORE INSERT ON `event_session` 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('3C-2N-2N-2N'); */
            SET NEW.id_random = gen_rand_pattern('4C-2N-2N-2N');
            /* SET NEW.id_random = gen_rand_str(11, 'URL'); */
        END IF;
		
		SET NEW.default_qry_str = event_session_default_qry_str(NEW.id_random, NEW.name, NEW.description, NEW.code, NEW.type_code, NEW.start_datetime);
    END;
END
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER `before_update_event_session` BEFORE UPDATE ON `event_session` 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('3C-2N-2N-2N'); */
            SET NEW.id_random = gen_rand_pattern('4C-2N-2N-2N');
            /* SET NEW.id_random = gen_rand_str(11, 'URL'); */
        END IF;
		
		SET NEW.default_qry_str = event_session_default_qry_str(NEW.id_random, NEW.name, NEW.description, NEW.code, NEW.type_code, NEW.start_datetime);
    END;
END
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER `event_session_after_delete` AFTER DELETE ON `event_session` FOR EACH ROW BEGIN
    DELETE FROM event_file WHERE event_file.for_type = 'event_session' AND event_file.for_id = OLD.id;
    
    DELETE FROM event_presentation WHERE event_presentation.event_session_id = OLD.id;
END
$$
DELIMITER ;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `event_session`
--
ALTER TABLE `event_session`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `id_random` (`id_random`),
  ADD KEY `event_id` (`event_id`),
  ADD KEY `start_datetime` (`start_datetime`),
  ADD KEY `event_location_id` (`event_location_id`),
  ADD KEY `poc_event_person_id` (`poc_event_person_id`),
  ADD KEY `created_on` (`created_on`),
  ADD KEY `updated_on` (`updated_on`),
  ADD KEY `sort` (`sort`),
  ADD KEY `enable` (`enable`),
  ADD KEY `hide` (`hide`),
  ADD KEY `priority` (`priority`),
  ADD KEY `name` (`name`),
  ADD KEY `external_id` (`external_id`),
  ADD KEY `code` (`code`),
  ADD KEY `event_track_id` (`event_track_id`),
  ADD KEY `hide_event_launcher` (`hide_event_launcher`),
  ADD KEY `type_code` (`type_code`),
  ADD KEY `poc_person_id` (`poc_person_id`),
  ADD KEY `poc_agree` (`poc_agree`);
ALTER TABLE `event_session` ADD FULLTEXT KEY `tbl_fulltext_default_qry_str` (`default_qry_str`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `event_session`
--
ALTER TABLE `event_session`
  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 */;
