-- Schema for greaterc_db2024, derived from the production phpMyAdmin dump (MariaDB 10.6, 2025-11-03). -- Shared by think.greaterchiangmai.com (site) and think-backend.greaterchiangmai.com (CMS). -- No Laravel migrations exist for these tables; this file is the source of truth for local dev. -- Applied automatically by `dev db start` on an empty database. Idempotent. SET NAMES utf8mb4; SET time_zone = "+00:00"; -- category_id: 1 = Chiang Mai ("no-where-else"), 2 = Where Else. There is no `category` table in prod. CREATE TABLE IF NOT EXISTS `sub_category` ( `id` int(11) NOT NULL AUTO_INCREMENT, `category_id` int(11) DEFAULT NULL, `due_date` datetime DEFAULT NULL, `name` text DEFAULT NULL, `name_en` text DEFAULT NULL, `description_en` longblob DEFAULT NULL, `description` longblob DEFAULT NULL, `active` int(11) DEFAULT 1 COMMENT '0 = inactive, 1 = active', `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, `image_url` text DEFAULT NULL, `image_name` text DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; -- sub_category_ids: comma-separated sub_category.id list, queried with FIND_IN_SET. -- description / description_en: Editor.js JSON stored as binary. CREATE TABLE IF NOT EXISTS `article` ( `id` int(11) NOT NULL AUTO_INCREMENT, `category_id` int(11) DEFAULT NULL, `sub_category_ids` text DEFAULT NULL, `due_date` datetime DEFAULT NULL, `name` text DEFAULT NULL, `name_en` text DEFAULT NULL, `description_en` longblob DEFAULT NULL, `description` longblob DEFAULT NULL, `active` int(11) DEFAULT 1 COMMENT '0 = inactive, 1 = active', `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, `image_url` text DEFAULT NULL, `image_name` text DEFAULT NULL, `count_view` int(11) DEFAULT 0, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; CREATE TABLE IF NOT EXISTS `folder` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `folder_type` int(11) NOT NULL, `created_at` datetime NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; CREATE TABLE IF NOT EXISTS `file_document` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` text DEFAULT NULL, `user_id` int(11) DEFAULT NULL, `folder_id` int(11) DEFAULT NULL, `created_at` datetime DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; CREATE TABLE IF NOT EXISTS `file_image` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` text DEFAULT NULL, `user_id` int(11) DEFAULT NULL, `folder_id` int(11) DEFAULT NULL, `created_at` datetime DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; CREATE TABLE IF NOT EXISTS `file_sound` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` text DEFAULT NULL, `user_id` int(11) DEFAULT NULL, `folder_id` int(11) DEFAULT NULL, `created_at` datetime DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; CREATE TABLE IF NOT EXISTS `file_video` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` text DEFAULT NULL, `user_id` int(11) DEFAULT NULL, `folder_id` int(11) DEFAULT NULL, `created_at` datetime DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; CREATE TABLE IF NOT EXISTS `users` ( `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, `first_name` varchar(255) DEFAULT NULL, `last_name` varchar(255) DEFAULT NULL, `phone` varchar(10) DEFAULT NULL, `email` varchar(255) NOT NULL, `password` varchar(255) NOT NULL, `remember_token` varchar(100) DEFAULT NULL, `role` int(11) DEFAULT NULL COMMENT '0 = Admin, 1 = Editor, 2 = Contributor', `active` int(11) DEFAULT 1 COMMENT '0 = inactive, 1 = active', `image_url` varchar(255) DEFAULT NULL, `image_name` varchar(255) DEFAULT NULL, `forgot_password_token` varchar(255) DEFAULT NULL, `forgot_password_date` datetime DEFAULT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `users_email_unique` (`email`), KEY `id` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; -- Laravel database cache driver (CACHE_DRIVER=database); the only table with a migration record. CREATE TABLE IF NOT EXISTS `cache` ( `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, `key` varchar(255) NOT NULL, `value` text NOT NULL, `expiration` int(10) UNSIGNED DEFAULT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `cache_key_unique` (`key`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; CREATE TABLE IF NOT EXISTS `migrations` ( `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, `migration` varchar(255) NOT NULL, `batch` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; INSERT IGNORE INTO `migrations` (`id`, `migration`, `batch`) VALUES (1, '2024_08_25_154254_create_cache_table', 1);