sql/patch_2014-03-25.sqlite
-- ---------------------------------------------------------------------------------------------------
-- Create pipeline_wide_parameters instead of meta (to avoid schema conflicts)
-- Copy all the data from meta to pipeline_wide_parameters
-- ---------------------------------------------------------------------------------------------------
CREATE TEMPORARY VIEW exp_ver AS SELECT "56" AS expected_version;
.bail ON
SELECT ('The patch only applies to schema version '
|| expected_version
|| ', but the current schema version is '
|| meta_value
|| ', skipping the rest.') AS ''
FROM hive_meta JOIN exp_ver WHERE meta_key='hive_sql_schema_version' AND meta_value<>expected_version;
INSERT INTO hive_meta (meta_key, meta_value)
SELECT hm.* FROM hive_meta AS hm JOIN exp_ver WHERE meta_key='hive_sql_schema_version' AND meta_value<>expected_version;
SELECT ('The patch seems to be compatible with schema version '
|| expected_version
|| ', applying the patch...') AS '' FROM exp_ver;
-- ----------------------------------<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
);
CREATE INDEX pipeline_wide_parameters_value_idx ON pipeline_wide_parameters (param_value);
INSERT 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';