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

CREATE TABLE `site` (
  `id` int(11) NOT NULL,
  `id_random` varchar(22) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `code` varchar(100) DEFAULT NULL,
  `account_id` int(11) DEFAULT NULL,
  `name` varchar(200) NOT NULL,
  `description` text DEFAULT NULL,
  `restrict_access` tinyint(1) NOT NULL DEFAULT 1,
  `access_key` varchar(22) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `access_code_kv_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'for super, manager, administrator, trusted, public, authenticated' CHECK (json_valid(`access_code_kv_json`)),
  `enable` tinyint(1) NOT NULL DEFAULT 0,
  `enable_from` datetime DEFAULT NULL,
  `enable_to` datetime DEFAULT NULL,
  `logo_path` varchar(200) DEFAULT NULL,
  `logo_bg_color` varchar(25) DEFAULT NULL,
  `background_image_path` varchar(200) DEFAULT NULL,
  `background_bg_color` varchar(25) DEFAULT NULL,
  `site_menu_html_path` varchar(200) DEFAULT NULL COMMENT 'path to html file for site menu',
  `site_menu` text DEFAULT NULL COMMENT 'not currently used; but want to use',
  `title` varchar(200) DEFAULT NULL,
  `header_html` text DEFAULT NULL,
  `header_css` text DEFAULT NULL,
  `header_image_path` varchar(200) DEFAULT NULL,
  `header_image_bg_color` varchar(25) DEFAULT NULL,
  `body_html` text DEFAULT NULL,
  `tagline` text DEFAULT NULL COMMENT 'catchphrase or slogan',
  `site_header_h1` text DEFAULT NULL COMMENT 'field not currently used',
  `site_header_h2` text DEFAULT NULL COMMENT 'field not currently used',
  `style_href` varchar(200) DEFAULT NULL,
  `script_src` varchar(200) DEFAULT NULL,
  `google_tracking_id` varchar(14) DEFAULT NULL,
  `cfg_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT '{}' COMMENT 'config in JSON format' CHECK (json_valid(`cfg_json`)),
  `hide` tinyint(1) DEFAULT NULL,
  `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 `site`
--
DELIMITER $$
CREATE TRIGGER `before_insert_site` BEFORE INSERT ON `site` 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;
    END;
END
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER `before_update_site` BEFORE UPDATE ON `site` 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;
    END;
END
$$
DELIMITER ;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `site`
--
ALTER TABLE `site`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `id_random` (`id_random`),
  ADD KEY `account_id` (`account_id`),
  ADD KEY `enable` (`enable`),
  ADD KEY `access_key` (`access_key`),
  ADD KEY `name` (`name`),
  ADD KEY `created_on` (`created_on`),
  ADD KEY `updated_on` (`updated_on`);

--
-- AUTO_INCREMENT for dumped tables
--

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