创优教育2026年招生简章
SET @exist := (SELECT COUNT(*) FROM information_schema.columns WHERE table_name = 'news' AND column_name = 'is_published');
SET @sql := IF(@exist = 0, 'ALTER TABLE news ADD COLUMN is_published TINYINT(1) DEFAULT 1', 'SELECT "Column is_published already exists"');
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
-- 更新现有数据,设置is_published为1
UPDATE news SET is_published = 1 WHERE is_published IS NULL;