-- Update template file table structure to replace file_path with module_id

-- Add module_id column
ALTER TABLE sys_template_file ADD COLUMN module_id bigint(20) NULL COMMENT '功能模块ID' AFTER file_name;

-- Drop file_path column (optional, can be kept for compatibility if needed)
-- ALTER TABLE sys_template_file DROP COLUMN file_path;

-- Add foreign key constraint (optional)
-- ALTER TABLE sys_template_file ADD CONSTRAINT fk_template_module FOREIGN KEY (module_id) REFERENCES sys_module (module_id);

-- Example data migration (if needed)
-- UPDATE sys_template_file SET module_id = 1 WHERE file_path LIKE '%/module1/%';
-- UPDATE sys_template_file SET module_id = 2 WHERE file_path LIKE '%/module2/%'; 