diff --git a/api/db/migrations/003_schema_snapshot.sql b/api/db/migrations/003_schema_snapshot.sql new file mode 100644 index 0000000..a488aa8 --- /dev/null +++ b/api/db/migrations/003_schema_snapshot.sql @@ -0,0 +1,1315 @@ +-- Full schema snapshot (structure only, no data) exported from a live SeedProject site. +-- Brings the base up to the current sp_ framework + content-model schema. Idempotent: +-- every table uses CREATE TABLE IF NOT EXISTS, so it composes with the existing migrations. +-- Generated 2026-07-11. + +/*M!999999\- enable the sandbox mode */ +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `mde_activity` ( + `activity_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `event_type` varchar(20) NOT NULL, + `target_type` varchar(20) NOT NULL, + `target_id` int(10) unsigned NOT NULL, + `user_id` int(10) unsigned DEFAULT NULL, + `ip` varbinary(16) DEFAULT NULL, + `referrer` varchar(255) DEFAULT NULL, + `platform` varchar(40) DEFAULT NULL, + `created_at` datetime NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`activity_id`), + KEY `idx_mde_activity_target` (`target_type`,`target_id`,`event_type`), + KEY `idx_mde_activity_type_time` (`event_type`,`created_at`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `mde_analytics` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `ip` varchar(45) NOT NULL, + `path` varchar(255) NOT NULL, + `referrer` varchar(500) DEFAULT NULL, + `ref_host` varchar(255) DEFAULT NULL, + `is_entry` tinyint(1) NOT NULL DEFAULT 0, + `user_agent` varchar(255) DEFAULT NULL, + `created_at` datetime NOT NULL, + PRIMARY KEY (`id`), + KEY `idx_created` (`created_at`), + KEY `idx_path` (`path`), + KEY `idx_ip` (`ip`), + KEY `idx_entry` (`is_entry`), + KEY `idx_refhost` (`ref_host`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `mde_authors` ( + `author_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `slug` varchar(191) NOT NULL, + `name` varchar(160) NOT NULL, + `role` varchar(120) DEFAULT NULL, + `bio` text DEFAULT NULL, + `avatar` varchar(255) DEFAULT NULL, + `user_id` int(10) unsigned DEFAULT NULL, + `created_at` datetime NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`author_id`), + UNIQUE KEY `uq_mde_authors_slug` (`slug`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `mde_blog_suggestions` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `title` varchar(255) NOT NULL, + `category` varchar(80) DEFAULT NULL, + `prompt` text DEFAULT NULL, + `draft` mediumtext DEFAULT NULL, + `image` varchar(500) DEFAULT NULL, + `priority` smallint(6) NOT NULL DEFAULT 0, + `status` enum('pending','writing','drafted','published','skip') NOT NULL DEFAULT 'pending', + `content_slug` varchar(191) DEFAULT NULL, + `created_at` datetime NOT NULL, + `updated_at` datetime DEFAULT NULL, + `score` tinyint(3) unsigned DEFAULT NULL, + `revisions` tinyint(3) unsigned NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + KEY `idx_status` (`status`,`priority`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `mde_categories` ( + `category_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `slug` varchar(191) NOT NULL, + `name` varchar(120) NOT NULL, + `context` enum('content','directory','event') NOT NULL DEFAULT 'content', + `parent_id` int(10) unsigned DEFAULT NULL, + `icon` varchar(64) DEFAULT NULL, + `description` varchar(400) DEFAULT NULL, + `sort` smallint(6) NOT NULL DEFAULT 0, + `created_at` datetime NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`category_id`), + UNIQUE KEY `uq_mde_categories_slug` (`slug`), + KEY `idx_mde_categories_context` (`context`), + KEY `idx_mde_categories_parent` (`parent_id`), + CONSTRAINT `fk_mde_categories_parent` FOREIGN KEY (`parent_id`) REFERENCES `mde_categories` (`category_id`) ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `mde_comments` ( + `comment_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `content_id` int(10) unsigned DEFAULT NULL, + `content_slug` varchar(200) NOT NULL DEFAULT '', + `user_id` int(10) unsigned NOT NULL, + `parent_id` int(10) unsigned DEFAULT NULL, + `body` text NOT NULL, + `status` enum('visible','pending','removed') NOT NULL DEFAULT 'visible', + `like_count` int(10) unsigned NOT NULL DEFAULT 0, + `dislike_count` int(10) unsigned NOT NULL DEFAULT 0, + `created_at` datetime NOT NULL DEFAULT current_timestamp(), + `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + PRIMARY KEY (`comment_id`), + KEY `idx_mde_comments_content` (`content_id`,`status`), + KEY `idx_mde_comments_user` (`user_id`), + KEY `idx_mde_comments_parent` (`parent_id`), + KEY `idx_mde_comments_slug` (`content_slug`,`status`), + CONSTRAINT `fk_mde_comments_parent` FOREIGN KEY (`parent_id`) REFERENCES `mde_comments` (`comment_id`) ON DELETE SET NULL, + CONSTRAINT `fk_mde_comments_user` FOREIGN KEY (`user_id`) REFERENCES `sp_users` (`userid`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `mde_content` ( + `content_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `content_type` varchar(20) NOT NULL DEFAULT 'page', + `city` varchar(64) DEFAULT NULL, + `comuna_no` smallint(5) unsigned DEFAULT NULL, + `parent_id` int(10) unsigned DEFAULT NULL, + `category_id` int(10) unsigned DEFAULT NULL, + `author_id` int(10) unsigned DEFAULT NULL, + `slug` varchar(191) NOT NULL, + `title` varchar(255) NOT NULL, + `excerpt` varchar(400) DEFAULT NULL, + `summary` varchar(500) DEFAULT NULL, + `body` mediumtext DEFAULT NULL, + `hero_image` varchar(255) DEFAULT NULL, + `lat` decimal(9,6) DEFAULT NULL, + `lng` decimal(9,6) DEFAULT NULL, + `reading_time` smallint(5) unsigned DEFAULT NULL, + `sort` smallint(6) NOT NULL DEFAULT 0, + `status` enum('draft','published') NOT NULL DEFAULT 'draft', + `published_at` datetime DEFAULT NULL, + `created_at` datetime NOT NULL DEFAULT current_timestamp(), + `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `view_count` int(10) unsigned NOT NULL DEFAULT 0, + `like_count` int(10) unsigned NOT NULL DEFAULT 0, + `dislike_count` int(10) unsigned NOT NULL DEFAULT 0, + `comment_count` int(10) unsigned NOT NULL DEFAULT 0, + `share_count` int(10) unsigned NOT NULL DEFAULT 0, + `meta_title` varchar(255) DEFAULT NULL, + `meta_description` varchar(320) DEFAULT NULL, + `og_image` varchar(255) DEFAULT NULL, + `canonical_url` varchar(500) DEFAULT NULL, + `noindex` tinyint(1) NOT NULL DEFAULT 0, + PRIMARY KEY (`content_id`), + UNIQUE KEY `uq_mde_content_type_slug` (`content_type`,`slug`), + KEY `idx_mde_content_parent` (`parent_id`), + KEY `idx_mde_content_cat` (`category_id`), + KEY `idx_mde_content_author` (`author_id`), + KEY `idx_mde_content_type` (`content_type`), + KEY `idx_mde_content_status_pub` (`status`,`published_at`), + KEY `idx_city` (`city`), + FULLTEXT KEY `ft_mde_content` (`title`,`excerpt`,`body`), + CONSTRAINT `fk_mde_content_author` FOREIGN KEY (`author_id`) REFERENCES `mde_authors` (`author_id`) ON DELETE SET NULL, + CONSTRAINT `fk_mde_content_cat` FOREIGN KEY (`category_id`) REFERENCES `mde_categories` (`category_id`) ON DELETE SET NULL, + CONSTRAINT `fk_mde_content_parent` FOREIGN KEY (`parent_id`) REFERENCES `mde_content` (`content_id`) ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `mde_content_facts` ( + `fact_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `content_id` int(10) unsigned NOT NULL, + `label` varchar(120) NOT NULL, + `value` varchar(255) NOT NULL, + `icon` varchar(64) DEFAULT NULL, + `sort` smallint(6) NOT NULL DEFAULT 0, + PRIMARY KEY (`fact_id`), + KEY `idx_mde_content_facts_content` (`content_id`), + CONSTRAINT `fk_mde_content_facts_content` FOREIGN KEY (`content_id`) REFERENCES `mde_content` (`content_id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `mde_content_media` ( + `content_id` int(10) unsigned NOT NULL, + `media_id` int(10) unsigned NOT NULL, + `role` varchar(40) DEFAULT NULL, + `sort` smallint(6) NOT NULL DEFAULT 0, + PRIMARY KEY (`content_id`,`media_id`), + KEY `idx_mde_content_media_media` (`media_id`), + CONSTRAINT `fk_mde_content_media_content` FOREIGN KEY (`content_id`) REFERENCES `mde_content` (`content_id`) ON DELETE CASCADE, + CONSTRAINT `fk_mde_content_media_media` FOREIGN KEY (`media_id`) REFERENCES `mde_media` (`media_id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `mde_content_migration` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `old_url` varchar(255) NOT NULL, + `new_url` varchar(255) DEFAULT NULL, + `title` varchar(300) DEFAULT NULL, + `section` varchar(64) DEFAULT NULL, + `category` varchar(80) DEFAULT NULL, + `author_id` int(10) unsigned DEFAULT NULL, + `bucket` enum('page','blog') NOT NULL DEFAULT 'page', + `action` varchar(80) DEFAULT NULL, + `status` enum('pending','review','drafting','drafted','draft-failed','published','redirect','retired','skip') NOT NULL DEFAULT 'pending', + `priority` smallint(6) NOT NULL DEFAULT 0, + `old_content` mediumtext DEFAULT NULL, + `word_count` int(10) unsigned NOT NULL DEFAULT 0, + `pub_date` date DEFAULT NULL, + `content_id` int(10) unsigned DEFAULT NULL, + `crawl_error` tinyint(1) NOT NULL DEFAULT 0, + `notes` varchar(500) DEFAULT NULL, + `created_at` datetime NOT NULL, + `updated_at` datetime DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `uq_old_url` (`old_url`), + KEY `idx_status` (`status`,`priority`), + KEY `idx_section` (`section`), + KEY `idx_bucket` (`bucket`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `mde_content_tags` ( + `content_id` int(10) unsigned NOT NULL, + `tag_id` int(10) unsigned NOT NULL, + PRIMARY KEY (`content_id`,`tag_id`), + KEY `idx_mde_content_tags_tag` (`tag_id`), + CONSTRAINT `fk_mde_con_tags_content` FOREIGN KEY (`content_id`) REFERENCES `mde_content` (`content_id`) ON DELETE CASCADE, + CONSTRAINT `fk_mde_con_tags_tag` FOREIGN KEY (`tag_id`) REFERENCES `mde_tags` (`tag_id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `mde_directory` ( + `listing_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `slug` varchar(191) NOT NULL, + `place_id` varchar(64) DEFAULT NULL, + `name` varchar(160) NOT NULL, + `category_id` int(10) unsigned DEFAULT NULL, + `comuna_id` int(10) unsigned DEFAULT NULL, + `barrio_id` int(10) unsigned DEFAULT NULL, + `summary` varchar(400) DEFAULT NULL, + `description` text DEFAULT NULL, + `price_level` tinyint(3) unsigned DEFAULT NULL, + `address` varchar(255) DEFAULT NULL, + `lat` decimal(9,6) DEFAULT NULL, + `lng` decimal(9,6) DEFAULT NULL, + `website` varchar(255) DEFAULT NULL, + `menu_url` varchar(255) DEFAULT NULL, + `phone` varchar(40) DEFAULT NULL, + `whatsapp` varchar(40) DEFAULT NULL, + `email` varchar(160) DEFAULT NULL, + `instagram` varchar(120) DEFAULT NULL, + `hours` text DEFAULT NULL, + `hours_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`hours_json`)), + `hero_image` varchar(255) DEFAULT NULL, + `rating` decimal(2,1) DEFAULT NULL, + `review_count` int(10) unsigned NOT NULL DEFAULT 0, + `featured` tinyint(1) NOT NULL DEFAULT 0, + `status` enum('draft','published') NOT NULL DEFAULT 'draft', + `created_at` datetime NOT NULL DEFAULT current_timestamp(), + `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `place_synced_at` datetime DEFAULT NULL, + `google_primary_type` varchar(80) DEFAULT NULL, + `google_maps_uri` varchar(512) DEFAULT NULL, + `google_summary` varchar(600) DEFAULT NULL, + `attributes_json` longtext DEFAULT NULL, + PRIMARY KEY (`listing_id`), + UNIQUE KEY `uq_mde_directory_slug` (`slug`), + KEY `idx_mde_directory_cat` (`category_id`), + KEY `idx_mde_directory_comuna` (`comuna_id`), + KEY `idx_mde_directory_barrio` (`barrio_id`), + KEY `idx_place` (`place_id`), + FULLTEXT KEY `ft_mde_directory` (`name`,`summary`,`description`), + CONSTRAINT `fk_mde_directory_barrio` FOREIGN KEY (`barrio_id`) REFERENCES `mde_content` (`content_id`) ON DELETE SET NULL, + CONSTRAINT `fk_mde_directory_cat` FOREIGN KEY (`category_id`) REFERENCES `mde_categories` (`category_id`) ON DELETE SET NULL, + CONSTRAINT `fk_mde_directory_comuna` FOREIGN KEY (`comuna_id`) REFERENCES `mde_content` (`content_id`) ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `mde_directory_coverage` ( + `coverage_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `category_slug` varchar(191) NOT NULL, + `area_slug` varchar(191) DEFAULT NULL, + `target` smallint(5) unsigned NOT NULL DEFAULT 0, + `priority` smallint(6) NOT NULL DEFAULT 0, + `notes` varchar(400) DEFAULT NULL, + `created_at` datetime NOT NULL, + `updated_at` datetime DEFAULT NULL, + PRIMARY KEY (`coverage_id`), + KEY `idx_cat` (`category_slug`), + KEY `idx_area` (`area_slug`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `mde_directory_media` ( + `listing_id` int(10) unsigned NOT NULL, + `media_id` int(10) unsigned NOT NULL, + `role` varchar(40) DEFAULT NULL, + `sort` smallint(6) NOT NULL DEFAULT 0, + PRIMARY KEY (`listing_id`,`media_id`), + KEY `idx_mde_directory_media_media` (`media_id`), + CONSTRAINT `fk_mde_dir_media_listing` FOREIGN KEY (`listing_id`) REFERENCES `mde_directory` (`listing_id`) ON DELETE CASCADE, + CONSTRAINT `fk_mde_dir_media_media` FOREIGN KEY (`media_id`) REFERENCES `mde_media` (`media_id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `mde_directory_suggestions` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(160) NOT NULL, + `category_slug` varchar(191) DEFAULT NULL, + `area_slug` varchar(191) DEFAULT NULL, + `draft` mediumtext DEFAULT NULL, + `prompt` text DEFAULT NULL, + `website` varchar(255) DEFAULT NULL, + `order_number` varchar(60) DEFAULT NULL, + `menu_url` varchar(255) DEFAULT NULL, + `photos` longtext DEFAULT NULL, + `priority` smallint(6) NOT NULL DEFAULT 0, + `status` enum('pending','drafting','drafted','published','skip') NOT NULL DEFAULT 'pending', + `listing_id` int(10) unsigned DEFAULT NULL, + `notes` varchar(500) DEFAULT NULL, + `created_at` datetime NOT NULL, + `updated_at` datetime DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `idx_status` (`status`,`priority`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `mde_directory_tags` ( + `listing_id` int(10) unsigned NOT NULL, + `tag_id` int(10) unsigned NOT NULL, + PRIMARY KEY (`listing_id`,`tag_id`), + KEY `idx_mde_directory_tags_tag` (`tag_id`), + CONSTRAINT `fk_mde_dir_tags_listing` FOREIGN KEY (`listing_id`) REFERENCES `mde_directory` (`listing_id`) ON DELETE CASCADE, + CONSTRAINT `fk_mde_dir_tags_tag` FOREIGN KEY (`tag_id`) REFERENCES `mde_tags` (`tag_id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `mde_events` ( + `event_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `slug` varchar(191) NOT NULL, + `title` varchar(200) NOT NULL, + `category_id` int(10) unsigned DEFAULT NULL, + `listing_id` int(10) unsigned DEFAULT NULL, + `comuna_id` int(10) unsigned DEFAULT NULL, + `location_text` varchar(200) DEFAULT NULL, + `starts_at` datetime DEFAULT NULL, + `ends_at` datetime DEFAULT NULL, + `is_free` tinyint(1) NOT NULL DEFAULT 0, + `price` varchar(60) DEFAULT NULL, + `description` text DEFAULT NULL, + `image` varchar(255) DEFAULT NULL, + `url` varchar(255) DEFAULT NULL, + `recurring_rule` varchar(120) DEFAULT NULL, + `status` enum('draft','published') NOT NULL DEFAULT 'draft', + `created_at` datetime NOT NULL DEFAULT current_timestamp(), + `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + PRIMARY KEY (`event_id`), + UNIQUE KEY `uq_mde_events_slug` (`slug`), + KEY `idx_mde_events_starts` (`starts_at`), + KEY `idx_mde_events_listing` (`listing_id`), + KEY `idx_mde_events_comuna` (`comuna_id`), + KEY `fk_mde_events_cat` (`category_id`), + CONSTRAINT `fk_mde_events_cat` FOREIGN KEY (`category_id`) REFERENCES `mde_categories` (`category_id`) ON DELETE SET NULL, + CONSTRAINT `fk_mde_events_comuna` FOREIGN KEY (`comuna_id`) REFERENCES `mde_content` (`content_id`) ON DELETE SET NULL, + CONSTRAINT `fk_mde_events_listing` FOREIGN KEY (`listing_id`) REFERENCES `mde_directory` (`listing_id`) ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `mde_media` ( + `media_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `url` varchar(500) NOT NULL, + `filename` varchar(255) DEFAULT NULL, + `alt` varchar(255) DEFAULT NULL, + `title` varchar(255) DEFAULT NULL, + `caption` varchar(400) DEFAULT NULL, + `mime` varchar(80) DEFAULT NULL, + `width` smallint(5) unsigned DEFAULT NULL, + `height` smallint(5) unsigned DEFAULT NULL, + `filesize` int(10) unsigned DEFAULT NULL, + `source` varchar(40) DEFAULT NULL, + `author_id` int(10) unsigned DEFAULT NULL, + `created_at` datetime NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`media_id`), + UNIQUE KEY `uq_mde_media_url` (`url`), + KEY `idx_mde_media_author` (`author_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `mde_page_suggestions` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `content_type` varchar(20) NOT NULL, + `title` varchar(255) NOT NULL, + `slug` varchar(191) DEFAULT NULL, + `section` varchar(64) DEFAULT NULL, + `brief` text DEFAULT NULL, + `draft` mediumtext DEFAULT NULL, + `source_url` varchar(500) DEFAULT NULL, + `image` varchar(500) DEFAULT NULL, + `priority` smallint(6) NOT NULL DEFAULT 0, + `status` enum('pending','researching','drafted','published','skip') NOT NULL DEFAULT 'pending', + `content_id` int(10) unsigned DEFAULT NULL, + `notes` varchar(500) DEFAULT NULL, + `created_at` datetime NOT NULL, + `updated_at` datetime DEFAULT NULL, + `score` tinyint(3) unsigned DEFAULT NULL, + `revisions` tinyint(3) unsigned NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + KEY `idx_status` (`status`,`priority`), + KEY `idx_type` (`content_type`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `mde_reactions` ( + `reaction_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `user_id` int(10) unsigned NOT NULL, + `target_type` varchar(20) NOT NULL, + `target_id` int(10) unsigned DEFAULT NULL, + `target_slug` varchar(200) DEFAULT NULL, + `value` tinyint(4) NOT NULL, + `created_at` datetime NOT NULL DEFAULT current_timestamp(), + `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + PRIMARY KEY (`reaction_id`), + UNIQUE KEY `uq_mde_reactions_user_target` (`user_id`,`target_type`,`target_id`), + UNIQUE KEY `uq_mde_reactions_user_slug` (`user_id`,`target_type`,`target_slug`), + KEY `idx_mde_reactions_target` (`target_type`,`target_id`), + CONSTRAINT `fk_mde_reactions_user` FOREIGN KEY (`user_id`) REFERENCES `sp_users` (`userid`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `mde_reports` ( + `report_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `user_id` int(10) unsigned NOT NULL, + `target_type` varchar(20) NOT NULL, + `target_id` int(10) unsigned DEFAULT NULL, + `target_slug` varchar(200) DEFAULT NULL, + `reason` varchar(60) NOT NULL, + `details` text DEFAULT NULL, + `status` enum('open','reviewed','dismissed','actioned') NOT NULL DEFAULT 'open', + `created_at` datetime NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`report_id`), + KEY `idx_mde_reports_status` (`status`), + KEY `idx_mde_reports_target` (`target_type`,`target_id`), + KEY `fk_mde_reports_user` (`user_id`), + KEY `idx_mde_reports_slug` (`target_type`,`target_slug`), + CONSTRAINT `fk_mde_reports_user` FOREIGN KEY (`user_id`) REFERENCES `sp_users` (`userid`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `mde_resources` ( + `resource_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `agent_type` varchar(40) NOT NULL, + `name` varchar(160) NOT NULL, + `url` varchar(500) NOT NULL, + `kind` varchar(40) DEFAULT NULL, + `notes` text DEFAULT NULL, + `priority` smallint(6) NOT NULL DEFAULT 0, + `active` tinyint(1) NOT NULL DEFAULT 1, + `last_used_at` datetime DEFAULT NULL, + `created_at` datetime NOT NULL DEFAULT current_timestamp(), + `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + PRIMARY KEY (`resource_id`), + KEY `idx_resources_type` (`agent_type`,`active`,`priority`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `mde_reviews` ( + `review_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `listing_id` int(10) unsigned NOT NULL, + `user_id` int(10) unsigned NOT NULL, + `rating` tinyint(3) unsigned NOT NULL, + `title` varchar(200) DEFAULT NULL, + `body` text DEFAULT NULL, + `status` enum('pending','published','rejected') NOT NULL DEFAULT 'pending', + `created_at` datetime NOT NULL DEFAULT current_timestamp(), + `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + PRIMARY KEY (`review_id`), + UNIQUE KEY `uq_mde_reviews_listing_user` (`listing_id`,`user_id`), + KEY `idx_mde_reviews_user` (`user_id`), + CONSTRAINT `fk_mde_reviews_listing` FOREIGN KEY (`listing_id`) REFERENCES `mde_directory` (`listing_id`) ON DELETE CASCADE, + CONSTRAINT `fk_mde_reviews_user` FOREIGN KEY (`user_id`) REFERENCES `sp_users` (`userid`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `mde_tags` ( + `tag_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `slug` varchar(120) NOT NULL, + `name` varchar(120) NOT NULL, + `kind` varchar(40) DEFAULT NULL, + PRIMARY KEY (`tag_id`), + UNIQUE KEY `uq_mde_tags_slug` (`slug`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_activitylog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `userid` int(11) DEFAULT NULL, + `status` varchar(255) DEFAULT NULL, + `trigval` varchar(255) DEFAULT NULL, + `controller` varchar(64) DEFAULT NULL, + `action` varchar(64) DEFAULT NULL, + `method` varchar(8) DEFAULT NULL, + `useragent` varchar(512) DEFAULT NULL, + `device_type` varchar(16) DEFAULT NULL, + `browser` varchar(64) DEFAULT NULL, + `os` varchar(64) DEFAULT NULL, + `msgval` text DEFAULT NULL, + `requestjson` text DEFAULT NULL, + `device` varchar(255) DEFAULT NULL, + `host` varchar(255) DEFAULT NULL, + `location` varchar(255) DEFAULT NULL, + `ipaddress` varchar(255) DEFAULT '000.000.000', + `public` int(11) DEFAULT NULL, + `createdate` datetime DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `idx_activitylog_userid_trigval_date` (`userid`,`trigval`,`createdate` DESC) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_ai_pricing` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `provider` varchar(20) NOT NULL, + `model` varchar(64) NOT NULL, + `kind` varchar(20) NOT NULL, + `input_per_1m` decimal(10,4) NOT NULL DEFAULT 0.0000, + `output_per_1m` decimal(10,4) NOT NULL DEFAULT 0.0000, + `updated_at` datetime NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `uq_model_kind` (`model`,`kind`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_ai_usage` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `provider` varchar(20) NOT NULL, + `model` varchar(64) NOT NULL, + `kind` varchar(20) NOT NULL, + `context` varchar(40) DEFAULT NULL, + `session_id` varchar(128) DEFAULT NULL, + `ip` varchar(45) DEFAULT NULL, + `prompt_tokens` int(10) unsigned NOT NULL DEFAULT 0, + `completion_tokens` int(10) unsigned NOT NULL DEFAULT 0, + `total_tokens` int(10) unsigned NOT NULL DEFAULT 0, + `cost_usd` decimal(12,6) NOT NULL DEFAULT 0.000000, + `created_at` datetime NOT NULL, + PRIMARY KEY (`id`), + KEY `idx_session` (`session_id`,`id`), + KEY `idx_provider` (`provider`,`kind`,`id`), + KEY `idx_created` (`created_at`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_api_requests` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `apikey` varchar(255) DEFAULT NULL, + `apikeyid` int(11) DEFAULT NULL, + `userid` int(11) DEFAULT NULL, + `requesting_ip` varchar(255) DEFAULT NULL, + `request` varchar(255) DEFAULT NULL, + `service` varchar(255) DEFAULT NULL, + `response` varchar(255) DEFAULT NULL COMMENT 'tracker, or api', + `createdate` datetime DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `idx_userid_createdate` (`userid`,`createdate`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_api_usage` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `userid` int(11) NOT NULL, + `requests` int(11) NOT NULL DEFAULT 0, + `report_date` date NOT NULL, + `report_type` enum('daily','monthly','yearly') NOT NULL, + `created_at` datetime DEFAULT current_timestamp(), + `updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(), + PRIMARY KEY (`id`), + UNIQUE KEY `idx_user_date_type` (`userid`,`report_date`,`report_type`), + KEY `idx_report_date` (`report_date`), + KEY `idx_report_type` (`report_type`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_broker_commissions` ( + `commission_id` int(11) NOT NULL AUTO_INCREMENT, + `userid` int(11) DEFAULT 0, + `orgid` int(11) DEFAULT 0, + `crid` int(11) DEFAULT 0, + `pull_date` datetime DEFAULT '0000-00-00 00:00:00', + `retail_price` decimal(10,2) NOT NULL DEFAULT 0.00, + `commission_type` varchar(255) DEFAULT '0', + `commission_rate` decimal(10,4) NOT NULL DEFAULT 0.0000, + `flat_fee_amount` decimal(10,2) NOT NULL DEFAULT 0.00, + `commission_amount` decimal(10,2) NOT NULL DEFAULT 0.00, + `payout_eligible_date` datetime DEFAULT '0000-00-00 00:00:00', + `payout_id` int(11) DEFAULT 0, + `paid_date` datetime DEFAULT '0000-00-00 00:00:00', + `status` int(11) DEFAULT 0, + `notes` varchar(255) DEFAULT '0', + `createdate` datetime DEFAULT current_timestamp(), + PRIMARY KEY (`commission_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_broker_orgs` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `userid` int(11) DEFAULT 0, + `orgid` int(11) DEFAULT 0, + `commission_override_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_ai_ci DEFAULT '0', + `commission_override_rate` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_ai_ci DEFAULT '0', + `flat_fee_override` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_ai_ci DEFAULT '0', + `start_date` datetime DEFAULT '0000-00-00 00:00:00', + `end_date` datetime DEFAULT '0000-00-00 00:00:00', + `assigned_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_ai_ci DEFAULT '0', + `notes` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_ai_ci DEFAULT '0', + `createdate` datetime DEFAULT current_timestamp(), + `active` int(11) DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_broker_payouts` ( + `payout_id` int(11) NOT NULL AUTO_INCREMENT, + `userid` int(11) DEFAULT NULL, + `payout_period_start` datetime DEFAULT '0000-00-00 00:00:00', + `payout_period_end` datetime DEFAULT '0000-00-00 00:00:00', + `total_commissions` decimal(10,2) NOT NULL DEFAULT 0.00, + `total_amount` decimal(10,2) NOT NULL DEFAULT 0.00, + `payment_method` varchar(255) DEFAULT NULL, + `payment_reference` varchar(255) DEFAULT NULL, + `payment_date` datetime DEFAULT '0000-00-00 00:00:00', + `status` int(11) DEFAULT NULL, + `processed_by` varchar(255) DEFAULT NULL, + `notes` varchar(255) DEFAULT NULL, + `createdate` datetime DEFAULT current_timestamp(), + `updatedate` datetime DEFAULT '0000-00-00 00:00:00' ON UPDATE current_timestamp(), + PRIMARY KEY (`payout_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_cron_tasks` ( + `cronid` int(11) NOT NULL AUTO_INCREMENT, + `keyval` varchar(255) DEFAULT '0', + `varval` varchar(255) DEFAULT '0', + `task` varchar(255) DEFAULT '0', + `response` text DEFAULT NULL, + `completed` datetime DEFAULT '0000-00-00 00:00:00' ON UPDATE current_timestamp(), + `created` datetime DEFAULT current_timestamp(), + `active` int(11) DEFAULT 1, + PRIMARY KEY (`cronid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_uca1400_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_email_templates` ( + `emailtemplateid` int(11) NOT NULL AUTO_INCREMENT, + `type` mediumtext NOT NULL, + `slug` varchar(100) NOT NULL, + `language` varchar(40) DEFAULT NULL, + `name` mediumtext NOT NULL, + `subject` mediumtext NOT NULL, + `message` mediumtext NOT NULL, + `fromname` mediumtext NOT NULL, + `fromemail` varchar(100) DEFAULT NULL, + `plaintext` int(11) NOT NULL DEFAULT 0, + `active` tinyint(4) NOT NULL DEFAULT 0, + `order` int(11) NOT NULL, + PRIMARY KEY (`emailtemplateid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_uca1400_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_error_handler` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `userid` int(11) DEFAULT NULL, + `org_id` int(11) DEFAULT NULL, + `errortype` varchar(50) DEFAULT NULL COMMENT 'E_ERROR, Exception, etc.', + `errorcode` varchar(255) DEFAULT NULL, + `url` varchar(512) DEFAULT NULL, + `file` varchar(512) DEFAULT NULL, + `line` int(11) DEFAULT NULL, + `fullerror` text DEFAULT NULL, + `trace` longtext DEFAULT NULL, + `method` varchar(10) DEFAULT NULL, + `ip_address` varchar(45) DEFAULT NULL, + `user_agent` varchar(512) DEFAULT NULL, + `referer` varchar(512) DEFAULT NULL, + `createdate` datetime DEFAULT current_timestamp(), + `status` varchar(20) DEFAULT 'unresolved' COMMENT 'unresolved, pending, resolved', + PRIMARY KEY (`id`), + KEY `idx_userid` (`userid`), + KEY `idx_org_id` (`org_id`), + KEY `idx_status` (`status`), + KEY `idx_createdate` (`createdate`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_feature_comments` ( + `comment_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `feature_id` int(10) unsigned NOT NULL, + `userid` int(10) unsigned NOT NULL, + `body` text NOT NULL, + `pinned` tinyint(1) NOT NULL DEFAULT 0, + `deleted_at` datetime DEFAULT NULL, + `createdate` datetime DEFAULT current_timestamp(), + PRIMARY KEY (`comment_id`), + KEY `idx_feature_created` (`feature_id`,`createdate`), + KEY `idx_user_created` (`userid`,`createdate`), + CONSTRAINT `fk_fc_feature` FOREIGN KEY (`feature_id`) REFERENCES `sp_features` (`feature_id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_feature_votes` ( + `vote_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `feature_id` int(10) unsigned NOT NULL, + `userid` int(10) unsigned NOT NULL, + `vote` tinyint(4) NOT NULL DEFAULT 1, + `createdate` datetime DEFAULT current_timestamp(), + PRIMARY KEY (`vote_id`), + UNIQUE KEY `uniq_feature_user` (`feature_id`,`userid`), + KEY `idx_userid` (`userid`), + CONSTRAINT `fk_fv_feature` FOREIGN KEY (`feature_id`) REFERENCES `sp_features` (`feature_id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_features` ( + `feature_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `userid` int(10) unsigned NOT NULL, + `title` varchar(255) NOT NULL, + `slug` varchar(255) NOT NULL, + `description` text DEFAULT NULL, + `type` varchar(32) NOT NULL DEFAULT 'feature', + `status` varchar(32) NOT NULL DEFAULT 'open', + `pinned` tinyint(1) NOT NULL DEFAULT 0, + `sysadmin_only` tinyint(1) NOT NULL DEFAULT 0, + `vote_score` int(11) NOT NULL DEFAULT 0, + `comment_count` int(10) unsigned NOT NULL DEFAULT 0, + `merged_into` int(10) unsigned DEFAULT NULL, + `closed_at` datetime DEFAULT NULL, + `last_activity_at` datetime DEFAULT current_timestamp(), + `deleted_at` datetime DEFAULT NULL, + `createdate` datetime DEFAULT current_timestamp(), + `updatedate` datetime DEFAULT current_timestamp(), + PRIMARY KEY (`feature_id`), + KEY `idx_status` (`status`), + KEY `idx_type` (`type`), + KEY `idx_score` (`vote_score`), + KEY `idx_userid` (`userid`), + KEY `idx_deleted` (`deleted_at`), + KEY `idx_activity` (`last_activity_at`), + KEY `idx_sysadmin_only` (`sysadmin_only`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_kathe_conversations` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `session_id` varchar(128) NOT NULL DEFAULT '', + `ip` varchar(45) NOT NULL DEFAULT '', + `role` enum('user','assistant') NOT NULL, + `source` varchar(20) DEFAULT NULL, + `message` mediumtext NOT NULL, + `tokens` int(10) unsigned NOT NULL DEFAULT 0, + `created_at` datetime NOT NULL, + PRIMARY KEY (`id`), + KEY `idx_session` (`session_id`,`id`), + KEY `idx_ip` (`ip`,`id`), + KEY `idx_created` (`created_at`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_master` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(255) DEFAULT '''0''', + `jvalue` text DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_menu_items` ( + `item_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `menu_id` int(10) unsigned NOT NULL, + `parent_id` int(10) unsigned DEFAULT NULL, + `label` varchar(100) NOT NULL, + `icon` varchar(100) DEFAULT NULL, + `type` enum('link','header','divider') DEFAULT 'link', + `url` varchar(255) DEFAULT NULL, + `perm_id` int(10) unsigned DEFAULT NULL, + `role_id` int(10) unsigned DEFAULT NULL, + `match_prefix` tinyint(4) DEFAULT 0, + `sort_order` int(11) DEFAULT 0, + `active` tinyint(4) DEFAULT 1, + PRIMARY KEY (`item_id`), + KEY `menu_id` (`menu_id`), + KEY `parent_id` (`parent_id`), + KEY `perm_id` (`perm_id`), + KEY `fk_menu_item_role` (`role_id`), + CONSTRAINT `fk_menu_item_role` FOREIGN KEY (`role_id`) REFERENCES `sp_roles` (`role_id`) ON DELETE SET NULL, + CONSTRAINT `sp_menu_items_ibfk_1` FOREIGN KEY (`perm_id`) REFERENCES `sp_permissions` (`perm_id`) ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_menus` ( + `menu_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `slug` varchar(50) NOT NULL, + `name` varchar(100) NOT NULL, + `active` tinyint(4) DEFAULT 1, + PRIMARY KEY (`menu_id`), + UNIQUE KEY `slug` (`slug`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_oauth_accounts` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `userid` int(10) unsigned NOT NULL, + `provider` varchar(30) NOT NULL, + `provider_uid` varchar(255) NOT NULL, + `email` varchar(255) DEFAULT NULL, + `created_at` datetime NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + UNIQUE KEY `uq_provider_uid` (`provider`,`provider_uid`), + KEY `idx_oauth_user` (`userid`), + CONSTRAINT `fk_oauth_user` FOREIGN KEY (`userid`) REFERENCES `sp_users` (`userid`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_orgs` ( + `orgid` int(11) NOT NULL AUTO_INCREMENT, + `catid` int(11) DEFAULT 1, + `name` varchar(255) DEFAULT '0', + `address` varchar(255) DEFAULT '0', + `address2` varchar(255) DEFAULT '0', + `city` varchar(255) DEFAULT '0', + `state` varchar(255) DEFAULT '0', + `zip` int(11) DEFAULT 0, + `country` varchar(255) DEFAULT NULL, + `countrycode` varchar(11) DEFAULT NULL, + `phone` varchar(255) DEFAULT '0', + `email` varchar(255) DEFAULT '0', + `billing_email` varchar(255) DEFAULT '0', + `logo` varchar(255) DEFAULT '0', + `website` varchar(255) DEFAULT '0', + `json_social_media` text DEFAULT NULL, + `summary` text DEFAULT NULL, + `description` text DEFAULT NULL, + `updated_date` datetime DEFAULT '0000-00-00 00:00:00', + `taxid` varchar(255) DEFAULT '0', + `defaultorg` int(11) DEFAULT 0, + `creditlimit` varchar(20) DEFAULT '0', + `active` int(11) DEFAULT 1, + `createdate` datetime DEFAULT current_timestamp(), + PRIMARY KEY (`orgid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_orgs_category` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'https://developer.bigcommerce.com/api-reference/9cc3a53863922-get-all-categories', + `name` varchar(255) DEFAULT '0', + `parentid` int(11) DEFAULT 0, + `description` text DEFAULT NULL, + `pagetitle` varchar(255) DEFAULT '0', + `image` varchar(255) DEFAULT '0', + `searchkeywords` text DEFAULT NULL, + `active` int(11) DEFAULT 1, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_orgs_meta` ( + `orgmetaid` int(11) NOT NULL AUTO_INCREMENT, + `orgid` int(11) DEFAULT 0, + `keyval` varchar(255) DEFAULT '0', + `metval` text DEFAULT NULL, + `createdate` datetime DEFAULT current_timestamp(), + `active` int(1) DEFAULT 1, + PRIMARY KEY (`orgmetaid`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_orgs_users_join` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `userid` int(11) DEFAULT 0, + `orgid` int(11) DEFAULT 0, + `orgrole` int(11) DEFAULT 0 COMMENT 'orgrole is temp.. Not sure how i want to handle this.. i don''t want multiple role tables.', + `orgadmin` int(11) DEFAULT 0 COMMENT 'orgadmin are account that have access to modifying the org information.', + `guest` int(11) DEFAULT 0 COMMENT 'if user is a guest, or invited into the org. OrgAdmin can''t delete or modify the account. Another way of thinking about it is ownership. Org Doesn''t have Ownership of the account. Can''t modify it.', + `created_date` datetime DEFAULT current_timestamp(), + `active` int(11) DEFAULT 1, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_permissions` ( + `perm_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `perm_controller` varchar(50) NOT NULL DEFAULT '0', + `perm_action` varchar(50) NOT NULL DEFAULT '0', + `name` varchar(255) DEFAULT '0', + `viewroleid` varchar(255) DEFAULT '0' COMMENT 'role that can see these options', + `menu` int(11) DEFAULT 0, + `menuorder` int(11) DEFAULT 0, + PRIMARY KEY (`perm_id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_plugins` ( + `plugin_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `slug` varchar(64) NOT NULL, + `name` varchar(128) NOT NULL, + `version` varchar(20) NOT NULL DEFAULT '1.0.0', + `description` text DEFAULT NULL, + `author` varchar(128) DEFAULT NULL, + `enabled` tinyint(1) NOT NULL DEFAULT 0, + `installed_at` datetime NOT NULL DEFAULT current_timestamp(), + `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + PRIMARY KEY (`plugin_id`), + UNIQUE KEY `slug` (`slug`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_referral` ( + `refid` int(11) NOT NULL AUTO_INCREMENT, + `refcode` varchar(255) DEFAULT '0', + `refurl` varchar(255) DEFAULT '0', + `ipaddress` varchar(255) DEFAULT '0', + `createdate` datetime DEFAULT current_timestamp(), + PRIMARY KEY (`refid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_uca1400_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_role_perm` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `role_id` int(10) unsigned NOT NULL DEFAULT 0, + `perm_id` int(10) unsigned NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + KEY `role_id` (`role_id`), + KEY `perm_id` (`perm_id`), + CONSTRAINT `sp_role_perm_ibfk_1` FOREIGN KEY (`role_id`) REFERENCES `sp_roles` (`role_id`), + CONSTRAINT `sp_role_perm_ibfk_2` FOREIGN KEY (`perm_id`) REFERENCES `sp_permissions` (`perm_id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_roles` ( + `role_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `role_name` varchar(50) NOT NULL, + `description` varchar(255) DEFAULT NULL, + `view` varchar(100) DEFAULT NULL, + `admin` int(11) DEFAULT NULL, + `onteam` int(11) DEFAULT NULL, + `menu` text DEFAULT NULL, + `defaultrole` int(11) DEFAULT NULL COMMENT 'default roleid is for the system to know which id to default the user to.', + `hidemenu` int(11) DEFAULT NULL, + `createdate` datetime DEFAULT current_timestamp(), + PRIMARY KEY (`role_id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_saas_invoice_activity` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `invid` int(11) NOT NULL, + `orgid` int(11) NOT NULL DEFAULT 0, + `event_type` varchar(64) NOT NULL COMMENT 'created, payment_attempted, payment_succeeded, payment_failed, viewed, etc.', + `label` varchar(255) NOT NULL, + `note` varchar(512) DEFAULT NULL, + `amount` decimal(10,2) DEFAULT NULL, + `createdate` datetime DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `idx_invid` (`invid`), + KEY `idx_orgid` (`orgid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_saas_invoice_items` ( + `itemid` int(11) NOT NULL AUTO_INCREMENT, + `invid` int(11) DEFAULT 0, + `priceid` varchar(255) DEFAULT '0', + `description` varchar(255) DEFAULT '0', + `amount` decimal(10,2) DEFAULT 0.00, + `quantity` int(11) DEFAULT 0, + `void` decimal(10,2) DEFAULT 0.00, + `total` decimal(10,2) DEFAULT 0.00, + `createdate` datetime DEFAULT current_timestamp(), + `active` int(11) DEFAULT 1, + PRIMARY KEY (`itemid`), + KEY `idx_invid` (`invid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_uca1400_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_saas_invoices` ( + `invid` int(11) NOT NULL AUTO_INCREMENT, + `orgid` int(11) NOT NULL DEFAULT 0, + `subid` varchar(255) DEFAULT '0', + `sinvid` varchar(255) DEFAULT '0', + `stripe_pmtid` varchar(255) NOT NULL DEFAULT '' COMMENT 'pm_xxx that was charged', + `description` varchar(255) DEFAULT '0', + `amountdue` decimal(10,2) DEFAULT 0.00, + `paid` decimal(10,2) DEFAULT 0.00, + `paidlast4` varchar(255) DEFAULT '0', + `paidtype` varchar(255) DEFAULT '0', + `balance` decimal(10,2) DEFAULT 0.00, + `discount` decimal(10,2) DEFAULT 0.00, + `hostedinv` varchar(255) DEFAULT '0', + `stripe_pdf_url` varchar(500) NOT NULL DEFAULT '', + `stripe_hosted_url` varchar(500) NOT NULL DEFAULT '', + `effective_at` datetime DEFAULT '0000-00-00 00:00:00', + `due_date` datetime DEFAULT NULL, + `paid_at` datetime DEFAULT NULL, + `canceled_at` datetime DEFAULT '0000-00-00 00:00:00', + `createdate` datetime DEFAULT current_timestamp(), + `status` varchar(255) DEFAULT 'draft' COMMENT 'this will be status like Pending, Paid, Refunded etc..', + `active` int(11) DEFAULT 1, + PRIMARY KEY (`invid`), + KEY `idx_orgid` (`orgid`), + KEY `idx_subid` (`subid`(191)), + KEY `idx_sinvid` (`sinvid`(191)), + KEY `idx_status` (`status`(30)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_saas_plans` ( + `planid` int(11) NOT NULL AUTO_INCREMENT, + `code` varchar(255) DEFAULT '0', + `codemonth` varchar(255) DEFAULT NULL, + `codeyear` varchar(255) DEFAULT NULL, + `name` varchar(255) DEFAULT NULL, + `description` varchar(255) DEFAULT NULL, + `html` mediumtext DEFAULT NULL, + `monthly` decimal(6,2) DEFAULT 0.00, + `yearly` decimal(6,2) DEFAULT 0.00, + `price` decimal(6,2) DEFAULT 0.00, + `limit_minute` int(11) DEFAULT 0, + `credits` int(11) DEFAULT 0, + `active` int(11) DEFAULT 1, + PRIMARY KEY (`planid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_saas_pmtmethods` ( + `pmtid` int(11) NOT NULL AUTO_INCREMENT, + `orgid` int(11) NOT NULL DEFAULT 0, + `stripe_cus_id` varchar(255) NOT NULL DEFAULT '', + `userid` int(11) DEFAULT 0, + `spmid` varchar(255) DEFAULT '0' COMMENT 'Stripe Payment Method ID', + `cardname` varchar(255) DEFAULT '0', + `cardtype` varchar(255) DEFAULT '0', + `last4` varchar(255) DEFAULT '0', + `exp_month` tinyint(2) NOT NULL DEFAULT 0, + `exp_year` smallint(4) NOT NULL DEFAULT 0, + `billingzip` varchar(20) NOT NULL DEFAULT '', + `bank_name` varchar(100) DEFAULT NULL, + `routing_number` varchar(20) DEFAULT NULL, + `account_type` varchar(20) DEFAULT NULL, + `account_holder_type` varchar(20) DEFAULT NULL, + `setup_intent_id` varchar(100) DEFAULT NULL, + `ach_status` varchar(30) DEFAULT NULL, + `is_primary` tinyint(1) NOT NULL DEFAULT 0, + `createdate` datetime DEFAULT current_timestamp(), + `active` int(11) DEFAULT 1, + PRIMARY KEY (`pmtid`), + UNIQUE KEY `idx_spmid` (`spmid`(191)), + KEY `idx_orgid` (`orgid`), + KEY `idx_userid` (`userid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_saas_stripe_response` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `orgid` int(11) NOT NULL DEFAULT 0, + `event_type` varchar(100) NOT NULL DEFAULT '' COMMENT 'e.g. charge.succeeded, invoice.paid', + `userid` int(11) DEFAULT 0, + `name` varchar(255) DEFAULT '0', + `email` varchar(255) DEFAULT '0', + `strid` varchar(255) DEFAULT '0', + `requtype` varchar(255) DEFAULT '0', + `amount` decimal(10,2) NOT NULL DEFAULT 0.00, + `chargeid` varchar(255) DEFAULT '0', + `chargecode` varchar(255) DEFAULT '0', + `chargereason` varchar(255) DEFAULT '0', + `chargemsg` varchar(255) DEFAULT '0', + `cardtype` varchar(255) DEFAULT '0', + `createdate` datetime DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `idx_orgid` (`orgid`), + KEY `idx_event_type` (`event_type`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_saas_subscription` ( + `subid` int(11) NOT NULL AUTO_INCREMENT, + `orgid` int(11) NOT NULL DEFAULT 0, + `userid` int(11) DEFAULT 0, + `planid` int(11) DEFAULT 0, + `stsubid` varchar(255) DEFAULT '0', + `status` varchar(30) NOT NULL DEFAULT 'active' COMMENT 'active | canceled | past_due | trialing | paused', + `trial_ends_at` datetime DEFAULT NULL, + `current_period_start` datetime DEFAULT NULL, + `current_period_end` datetime DEFAULT NULL, + `cancels_at` date DEFAULT '0000-00-00', + `cancelled_at` datetime DEFAULT '0000-00-00 00:00:00', + `reasoncancelled` varchar(255) DEFAULT '0', + `credits_usage` int(11) DEFAULT 0, + `bonus_credits` int(11) DEFAULT 0, + `nextbilling` datetime DEFAULT '0000-00-00 00:00:00', + `createdate` datetime DEFAULT current_timestamp(), + `updatedate` datetime DEFAULT '0000-00-00 00:00:00' ON UPDATE current_timestamp(), + `active` int(11) DEFAULT 0, + PRIMARY KEY (`subid`), + KEY `idx_orgid` (`orgid`), + KEY `idx_userid` (`userid`), + KEY `idx_status` (`status`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_settings` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `keyval` varchar(255) DEFAULT '0', + `group` varchar(100) NOT NULL DEFAULT 'general', + `metval` text DEFAULT NULL, + `status` tinyint(1) NOT NULL DEFAULT 0, + `encrypted` tinyint(1) NOT NULL DEFAULT 0, + `createdate` datetime DEFAULT current_timestamp(), + `updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), + PRIMARY KEY (`id`), + UNIQUE KEY `uq_keyval` (`keyval`), + KEY `idx_group` (`group`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_states` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `code` char(2) NOT NULL, + `name` varchar(64) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `id` (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_user_tokens` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `userid` int(10) unsigned NOT NULL, + `token` varchar(64) NOT NULL, + `type` enum('verify','reset') NOT NULL DEFAULT 'verify', + `expires_at` datetime NOT NULL, + `used_at` datetime DEFAULT NULL, + `created_at` datetime NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `idx_token` (`token`), + KEY `idx_token_user` (`userid`), + CONSTRAINT `fk_token_user` FOREIGN KEY (`userid`) REFERENCES `sp_users` (`userid`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_users` ( + `userid` int(10) unsigned NOT NULL AUTO_INCREMENT, + `username` varchar(50) DEFAULT '0', + `password` varchar(255) DEFAULT NULL, + `email` varchar(255) DEFAULT '0', + `email_verified` tinyint(1) NOT NULL DEFAULT 0, + `avatar` varchar(255) DEFAULT '0', + `autho` varchar(255) DEFAULT '0' COMMENT 'this is for google authorization', + `mobile` varchar(255) DEFAULT '0' COMMENT 'otp authorization or 2step', + `fname` varchar(255) DEFAULT '0', + `lname` varchar(255) DEFAULT '0', + `role_id` int(10) unsigned DEFAULT 2, + `sysadmin` int(11) DEFAULT 0, + `lastlogin` datetime DEFAULT '0000-00-00 00:00:00', + `created_date` datetime DEFAULT current_timestamp(), + `updated_date` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `ipaddress` varchar(255) DEFAULT '000.000.000.000', + `pwcodedate` datetime DEFAULT '0000-00-00 00:00:00', + `pwcode` varchar(255) DEFAULT '0', + `verify` varchar(255) DEFAULT '0', + `active` int(11) DEFAULT 1, + PRIMARY KEY (`userid`), + UNIQUE KEY `username` (`username`), + KEY `role_id` (`role_id`), + KEY `idx_sp_users_email` (`email`), + CONSTRAINT `sp_users_ibfk_1` FOREIGN KEY (`role_id`) REFERENCES `sp_roles` (`role_id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_users_api` ( + `apiid` int(11) NOT NULL AUTO_INCREMENT, + `orgid` int(11) DEFAULT 0, + `userid` int(11) DEFAULT 0, + `projectid` int(11) DEFAULT 0, + `apikey` varchar(100) DEFAULT NULL, + `mcp_key_prefix` varchar(32) DEFAULT NULL, + `mcp_key_hash` char(64) DEFAULT NULL, + `mcp_last_used_at` datetime DEFAULT NULL, + `mcp_public_key` varchar(255) DEFAULT NULL, + `apiname` varchar(255) DEFAULT '0', + `website` varchar(255) DEFAULT '0', + `description` text DEFAULT NULL, + `whitelist` text DEFAULT NULL, + `lockdomain` int(11) DEFAULT 0, + `createdate` datetime DEFAULT current_timestamp(), + `active` int(11) DEFAULT 1, + PRIMARY KEY (`apiid`), + UNIQUE KEY `ApiDups` (`apikey`), + UNIQUE KEY `idx_mcp_key_prefix` (`mcp_key_prefix`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_users_api_copy` ( + `apiid` int(11) NOT NULL AUTO_INCREMENT, + `orgid` int(11) DEFAULT 0, + `userid` int(11) DEFAULT 0, + `projectid` int(11) DEFAULT 0, + `apikey` varchar(100) DEFAULT NULL, + `mcp_key_prefix` varchar(32) DEFAULT NULL, + `mcp_key_hash` char(64) DEFAULT NULL, + `mcp_last_used_at` datetime DEFAULT NULL, + `apiname` varchar(255) DEFAULT '0', + `website` varchar(255) DEFAULT '0', + `description` text DEFAULT NULL, + `whitelist` text DEFAULT NULL, + `lockdomain` int(11) DEFAULT 0, + `createdate` datetime DEFAULT current_timestamp(), + `active` int(11) DEFAULT 1, + PRIMARY KEY (`apiid`), + UNIQUE KEY `ApiDups` (`apikey`), + UNIQUE KEY `idx_mcp_key_prefix` (`mcp_key_prefix`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_users_meta` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `userid` int(11) DEFAULT 0, + `keyval` varchar(255) DEFAULT '0', + `metval` text DEFAULT NULL, + `createdate` datetime DEFAULT current_timestamp(), + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_webhook_events` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `provider` varchar(50) NOT NULL, + `event_type` varchar(100) NOT NULL, + `event_id` varchar(100) NOT NULL, + `payload` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`payload`)), + `processed` tinyint(1) DEFAULT 0, + `created_at` datetime DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `uq_event_id` (`event_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `sp_zipcode` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `zip_code` varchar(15) DEFAULT NULL, + `state_prefix` varchar(10) DEFAULT NULL, + `city` varchar(50) DEFAULT NULL, + `county` varchar(50) DEFAULT NULL, + `lon` decimal(10,2) DEFAULT 0.00, + `lat` decimal(10,2) DEFAULT 0.00, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +/*!40101 SET character_set_client = @saved_cs_client */;