Commit f54b548d authored by Matthieu Muffato's avatar Matthieu Muffato
Browse files

analysis_base.module should be NOT NULL

parent 1c3e10a3
-- ---------------------------------------------------------------------------------------------------
SET @expected_version = 64;
-- 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> -------------------------------------------------
-- Set the field to NOT NULL
ALTER TABLE analysis_base MODIFY COLUMN module VARCHAR(255) NOT NULL;
-- ----------------------------------</actual_patch> -------------------------------------------------
-- increase the schema version by one:
UPDATE hive_meta SET meta_value=meta_value+1 WHERE meta_key='hive_sql_schema_version';
-- ---------------------------------------------------------------------------------------------------
\set expected_version 64
\set ON_ERROR_STOP on
-- warn that we detected the schema version mismatch:
SELECT ('The patch only applies to schema version '
|| CAST(:expected_version AS VARCHAR)
|| ', but the current schema version is '
|| meta_value
|| ', so skipping the rest.') as incompatible_msg
FROM hive_meta WHERE meta_key='hive_sql_schema_version' AND meta_value!=CAST(:expected_version AS VARCHAR);
-- 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 1 != 1/CAST( (meta_key!='hive_sql_schema_version' OR meta_value=CAST(:expected_version AS VARCHAR)) AS INTEGER );
SELECT ('The patch seems to be compatible with schema version '
|| CAST(:expected_version AS VARCHAR)
|| ', applying the patch...') AS compatible_msg;
-- ----------------------------------<actual_patch> -------------------------------------------------
-- Set the field to NOT NULL
ALTER TABLE analysis_base ALTER COLUMN module SET DATA TYPE VARCHAR(255) NOT NULL;
-- ----------------------------------</actual_patch> -------------------------------------------------
-- increase the schema version by one:
UPDATE hive_meta SET meta_value= (CAST(meta_value AS INTEGER) + 1) WHERE meta_key='hive_sql_schema_version';
......@@ -101,7 +101,7 @@ CREATE TABLE pipeline_wide_parameters (
CREATE TABLE analysis_base (
analysis_id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
logic_name VARCHAR(255) NOT NULL,
module VARCHAR(255),
module VARCHAR(255) NOT NULL,
parameters TEXT,
resource_class_id INTEGER NOT NULL,
failed_job_tolerance INTEGER NOT NULL DEFAULT 0,
......
......@@ -103,7 +103,7 @@ CREATE INDEX ON pipeline_wide_parameters (param_value);
CREATE TABLE analysis_base (
analysis_id SERIAL PRIMARY KEY,
logic_name VARCHAR(255) NOT NULL,
module VARCHAR(255),
module VARCHAR(255) NOT NULL,
parameters TEXT,
resource_class_id INTEGER NOT NULL,
failed_job_tolerance INTEGER NOT NULL DEFAULT 0,
......
......@@ -103,7 +103,7 @@ CREATE INDEX pipeline_wide_parameters_value_idx ON pipeline_wide_para
CREATE TABLE analysis_base (
analysis_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
logic_name VARCHAR(255) NOT NULL,
module VARCHAR(255),
module VARCHAR(255) NOT NULL,
parameters TEXT,
resource_class_id INTEGER NOT NULL,
failed_job_tolerance INTEGER NOT NULL DEFAULT 0,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment