-- 1.0.344 补齐 mdp_entity.is_public_template 默认值。
-- 1.0.343 的 ADD COLUMN 在 CodeFirst 已建列（无 DEFAULT）时被跳过，导致旧 INSERT 失败。
SET NAMES utf8mb4;

SET @sql := IF(
  (SELECT COUNT(*) FROM information_schema.COLUMNS
    WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='mdp_entity' AND COLUMN_NAME='is_public_template') = 0,
  'ALTER TABLE `mdp_entity` ADD COLUMN `is_public_template` TINYINT NOT NULL DEFAULT 0',
  'ALTER TABLE `mdp_entity` MODIFY COLUMN `is_public_template` TINYINT NOT NULL DEFAULT 0');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
