SET @story_share_table_exists = ( SELECT COUNT(*) FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'story_share' ); SET @story_share_template_exists = ( SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'story_share' AND COLUMN_NAME = 'template_style' ); SET @story_share_template_stmt = IF( @story_share_table_exists = 1 AND @story_share_template_exists = 0, "ALTER TABLE story_share ADD COLUMN template_style varchar(32) DEFAULT 'editorial' COMMENT 'Public template style' AFTER share_quote", 'SELECT 1' ); PREPARE story_share_template_stmt FROM @story_share_template_stmt; EXECUTE story_share_template_stmt; DEALLOCATE PREPARE story_share_template_stmt;