Commit f71e4adf authored by Leo Gordon's avatar Leo Gordon
Browse files

schema_change: extended all mysql TEXT fields to MEDIUMTEXT for more space

parent f54b548d
-- ---------------------------------------------------------------------------------------------------
-- Extend the all TEXT fields (that accomodate 64kb) into MEDIUMTEXT (that accomodates 24Mb)
-- ---------------------------------------------------------------------------------------------------
SET @expected_version = 65;
-- 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> -------------------------------------------------
ALTER TABLE hive_meta MODIFY COLUMN meta_value MEDIUMTEXT;
ALTER TABLE pipeline_wide_parameters MODIFY COLUMN param_value MEDIUMTEXT;
ALTER TABLE analysis_base MODIFY COLUMN parameters MEDIUMTEXT;
ALTER TABLE dataflow_rule MODIFY COLUMN input_id_template MEDIUMTEXT DEFAULT NULL;
ALTER TABLE accu MODIFY COLUMN value MEDIUMTEXT;
ALTER TABLE analysis_data MODIFY COLUMN data MEDIUMTEXT;
ALTER TABLE log_message MODIFY COLUMN msg MEDIUMTEXT;
-- ----------------------------------</actual_patch> -------------------------------------------------
-- increase the schema version by one:
UPDATE hive_meta SET meta_value=meta_value+1 WHERE meta_key='hive_sql_schema_version';
-- ---------------------------------------------------------------------------------------------------
-- Dummy: this patch only makes a difference for MySQL schema
-- ---------------------------------------------------------------------------------------------------
\set expected_version 65
\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> -------------------------------------------------
-- NOTHING TO DO HERE, just change the schema version
-- ----------------------------------</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';
-- ---------------------------------------------------------------------------------------------------
-- Dummy: this patch only makes a difference for MySQL schema
-- ---------------------------------------------------------------------------------------------------
CREATE TEMPORARY VIEW exp_ver AS SELECT "65" 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> -------------------------------------------------
-- NOTHING TO DO HERE, just change the schema version
-- ----------------------------------</actual_patch> -------------------------------------------------
-- increase the schema version by one:
UPDATE hive_meta SET meta_value=meta_value+1 WHERE meta_key='hive_sql_schema_version';
......@@ -51,7 +51,7 @@ CONTACT
CREATE TABLE hive_meta (
meta_key VARCHAR(255) NOT NULL PRIMARY KEY,
meta_value TEXT
meta_value MEDIUMTEXT
) COLLATE=latin1_swedish_ci ENGINE=InnoDB;
......@@ -70,7 +70,7 @@ CREATE TABLE hive_meta (
CREATE TABLE pipeline_wide_parameters (
param_name VARCHAR(255) NOT NULL PRIMARY KEY,
param_value TEXT,
param_value MEDIUMTEXT,
KEY value_idx (param_name(255))
) COLLATE=latin1_swedish_ci ENGINE=InnoDB;
......@@ -102,7 +102,7 @@ CREATE TABLE analysis_base (
analysis_id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
logic_name VARCHAR(255) NOT NULL,
module VARCHAR(255) NOT NULL,
parameters TEXT,
parameters MEDIUMTEXT,
resource_class_id INTEGER NOT NULL,
failed_job_tolerance INTEGER NOT NULL DEFAULT 0,
max_retry_count INTEGER NOT NULL DEFAULT 3,
......@@ -214,7 +214,7 @@ CREATE TABLE dataflow_rule (
branch_code INTEGER NOT NULL DEFAULT 1,
funnel_dataflow_rule_id INTEGER DEFAULT NULL,
to_analysis_url VARCHAR(255) NOT NULL DEFAULT '',
input_id_template TEXT DEFAULT NULL,
input_id_template MEDIUMTEXT DEFAULT NULL,
UNIQUE KEY (from_analysis_id, branch_code, funnel_dataflow_rule_id, to_analysis_url, input_id_template(512))
) COLLATE=latin1_swedish_ci ENGINE=InnoDB;
......@@ -393,7 +393,7 @@ CREATE TABLE accu (
receiving_job_id INTEGER NOT NULL,
struct_name VARCHAR(255) NOT NULL,
key_signature VARCHAR(255) NOT NULL,
value TEXT,
value MEDIUMTEXT,
KEY accu_sending_idx (sending_job_id),
KEY accu_receiving_idx (receiving_job_id)
......@@ -416,7 +416,7 @@ CREATE TABLE accu (
CREATE TABLE analysis_data (
analysis_data_id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
data TEXT,
data MEDIUMTEXT,
KEY (data(100))
) COLLATE=latin1_swedish_ci ENGINE=InnoDB;
......@@ -573,7 +573,7 @@ CREATE TABLE log_message (
when_logged TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
retry INTEGER DEFAULT NULL,
status ENUM('UNKNOWN','SPECIALIZATION','COMPILATION','CLAIMED','READY','PRE_CLEANUP','FETCH_INPUT','RUN','WRITE_OUTPUT','POST_CLEANUP','PASSED_ON') DEFAULT 'UNKNOWN',
msg TEXT,
msg MEDIUMTEXT,
is_error SMALLINT,
KEY worker_id (worker_id),
......
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