Commit 19abc863 authored by Leo Gordon's avatar Leo Gordon
Browse files

Adding foreign keys to PostgreSQL schema by reusing the MySQL file (the syntax...

Adding foreign keys to PostgreSQL schema by reusing the MySQL file (the syntax happens to be exactly the same!)
parent b85670ac
......@@ -118,20 +118,21 @@ sub pipeline_create_commands {
],
'mysql' => [
$self->o('hive_force_init') ? ( 'mysql '.$self->dbconn_2_mysql($db_conn, 0)." -e 'DROP DATABASE IF EXISTS `".$self->o($db_conn, '-dbname')."`'" ) : (),
'mysql '.$self->dbconn_2_mysql($db_conn, 0)." -e 'CREATE DATABASE `".$self->o($db_conn, '-dbname')."`'",
# standard eHive tables, triggers, foreign_keys and procedures:
$self->db_connect_command($db_conn).' <'.$self->o('hive_root_dir').'/sql/tables.mysql',
$self->o('hive_use_triggers') ? ( $self->db_connect_command($db_conn).' <'.$self->o('hive_root_dir').'/sql/triggers.mysql' ) : (),
$self->db_connect_command($db_conn).' <'.$self->o('hive_root_dir').'/sql/foreign_keys.mysql',
$self->db_connect_command($db_conn).' <'.$self->o('hive_root_dir').'/sql/foreign_keys.sql',
$self->db_connect_command($db_conn).' <'.$self->o('hive_root_dir').'/sql/procedures.mysql',
],
'pgsql' => [
$self->o('hive_force_init') ? ( $self->db_execute_command($db_conn, 'DROP DATABASE IF EXISTS '.$self->o($db_conn, '-dbname'), 0 ) ) : (),
$self->db_execute_command($db_conn, 'CREATE DATABASE '.$self->o($db_conn, '-dbname'), 0 ),
# standard eHive tables, triggers, foreign_keys and procedures:
$self->db_connect_command($db_conn).' <'.$self->o('hive_root_dir').'/sql/tables.pgsql',
$self->db_connect_command($db_conn).' <'.$self->o('hive_root_dir').'/sql/foreign_keys.sql',
],
}->{ $self->o($db_conn, '-driver') };
......
# introducing the FOREIGN KEY constraints as a separate file (so that they could be optionally switched on or off):
/*
FOREIGN KEY constraints are listed in a separate file so that they could be optionally switched on or off.
A nice surprise is that the syntax for defining them is the same for MySQL and PostgreSQL.
*/
ALTER TABLE worker ADD FOREIGN KEY (analysis_id) REFERENCES analysis_base(analysis_id);
ALTER TABLE dataflow_rule ADD FOREIGN KEY (from_analysis_id) REFERENCES analysis_base(analysis_id);
......
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