astrbot_plugin_imagestudio/database/migrations/0017_advanced_wardrobe_items.sql

23 行
916 B
MySQL

CREATE TABLE IF NOT EXISTS advanced_wardrobe_items (
wardrobe_item_id TEXT PRIMARY KEY,
profile_id TEXT NOT NULL,
material_id TEXT NOT NULL,
wardrobe_category TEXT NOT NULL,
tags_json TEXT,
season TEXT,
style TEXT,
is_favorite INTEGER NOT NULL DEFAULT 0,
usage_count INTEGER NOT NULL DEFAULT 0,
last_used_at TIMESTAMP,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY(profile_id) REFERENCES character_profiles(profile_id) ON DELETE CASCADE,
FOREIGN KEY(material_id) REFERENCES advanced_materials(material_id) ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS idx_advanced_wardrobe_profile
ON advanced_wardrobe_items(profile_id, wardrobe_category);
CREATE UNIQUE INDEX IF NOT EXISTS idx_advanced_wardrobe_profile_material
ON advanced_wardrobe_items(profile_id, material_id, wardrobe_category);