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

schema_change: pipeline_wide_parameters added instead of meta for clearer separation

parent f562ba28
......@@ -292,12 +292,16 @@ sub load_collections {
sub save_collections {
my $self = shift @_;
foreach my $AdaptorType ('Meta', 'PipelineWideParameters') {
my $adaptor = $self->get_adaptor( $AdaptorType );
while(my ($meta_key, $meta_value) = each %{ Bio::EnsEMBL::Hive->collection( $AdaptorType ) } ) {
$adaptor->remove_all_by_meta_key($meta_key); # make sure the previous values are gone
$adaptor->store_pair( $meta_key, $meta_value );
}
my $meta_adaptor = $self->get_adaptor( 'Meta' );
while(my ($meta_key, $meta_value) = each %{ Bio::EnsEMBL::Hive->collection( 'Meta' ) } ) {
$meta_adaptor->remove_all_by_meta_key($meta_key); # make sure the previous values are gone
$meta_adaptor->store_pair( $meta_key, $meta_value );
}
my $pwp_adaptor = $self->get_adaptor( 'PipelineWideParameters' );
while(my ($param_name, $param_value) = each %{ Bio::EnsEMBL::Hive->collection( 'PipelineWideParameters' ) } ) {
$pwp_adaptor->remove_all_by_param_name($param_name); # make sure the previous values are gone
$pwp_adaptor->store_pair( $param_name, $param_value );
}
foreach my $AdaptorType ('ResourceClass', 'ResourceDescription', 'Analysis', 'AnalysisStats', 'AnalysisCtrlRule', 'DataflowRule') {
......
......@@ -6,7 +6,7 @@
=head1 SYNOPSIS
$meta_container = $db_adaptor->get_PipelineWideParametersAdaptor;
$pipeline_wide_parameters_adaptor = $db_adaptor->get_PipelineWideParametersAdaptor;
=head1 DESCRIPTION
......@@ -41,14 +41,14 @@ use base ('Bio::EnsEMBL::Hive::DBSQL::NakedTableAdaptor');
sub default_table_name {
return 'meta';
return 'pipeline_wide_parameters';
}
sub store_pair {
my ($self, $meta_key, $meta_value) = @_;
my ($self, $param_name, $param_value) = @_;
return $self->store( { 'meta_key' => $meta_key, 'meta_value' => stringify( $meta_value ), 'species_id' => undef } );
return $self->store( { 'param_name' => $param_name, 'param_value' => stringify( $param_value ) } );
}
......@@ -61,8 +61,8 @@ sub store_pair {
sub get_param_hash {
my $self = shift @_;
my $original_value = $self->fetch_all_HASHED_FROM_meta_key_TO_meta_value();
my %destringified_hash = map { $_, destringify($original_value->{$_}[0]) } keys %$original_value;
my $original_value = $self->fetch_HASHED_FROM_param_name_TO_param_value();
my %destringified_hash = map { $_, destringify($original_value->{$_}) } keys %$original_value;
return \%destringified_hash;
}
......
......@@ -94,7 +94,7 @@ sub fetch_input {
$self->param('ignores', \@ignores);
# Would be good to have this from eHive
my @ehive_tables = qw(hive_meta worker dataflow_rule analysis_base analysis_ctrl_rule job accu log_message job_file analysis_data resource_description analysis_stats analysis_stats_monitor monitor msg progress resource_class);
my @ehive_tables = qw(hive_meta pipeline_wide_parameters worker dataflow_rule analysis_base analysis_ctrl_rule job accu log_message job_file analysis_data resource_description analysis_stats analysis_stats_monitor monitor msg progress resource_class);
$self->param('nb_ehive_tables', scalar(@ehive_tables));
# Connection parameters
......
-- initially duplicate 'meta' table with 'pipeline_wide_parameters'
CREATE TABLE pipeline_wide_parameters (
param_name VARCHAR(255) NOT NULL PRIMARY KEY,
param_value TEXT,
KEY value_idx (param_name(255))
) COLLATE=latin1_swedish_ci ENGINE=InnoDB;
INSERT INTO pipeline_wide_parameters(param_name, param_value) SELECT meta_key, meta_value FROM meta;
-- UPDATE hive_sql_schema_version
UPDATE hive_meta SET meta_value=57 WHERE meta_key='hive_sql_schema_version' AND meta_value='56';
-- initially duplicate 'meta' table with 'pipeline_wide_parameters'
CREATE TABLE pipeline_wide_parameters (
param_name VARCHAR(255) NOT NULL PRIMARY KEY,
param_value TEXT
);
CREATE INDEX ON pipeline_wide_parameters (param_value);
INSERT INTO pipeline_wide_parameters(param_name, param_value) SELECT meta_key, meta_value FROM meta;
-- UPDATE hive_sql_schema_version
UPDATE hive_meta SET meta_value=57 WHERE meta_key='hive_sql_schema_version' AND meta_value='56';
-- initially duplicate 'meta' table with 'pipeline_wide_parameters'
CREATE TABLE pipeline_wide_parameters (
param_name VARCHAR(255) NOT NULL PRIMARY KEY,
param_value TEXT
);
CREATE INDEX pipeline_wide_parameters_value_idx ON pipeline_wide_parameters (param_value);
INSERT INTO pipeline_wide_parameters(param_name, param_value) SELECT meta_key, meta_value FROM meta;
-- UPDATE hive_sql_schema_version
UPDATE hive_meta SET meta_value=57 WHERE meta_key='hive_sql_schema_version' AND meta_value='56';
......@@ -128,7 +128,7 @@ CREATE PROCEDURE drop_hive_tables()
MODIFIES SQL DATA
BEGIN
DROP VIEW IF EXISTS msg, progress;
DROP TABLE IF EXISTS monitor, analysis_stats_monitor, resource_description, analysis_data, job_file, dataflow_rule, analysis_ctrl_rule, analysis_stats, log_message, accu, job, worker, analysis_base, resource_class, hive_meta;
DROP TABLE IF EXISTS pipeline_wide_parameters, monitor, analysis_stats_monitor, resource_description, analysis_data, job_file, dataflow_rule, analysis_ctrl_rule, analysis_stats, log_message, accu, job, worker, analysis_base, resource_class, hive_meta;
END; //
DELIMITER ;
......@@ -397,37 +397,27 @@ CREATE TABLE hive_meta (
meta_key VARCHAR(255) NOT NULL PRIMARY KEY,
meta_value TEXT
) COLLATE=latin1_swedish_ci ENGINE=MyISAM;
) COLLATE=latin1_swedish_ci ENGINE=InnoDB;
/**
@table meta
@table pipeline_wide_parameters
@colour #000000
@desc This table comes from the Ensembl core schema.
It is created here with the 'IF NOT EXISTS' option to avoid a potential clash
if we are dealing with core-hive hybrid that is created in the wrong order.
At the moment meta table is used
(1) for compatibility with the Core API ('schema_version'),
(2) to keep pipeline-wide parameters.
@desc This table contains a simple hash between pipeline_wide_parameter names and their values.
The same data used to live in 'meta' table until both the schema and the API were finally separated.
@column meta_id auto-incrementing primary key, not really used per se
@column species_id always 1, kept for compatibility with the Core API
@column meta_key the KEY of KEY-VALUE pairs
@column meta_value the VALUE of KEY-VALUE pairs
@column param_name the KEY of KEY-VALUE pairs (primary key)
@column param_value the VALUE of KEY-VALUE pairs
*/
CREATE TABLE IF NOT EXISTS meta (
meta_id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
species_id INTEGER DEFAULT 1,
meta_key VARCHAR(255) NOT NULL,
meta_value TEXT NOT NULL,
CREATE TABLE pipeline_wide_parameters (
param_name VARCHAR(255) NOT NULL PRIMARY KEY,
param_value TEXT,
UNIQUE KEY species_key_value_idx (species_id, meta_key, meta_value(255)),
KEY species_value_idx (species_id, meta_value(255))
) COLLATE=latin1_swedish_ci ENGINE=MyISAM;
KEY value_idx (param_name(255))
) COLLATE=latin1_swedish_ci ENGINE=InnoDB;
/**
......
......@@ -405,32 +405,23 @@ CREATE TABLE hive_meta (
/**
@table meta
@table pipeline_wide_parameters
@colour #000000
@desc This table comes from the Ensembl core schema.
It is created here with the 'IF NOT EXISTS' option to avoid a potential clash
if we are dealing with core-hive hybrid that is created in the wrong order.
At the moment meta table is used
(1) for compatibility with the Core API ('schema_version'),
(2) to keep pipeline-wide parameters.
@desc This table contains a simple hash between pipeline_wide_parameter names and their values.
The same data used to live in 'meta' table until both the schema and the API were finally separated from Ensembl Core.
@column meta_id auto-incrementing primary key, not really used per se
@column species_id always 1, kept for compatibility with the Core API
@column meta_key the KEY of KEY-VALUE pairs
@column meta_value the VALUE of KEY-VALUE pairs
@column param_name the KEY of KEY-VALUE pairs (primary key)
@column param_value the VALUE of KEY-VALUE pairs
*/
CREATE TABLE IF NOT EXISTS meta (
meta_id SERIAL PRIMARY KEY,
species_id INTEGER DEFAULT 1,
meta_key VARCHAR(255) NOT NULL,
meta_value TEXT NOT NULL,
CREATE TABLE pipeline_wide_parameters (
param_name VARCHAR(255) NOT NULL PRIMARY KEY,
param_value TEXT
UNIQUE (species_id, meta_key, meta_value)
);
CREATE INDEX ON meta (species_id, meta_value);
CREATE INDEX ON pipeline_wide_parameters (param_value);
/**
......
......@@ -395,31 +395,23 @@ CREATE TABLE hive_meta (
/**
@table meta
@table pipeline_wide_parameters
@colour #000000
@desc This table comes from the Ensembl core schema.
It is created here with the 'IF NOT EXISTS' option to avoid a potential clash
if we are dealing with core-hive hybrid that is created in the wrong order.
At the moment meta table is used
(1) for compatibility with the Core API ('schema_version'),
(2) to keep pipeline-wide parameters.
@desc This table contains a simple hash between pipeline_wide_parameter names and their values.
The same data used to live in 'meta' table until both the schema and the API were finally separated from Ensembl Core.
@column meta_id auto-incrementing primary key, not really used per se
@column species_id always 1, kept for compatibility with the Core API
@column meta_key the KEY of KEY-VALUE pairs
@column meta_value the VALUE of KEY-VALUE pairs
@column param_name the KEY of KEY-VALUE pairs (primary key)
@column param_value the VALUE of KEY-VALUE pairs
*/
CREATE TABLE IF NOT EXISTS meta (
meta_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
species_id INTEGER DEFAULT 1,
meta_key VARCHAR(255) NOT NULL,
meta_value TEXT NOT NULL
CREATE TABLE pipeline_wide_parameters (
param_name VARCHAR(255) NOT NULL PRIMARY KEY,
param_value TEXT
);
CREATE UNIQUE INDEX meta_species_key_value_idx ON meta (species_id, meta_key, meta_value);
CREATE INDEX meta_species_value_idx ON meta (species_id, meta_value);
CREATE INDEX pipeline_wide_parameters_value_idx ON pipeline_wide_parameters (param_value);
/**
......
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