-- +goose Up SET @schema_name := DATABASE(); SELECT COUNT(*) INTO @has_notes FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = @schema_name AND TABLE_NAME = 'reserve_acs' AND COLUMN_NAME = 'notes'; SET @add_notes_sql := IF( @has_notes = 0, 'ALTER TABLE reserve_acs ADD COLUMN notes TEXT NULL AFTER base_id', 'SELECT 1' ); PREPARE stmt_add_notes FROM @add_notes_sql; EXECUTE stmt_add_notes; DEALLOCATE PREPARE stmt_add_notes; -- +goose Down SET @schema_name := DATABASE(); SELECT COUNT(*) INTO @has_notes FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = @schema_name AND TABLE_NAME = 'reserve_acs' AND COLUMN_NAME = 'notes'; SET @drop_notes_sql := IF( @has_notes = 1, 'ALTER TABLE reserve_acs DROP COLUMN notes', 'SELECT 1' ); PREPARE stmt_drop_notes FROM @drop_notes_sql; EXECUTE stmt_drop_notes; DEALLOCATE PREPARE stmt_drop_notes;