-- Only needed if the first experimental ArtFinder schema was already installed.
-- The user-created search_terms column has been replaced by engine-owned query
-- profiles in ArtSearchCore. This migration does not touch themes or decisions.
USE `artfinder`;

SET @artfinder_has_search_terms = (
  SELECT COUNT(*)
  FROM `information_schema`.`COLUMNS`
  WHERE `TABLE_SCHEMA` = DATABASE()
    AND `TABLE_NAME` = 'artfinder_themes'
    AND `COLUMN_NAME` = 'search_terms'
);
SET @artfinder_migration_sql = IF(
  @artfinder_has_search_terms > 0,
  'ALTER TABLE `artfinder_themes` DROP COLUMN `search_terms`',
  'SELECT 1'
);
PREPARE artfinder_migration_statement FROM @artfinder_migration_sql;
EXECUTE artfinder_migration_statement;
DEALLOCATE PREPARE artfinder_migration_statement;
