sql/patch_2014-03-25.mysql
-- ---------------------------------------------------------------------------------------------------
-- Create pipeline_wide_parameters instead of meta (to avoid schema conflicts)
-- Copy all the data from meta to pipeline_wide_parameters
-- ---------------------------------------------------------------------------------------------------
SET @expected_version = 56;
-- make MySQL stop immediately after it encounters division by zero:
SET SESSION sql_mode='TRADITIONAL';
-- warn that we detected the schema version mismatch:
SELECT CONCAT( 'The patch only applies to schema version ',
@expected_version,
', but the current schema version is ',
meta_value,
', so skipping the rest.') AS ''
FROM hive_meta WHERE meta_key='hive_sql_schema_version' AND meta_value<>@expected_version;
-- cause division by zero only if current version differs from the expected one:
INSERT INTO hive_meta (meta_key, meta_value)
SELECT 'this_should_never_be_inserted', 1 FROM hive_meta WHERE NOT 1/(meta_key<>'hive_sql_schema_version' OR meta_value=@expected_version);
SELECT CONCAT( 'The patch seems to be compatible with schema version ',
@expected_version,
', applying the patch...') AS '';
-- Now undo the change so that we could patch potentially non-TRADITIONAL schema:
SET SESSION sql_mode='';
-- ----------------------------------<actual_patch> -------------------------------------------------
-- initially duplicate 'meta' table with 'pipeline_wide_parameters':
CREATE TABLE pipeline_wide_parameters (
param_name VARCHAR(255) NOT NULL PRIMARY KEY,
param_value TEXT,
KEY value_idx (param_name(255))
) COLLATE=latin1_swedish_ci ENGINE=InnoDB;
-- there may be a collision from 'patch' entries or similar,
-- which are normally not used as pipeline_wide_parameters anyway, so ignore them:
INSERT IGNORE INTO pipeline_wide_parameters(param_name, param_value) SELECT meta_key, meta_value FROM meta;
-- ----------------------------------</actual_patch> -------------------------------------------------
-- increase the schema version by one:
UPDATE hive_meta SET meta_value=meta_value+1 WHERE meta_key='hive_sql_schema_version';