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

foreign keys have moved out into a separate file for flexibility

parent 198ed272
......@@ -90,8 +90,9 @@ sub pipeline_create_commands {
return [
'mysql '.$self->dbconn_2_mysql('pipeline_db', 0)." -e 'CREATE DATABASE ".$self->o('pipeline_db', '-dbname')."'",
# standard eHive tables and procedures:
# standard eHive tables, foreign_keys and procedures:
'mysql '.$self->dbconn_2_mysql('pipeline_db', 1).' <'.$self->o('ensembl_cvs_root_dir').'/ensembl-hive/sql/tables.sql',
'mysql '.$self->dbconn_2_mysql('pipeline_db', 1).' <'.$self->o('ensembl_cvs_root_dir').'/ensembl-hive/sql/foreign_keys.sql',
'mysql '.$self->dbconn_2_mysql('pipeline_db', 1).' <'.$self->o('ensembl_cvs_root_dir').'/ensembl-hive/sql/procedures.sql',
];
}
......
# introducing the FOREIGN KEY constraints as a separate file (so that they could be optionally switched on or off):
ALTER TABLE analysis_description ADD FOREIGN KEY (analysis_id) REFERENCES analysis(analysis_id);
ALTER TABLE hive ADD FOREIGN KEY (analysis_id) REFERENCES analysis(analysis_id);
ALTER TABLE dataflow_rule ADD FOREIGN KEY (from_analysis_id) REFERENCES analysis(analysis_id);
ALTER TABLE analysis_ctrl_rule ADD FOREIGN KEY (ctrled_analysis_id) REFERENCES analysis(analysis_id);
ALTER TABLE analysis_job ADD FOREIGN KEY (analysis_id) REFERENCES analysis(analysis_id);
ALTER TABLE job_message ADD FOREIGN KEY (analysis_id) REFERENCES analysis(analysis_id);
ALTER TABLE analysis_stats ADD FOREIGN KEY (analysis_id) REFERENCES analysis(analysis_id);
ALTER TABLE analysis_stats_monitor ADD FOREIGN KEY (analysis_id) REFERENCES analysis(analysis_id);
ALTER TABLE analysis_job ADD FOREIGN KEY (worker_id) REFERENCES hive(worker_id);
ALTER TABLE job_message ADD FOREIGN KEY (worker_id) REFERENCES hive(worker_id);
ALTER TABLE analysis_job_file ADD FOREIGN KEY (worker_id) REFERENCES hive(worker_id);
ALTER TABLE analysis_job ADD FOREIGN KEY (prev_analysis_job_id) REFERENCES analysis_job(analysis_job_id);
ALTER TABLE job_message ADD FOREIGN KEY (analysis_job_id) REFERENCES analysis_job(analysis_job_id);
ALTER TABLE analysis_job_file ADD FOREIGN KEY (analysis_job_id) REFERENCES analysis_job(analysis_job_id);
## The following are not unique keys in the original table, so cannot be used as foreign keys.
# ALTER TABLE analysis_stats ADD FOREIGN KEY (rc_id) REFERENCES resource_description(rc_id);
# ALTER TABLE analysis_stats_monitor ADD FOREIGN KEY (rc_id) REFERENCES resource_description(rc_id);
......@@ -82,8 +82,6 @@ CREATE TABLE IF NOT EXISTS analysis_description (
displayable BOOLEAN NOT NULL DEFAULT 1,
web_data TEXT,
FOREIGN KEY (analysis_id) REFERENCES analysis(analysis_id),
UNIQUE KEY analysis_idx (analysis_id)
) COLLATE=latin1_swedish_ci ENGINE=InnoDB;
......@@ -119,8 +117,6 @@ CREATE TABLE hive (
died datetime DEFAULT NULL,
cause_of_death enum('', 'NO_WORK', 'JOB_LIMIT', 'HIVE_OVERLOAD', 'LIFESPAN', 'CONTAMINATED', 'KILLED_BY_USER', 'MEMLIMIT', 'RUNLIMIT', 'FATALITY') DEFAULT '' NOT NULL,
FOREIGN KEY (analysis_id) REFERENCES analysis(analysis_id),
PRIMARY KEY (worker_id),
INDEX analysis_status (analysis_id, status)
......@@ -161,8 +157,6 @@ CREATE TABLE dataflow_rule (
branch_code int(10) default 1 NOT NULL,
input_id_template TEXT DEFAULT NULL,
FOREIGN KEY (from_analysis_id) REFERENCES analysis(analysis_id),
PRIMARY KEY (dataflow_rule_id),
UNIQUE KEY (from_analysis_id, to_analysis_url, branch_code, input_id_template(512))
......@@ -192,8 +186,6 @@ CREATE TABLE analysis_ctrl_rule (
condition_analysis_url varchar(255) default '' NOT NULL,
ctrled_analysis_id int(10) unsigned NOT NULL,
FOREIGN KEY (ctrled_analysis_id) REFERENCES analysis(analysis_id),
UNIQUE (condition_analysis_url, ctrled_analysis_id)
) COLLATE=latin1_swedish_ci ENGINE=InnoDB;
......@@ -239,10 +231,6 @@ CREATE TABLE analysis_job (
semaphore_count int(10) NOT NULL default 0,
semaphored_job_id int(10) DEFAULT NULL,
FOREIGN KEY (analysis_id) REFERENCES analysis(analysis_id),
FOREIGN KEY (worker_id) REFERENCES hive(worker_id),
FOREIGN KEY (prev_analysis_job_id) REFERENCES analysis_job(analysis_job_id),
PRIMARY KEY (analysis_job_id),
UNIQUE KEY input_id_analysis (input_id, analysis_id),
INDEX analysis_status_sema_retry (analysis_id, status, semaphore_count, retry_count),
......@@ -279,10 +267,6 @@ CREATE TABLE job_message (
msg text,
is_error boolean,
FOREIGN KEY (analysis_id) REFERENCES analysis(analysis_id),
FOREIGN KEY (analysis_job_id) REFERENCES analysis_job(analysis_job_id),
FOREIGN KEY (worker_id) REFERENCES hive(worker_id),
PRIMARY KEY (analysis_job_id, worker_id, moment),
INDEX worker_id (worker_id),
INDEX analysis_job_id (analysis_job_id)
......@@ -314,9 +298,6 @@ CREATE TABLE analysis_job_file (
type varchar(16) NOT NULL default '',
path varchar(255) NOT NULL,
FOREIGN KEY (worker_id) REFERENCES hive(worker_id),
FOREIGN KEY (analysis_job_id) REFERENCES analysis_job(analysis_job_id),
UNIQUE KEY job_hive_type (analysis_job_id, worker_id, type),
INDEX worker_id (worker_id)
......@@ -397,10 +378,7 @@ CREATE TABLE analysis_stats (
rc_id int(10) unsigned default 0 NOT NULL,
can_be_empty TINYINT UNSIGNED DEFAULT 0 NOT NULL,
UNIQUE KEY (analysis_id),
FOREIGN KEY (analysis_id) REFERENCES analysis(analysis_id)
# , FOREIGN KEY (rc_id) REFERENCES resource_description(rc_id),
UNIQUE KEY (analysis_id)
) COLLATE=latin1_swedish_ci ENGINE=InnoDB;
......@@ -430,10 +408,7 @@ CREATE TABLE analysis_stats_monitor (
last_update datetime NOT NULL,
sync_lock int(10) default 0 NOT NULL,
rc_id int(10) unsigned default 0 NOT NULL,
can_be_empty TINYINT UNSIGNED DEFAULT 0 NOT NULL,
FOREIGN KEY (analysis_id) REFERENCES analysis(analysis_id)
# , FOREIGN KEY (rc_id) REFERENCES resource_description(rc_id)
can_be_empty TINYINT UNSIGNED DEFAULT 0 NOT NULL
) COLLATE=latin1_swedish_ci ENGINE=InnoDB;
......
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