Skip to content
Snippets Groups Projects
Commit 87371e92 authored by Kieron Taylor's avatar Kieron Taylor :angry:
Browse files

New test for valid foreign keys in InnoDB applications. foreign_keys.sql...

New test for valid foreign keys in InnoDB applications. foreign_keys.sql cleaned. Tabs assassinated.
parent 950e4973
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,7 @@ use Test::More;
use Bio::EnsEMBL::Test::MultiTestDB;
use Bio::EnsEMBL::Utils::IO qw/slurp/;
use File::Spec::Functions qw/updir catfile catdir/;
use File::Temp qw/tempfile/;
my $db = Bio::EnsEMBL::Test::MultiTestDB->new();
my $dba = $db->get_DBAdaptor('core');
......@@ -42,7 +43,7 @@ SKIP: {
my $table_string = slurp $sql_file;
my @fks = sort grep /FOREIGN[\s\n]+?KEY[\s\n]+?\(.+?\)[\s\n]+?REFERENCES/i, $table_string;
if(@fks) {
fail("Definition of foreign keys detected in SQL schema file");
fail("Definition of foreign keys detected in SQL schema file\n".join(', ',@fks));
} else {
pass("SQL schema file does not define foreign keys");
}
......@@ -62,6 +63,38 @@ SKIP: {
note 'Dropping database '.$new_db_name;
$dba->dbc()->do("drop database $new_db_name");
# Check viability of foreign_keys.sql
$table_string =~ s/ENGINE=MyISAM/ENGINE=InnoDB/g;
my $fk_file = catfile($sql_dir, 'foreign_keys.sql');
$table_string .= slurp $fk_file;
my ($temp_fh,$temp_filename) = tempfile;
{
local $| = 1;
print $temp_fh $table_string;
}
$new_db_name = $db->create_db_name('fkschematemp');
note 'Creating database with foreign keys '.$new_db_name;
$dba->dbc()->do("create database $new_db_name");
%args = ( host => $dbc->host(), port => $dbc->port(), user => $dbc->username(), password => $dbc->password());
$cmd_args = join(q{ }, map { "--${_}=$args{$_}" } keys %args);
$cmd = "mysql $cmd_args $new_db_name < $temp_filename 2>&1";
$output = `$cmd`;
$ec = ($? >> 8);
if($ec != 0) {
note($output);
fail("MySQL (InnoDB) command failed with error code '$ec'");
}
else {
pass("MySQL (InnoDB) was able to load the Ensembl core schema with foreign keys");
}
note 'Dropping database '.$new_db_name;
$dba->dbc()->do("drop database $new_db_name");
}
done_testing();
\ No newline at end of file
......@@ -23,8 +23,8 @@
# key constraints on MyISAM tables.
ALTER table alt_allele ADD FOREIGN KEY (gene_id) REFERENCES gene(gene_id);
ALTER table alt_allele ADD FOREIGN KEY (alt_allele_group_id) REFERENCES alt_allele_group(alt_allele_group_id)
ALTER table alt_allele_id ADD FOREIGN KEY (alt_allele_id) REFERENCES alt_allele(alt_allele_id);
ALTER table alt_allele ADD FOREIGN KEY (alt_allele_group_id) REFERENCES alt_allele_group(alt_allele_group_id);
ALTER table alt_allele ADD FOREIGN KEY (alt_allele_id) REFERENCES alt_allele(alt_allele_id);
ALTER table analysis_description ADD FOREIGN KEY (analysis_id) REFERENCES analysis(analysis_id);
......@@ -58,9 +58,6 @@ ALTER table dna ADD FOREIGN KEY (seq_region_id) REFERENCES seq_region(seq_region
ALTER table dna_align_feature ADD FOREIGN KEY (analysis_id) REFERENCES analysis(analysis_id);
ALTER table dna_align_feature ADD FOREIGN KEY (seq_region_id) REFERENCES seq_region(seq_region_id);
ALTER table dna_align_feature ADD FOREIGN KEY (external_db_id) REFERENCES external_db(external_db_id);
ALTER table dna_align_feature ADD FOREIGN KEY (pair_dna_align_feature_id) REFERENCES dna_align_feature(dna_align_feature_id);
ALTER table dnac ADD FOREIGN KEY (seq_region_id) REFERENCES seq_region(seq_region_id);
ALTER table exon ADD FOREIGN KEY (seq_region_id) REFERENCES seq_region(seq_region_id);
......@@ -138,16 +135,6 @@ ALTER table protein_align_feature ADD FOREIGN KEY (external_db_id) REFERENCES ex
ALTER table protein_feature ADD FOREIGN KEY (analysis_id) REFERENCES analysis(analysis_id);
ALTER table protein_feature ADD FOREIGN KEY (translation_id) REFERENCES translation(translation_id);
ALTER table qtl ADD FOREIGN KEY (flank_marker_id_1) REFERENCES marker(marker_id);
ALTER table qtl ADD FOREIGN KEY (flank_marker_id_2) REFERENCES marker(marker_id);
ALTER table qtl ADD FOREIGN KEY (peak_marker_id) REFERENCES marker(marker_id);
ALTER table qtl_feature ADD FOREIGN KEY (analysis_id) REFERENCES analysis(analysis_id);
ALTER table qtl_feature ADD FOREIGN KEY (qtl_id) REFERENCES qtl(qtl_id);
ALTER table qtl_feature ADD FOREIGN KEY (seq_region_id) REFERENCES seq_region(seq_region_id);
ALTER table qtl_synonym ADD FOREIGN KEY (qtl_id) REFERENCES qtl(qtl_id);
ALTER table repeat_feature ADD FOREIGN KEY (analysis_id) REFERENCES analysis(analysis_id);
ALTER table repeat_feature ADD FOREIGN KEY (repeat_consensus_id) REFERENCES repeat_consensus(repeat_consensus_id);
ALTER table repeat_feature ADD FOREIGN KEY (seq_region_id) REFERENCES seq_region(seq_region_id);
......@@ -196,9 +183,6 @@ ALTER table translation ADD FOREIGN KEY (transcript_id) REFERENCES transcript(tr
ALTER table translation_attrib ADD FOREIGN KEY (attrib_type_id) REFERENCES attrib_type(attrib_type_id);
ALTER table translation_attrib ADD FOREIGN KEY (translation_id) REFERENCES translation(translation_id);
ALTER table unconventional_transcript_association ADD FOREIGN KEY (gene_id) REFERENCES gene(gene_id);
ALTER table unconventional_transcript_association ADD FOREIGN KEY (transcript_id) REFERENCES transcript(transcript_id);
ALTER table unmapped_object ADD FOREIGN KEY (analysis_id) REFERENCES analysis(analysis_id);
ALTER table unmapped_object ADD FOREIGN KEY (external_db_id) REFERENCES external_db(external_db_id);
ALTER table unmapped_object ADD FOREIGN KEY (unmapped_reason_id) REFERENCES unmapped_reason(unmapped_reason_id);
......
......@@ -969,8 +969,8 @@ CREATE TABLE splicing_event (
@column splicing_event_id Foreign key references to the @link splicing_event table.
@column exon_id Foreign key references to the @link exon table.
@column transcript_id Foreign key references to the @link transcript table.
@column feature_order Feature order number according to genomic location.
@column transcript_association Transcript sequence.
@column feature_order Feature order number according to genomic location.
@column transcript_association Transcript sequence.
@column type E.g. 'constitutive_exon','exon','flanking_exon'.
@column start Sequence start.
@column end Sequence end.
......
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