CREATE TABLE IF NOT EXISTS admins (id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, username VARCHAR(80) NOT NULL UNIQUE, password_hash VARCHAR(255) NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS categories (id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, slug VARCHAR(100) NOT NULL UNIQUE, name VARCHAR(160) NOT NULL, icon_name VARCHAR(20) DEFAULT '🎨', description VARCHAR(500) DEFAULT '', sort_order INT DEFAULT 0, is_active TINYINT(1) DEFAULT 1) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS prompts (id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, sl_no INT NOT NULL, category_id BIGINT UNSIGNED NULL, title VARCHAR(255) NOT NULL, image_url TEXT, tags JSON, prompt_text LONGTEXT NOT NULL, negative_prompt TEXT, aspect_ratio VARCHAR(20) DEFAULT '16:9', view_count INT UNSIGNED DEFAULT 0, use_count INT UNSIGNED DEFAULT 0, video_tutorial_url TEXT, sort_order INT DEFAULT 0, is_active TINYINT(1) DEFAULT 1, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, INDEX idx_prompt_category(category_id), INDEX idx_prompt_active(is_active), CONSTRAINT fk_prompt_category FOREIGN KEY(category_id) REFERENCES categories(id) ON DELETE SET NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS templates (id VARCHAR(80) PRIMARY KEY, title VARCHAR(255) NOT NULL, images JSON, tag VARCHAR(100), external_link TEXT, platform VARCHAR(100), view_count INT UNSIGNED DEFAULT 0, sort_order INT DEFAULT 0, is_active TINYINT(1) DEFAULT 1) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS banners (id VARCHAR(80) PRIMARY KEY, title VARCHAR(255) NOT NULL, subtitle TEXT, image_url TEXT, action_text VARCHAR(100), action_url TEXT, sort_order INT DEFAULT 0, is_active TINYINT(1) DEFAULT 1) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS app_config (config_key VARCHAR(100) PRIMARY KEY, config_value TEXT, is_public TINYINT(1) DEFAULT 1, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
INSERT IGNORE INTO categories(slug,name,icon_name,description,sort_order) VALUES ('portrait','Portrait Photography','📸','Hyper-realistic portraits & lighting',1),('cyberpunk','Cyberpunk & Sci-Fi','🌃','Neon rain, futuristic cities & cyborgs',2),('anime','Anime & Manga','⛩️','Anime and manga inspired art',3),('pixar_3d','3D Pixar & Disney Style','🎨','Cute 3D animated character avatars',4),('architecture','Architecture & Interior','🏛️','Architecture and interior prompts',5),('nature','Nature & Wildlife','🌿','Landscapes and wildlife',6),('fantasy','Fantasy & Mythical','✨','Enchanted worlds and mythical art',7),('logos','Logos & Vector Art','✒️','Modern logos and vector art',8),('festivals','Festivals & Cultural','🕉️','Festival and cultural prompts',9),('fashion','Fashion & Streetwear','🕶️','Fashion and streetwear',10),('vintage','Vintage & Retro','📻','Retro visual styles',11),('cinematic','Cinematic & Movie Still','🎬','Cinematic photography',12),('food','Food & Culinary','🍣','Food photography',13),('abstract','Abstract & Minimalist','🖼️','Abstract and minimalist art',14),('oil_painting','Watercolors & Oil Painting','🖌️','Painting styles',15),('automotive','Car & Automotive','🏎️','Automotive visuals',16),('underwater','Underwater & Marine','🌊','Ocean and underwater art',17),('chibi','Cute Animals & Chibi','🐾','Cute characters and animals',18),('dark_fantasy','Dark Fantasy & Gothic','🏰','Gothic and dark fantasy',19),('space','Space & Galaxy','🚀','Space and galaxy prompts',20);
INSERT IGNORE INTO app_config(config_key,config_value,is_public) VALUES ('app_name','Prompt Wala Dost',1),('min_supported_version','1.0.0',1),('maintenance_mode','false',1),('support_email','support@promptwaladost.com',1);
