SET @schema_name := DATABASE();

SET @settlement_ratio_column_exists := (
    SELECT COUNT(1)
    FROM information_schema.columns
    WHERE table_schema = @schema_name
      AND table_name = 'content'
      AND column_name = 'settlement_ratio'
);

SET @add_settlement_ratio_column_sql := IF(
    @settlement_ratio_column_exists = 0,
    'ALTER TABLE content ADD COLUMN settlement_ratio INT NULL COMMENT ''콘텐츠별 정산 요율(%)'' AFTER price',
    'SELECT ''content.settlement_ratio already exists'' AS message'
);

PREPARE add_settlement_ratio_column_stmt FROM @add_settlement_ratio_column_sql;
EXECUTE add_settlement_ratio_column_stmt;
DEALLOCATE PREPARE add_settlement_ratio_column_stmt;
