SET @current_schema := DATABASE();

SET @add_provider_create_user_sql := IF(
  NOT EXISTS (
    SELECT 1 FROM information_schema.columns
    WHERE table_schema = @current_schema
      AND table_name = 'baishun_provider_config'
      AND column_name = 'create_user'
  ),
  'ALTER TABLE `baishun_provider_config` ADD COLUMN `create_user` bigint DEFAULT NULL AFTER `update_time`',
  'SELECT 1'
);
PREPARE add_provider_create_user_stmt FROM @add_provider_create_user_sql;
EXECUTE add_provider_create_user_stmt;
DEALLOCATE PREPARE add_provider_create_user_stmt;

SET @add_provider_update_user_sql := IF(
  NOT EXISTS (
    SELECT 1 FROM information_schema.columns
    WHERE table_schema = @current_schema
      AND table_name = 'baishun_provider_config'
      AND column_name = 'update_user'
  ),
  'ALTER TABLE `baishun_provider_config` ADD COLUMN `update_user` bigint DEFAULT NULL AFTER `create_user`',
  'SELECT 1'
);
PREPARE add_provider_update_user_stmt FROM @add_provider_update_user_sql;
EXECUTE add_provider_update_user_stmt;
DEALLOCATE PREPARE add_provider_update_user_stmt;
