From cba55729fec8002e615ffa48c132b279b2b8e3ac Mon Sep 17 00:00:00 2001 From: Andrew Yates <ayates@ebi.ac.uk> Date: Wed, 23 Oct 2013 09:29:20 +0000 Subject: [PATCH] [ENSCORESW-694]. Adding a unique constraint to alt_allele(gene_id). Seems that our earlier design was incorrect and we do want to only have 1 gene in 1 alt allele group. So adding the constraint in. --- sql/patch_73_74_h.sql | 15 +++++++++++++++ sql/table.sql | 3 +++ 2 files changed, 18 insertions(+) create mode 100644 sql/patch_73_74_h.sql diff --git a/sql/patch_73_74_h.sql b/sql/patch_73_74_h.sql new file mode 100644 index 0000000000..40b893dfb4 --- /dev/null +++ b/sql/patch_73_74_h.sql @@ -0,0 +1,15 @@ +# patch_73_74_h.sql +# +# Title: Creating a unique index on alt_allele(gene_id) +# +# Description: +# +# Alt alleles only allow a gene to appear in one group. Enforce this +# at the DB level + +CREATE UNIQUE INDEX gene_idx ON alt_allele(gene_id); + +# patch identifier +INSERT INTO meta (species_id, meta_key, meta_value) VALUES (NULL, 'patch', 'patch_73_74_h.sql|alt_allele_unique_gene_idx'); + + diff --git a/sql/table.sql b/sql/table.sql index d6a8c08a19..737a1fed65 100755 --- a/sql/table.sql +++ b/sql/table.sql @@ -274,6 +274,8 @@ INSERT INTO meta (species_id, meta_key, meta_value) VALUES (NULL, 'patch', 'patch_73_74_f.sql|remove_pair_dna_align'); INSERT INTO meta (species_id, meta_key, meta_value) VALUES (NULL, 'patch', 'patch_73_74_g.sql|add_transcript_idx_tise'); +INSERT INTO meta (species_id, meta_key, meta_value) + VALUES (NULL, 'patch', 'patch_73_74_h.sql|alt_allele_unique_gene_idx'); /** @table meta_coord @@ -405,6 +407,7 @@ CREATE TABLE alt_allele ( gene_id INT UNSIGNED NOT NULL, PRIMARY KEY (alt_allele_id), + UNIQUE KEY gene_idx (gene_id), KEY (gene_id,alt_allele_group_id) ) COLLATE=latin1_swedish_ci ENGINE=MyISAM; -- GitLab