21 lines
697 B
SQL
21 lines
697 B
SQL
-- Additive migration for the draft/publish feature.
|
|
-- Adds topic.is_published to an ALREADY-DEPLOYED jqc_features database.
|
|
-- Safe to re-run: guarded by an information_schema existence check (MySQL has
|
|
-- no ADD COLUMN IF NOT EXISTS). New deploys don't need this — schema.sql already
|
|
-- includes the column.
|
|
|
|
USE jqc_features;
|
|
|
|
SET @col := (
|
|
SELECT COUNT(*) FROM information_schema.columns
|
|
WHERE table_schema = DATABASE()
|
|
AND table_name = 'topic'
|
|
AND column_name = 'is_published'
|
|
);
|
|
SET @sql := IF(@col = 0,
|
|
'ALTER TABLE topic ADD COLUMN is_published TINYINT(1) NOT NULL DEFAULT 1 AFTER sort_order',
|
|
'SELECT 1');
|
|
PREPARE stmt FROM @sql;
|
|
EXECUTE stmt;
|
|
DEALLOCATE PREPARE stmt;
|