From 5de1bf2cdbfcd905824fc09959fb3357b846d48b Mon Sep 17 00:00:00 2001
From: Andrew Yates <ayates@ebi.ac.uk>
Date: Mon, 29 Oct 2012 12:58:29 +0000
Subject: [PATCH] Adding column edits for columns which have now diverged in
 their definitions. Also making sure data_file's collate is set correctly

---
 sql/patch_69_70_c.sql | 24 ++++++++++++++++++++++++
 sql/table.sql         | 30 +++++++++++++++++-------------
 2 files changed, 41 insertions(+), 13 deletions(-)
 create mode 100644 sql/patch_69_70_c.sql

diff --git a/sql/patch_69_70_c.sql b/sql/patch_69_70_c.sql
new file mode 100644
index 0000000000..2d8b590e4e
--- /dev/null
+++ b/sql/patch_69_70_c.sql
@@ -0,0 +1,24 @@
+# patch_69_70_c.sql
+#
+# Title: Ensure column definitions are consistent in the schema
+#
+# Description: A number of column defintions over time have diverged from their
+#              original specification. We are converting those we know are wrong
+
+ALTER TABLE dependent_xref MODIFY COLUMN object_xref_id INT(10) UNSIGNED NOT NULL;
+ALTER TABLE dependent_xref MODIFY COLUMN master_xref_id INT(10) UNSIGNED NOT NULL;
+ALTER TABLE dependent_xref MODIFY COLUMN dependent_xref_id INT(10) UNSIGNED NOT NULL;
+
+ALTER TABLE object_xref MODIFY COLUMN xref_id INT(10) UNSIGNED NOT NULL;
+
+ALTER TABLE data_file MODIFY COLUMN data_file_id INT(10) UNSIGNED NOT NULL;
+ALTER TABLE data_file MODIFY COLUMN coord_system_id INT(10) UNSIGNED NOT NULL;
+ALTER TABLE data_file MODIFY COLUMN analysis_id SMALLINT UNSIGNED NOT NULL;
+
+ALTER TABLE data_file COLLATE=latin1_swedish_ci;
+
+# Patch identifier
+INSERT INTO meta (species_id, meta_key, meta_value)
+  VALUES (NULL, 'patch', 'patch_69_70_c.sql|column_datatype_consistency');
+
+
diff --git a/sql/table.sql b/sql/table.sql
index cef21b19cc..ec582373a9 100755
--- a/sql/table.sql
+++ b/sql/table.sql
@@ -514,6 +514,9 @@ INSERT INTO meta (species_id, meta_key, meta_value) VALUES
 INSERT INTO meta (species_id, meta_key, meta_value) VALUES
   (NULL, 'patch', 'patch_69_70_b.sql|add_mapping_set_history')
  ;
+INSERT INTO meta (species_id, meta_key, meta_value) VALUES
+  (NULL, 'patch', 'patch_69_70_c.sql|column_datatype_consistency')
+ ;
 
 /**
 @table meta_coord
@@ -2191,9 +2194,9 @@ They are linked to primary external references instead.
 
 CREATE TABLE dependent_xref(
 
-  object_xref_id         INT NOT NULL,
-  master_xref_id         INT NOT NULL,
-  dependent_xref_id      INT NOT NULL,
+  object_xref_id         INT(10) UNSIGNED NOT NULL,
+  master_xref_id         INT(10) UNSIGNED NOT NULL,
+  dependent_xref_id      INT(10) UNSIGNED NOT NULL,
 
   PRIMARY KEY( object_xref_id ),
   KEY dependent ( dependent_xref_id ),
@@ -2342,7 +2345,7 @@ CREATE TABLE object_xref (
   ensembl_object_type         ENUM('RawContig', 'Transcript', 'Gene',
                                    'Translation', 'Operon', 'OperonTranscript')
                               NOT NULL,
-  xref_id                     INT UNSIGNED NOT NULL,
+  xref_id                     INT(10) UNSIGNED NOT NULL,
   linkage_annotation          VARCHAR(255) DEFAULT NULL,
   analysis_id                 SMALLINT UNSIGNED DEFAULT 0 NOT NULL,
 
@@ -2575,17 +2578,18 @@ CREATE TABLE interpro (
 */
 
 CREATE TABLE data_file (
-  data_file_id int(11) unsigned NOT NULL AUTO_INCREMENT,
-  coord_system_id int(11) NOT NULL,
-  analysis_id int(11) NOT NULL,
-  name varchar(100) NOT NULL,
-  version_lock tinyint(1) DEFAULT 0 NOT NULL,
-  absolute tinyint(1) DEFAULT 0 NOT NULL,
-  url text,
-  file_type enum('BAM','BIGBED','BIGWIG','VCF'),
+  data_file_id      INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+  coord_system_id   INT(10) UNSIGNED NOT NULL,
+  analysis_id       SMALLINT UNSIGNED NOT NULL,
+  name              VARCHAR(100) NOT NULL,
+  version_lock      TINYINT(1) DEFAULT 0 NOT NULL,
+  absolute          TINYINT(1) DEFAULT 0 NOT NULL,
+  url               TEXT,
+  file_type         ENUM('BAM','BIGBED','BIGWIG','VCF'),
+  
   PRIMARY KEY (data_file_id),
   UNIQUE KEY df_unq_idx(coord_system_id, analysis_id, name, file_type),
   INDEX df_name_idx(name),
   INDEX df_analysis_idx(analysis_id)
-) ENGINE=MyISAM;
+) COLLATE=latin1_swedish_ci ENGINE=MyISAM;
 
-- 
GitLab