示例#1
0
 public static function build_upgrade($old_output_prefix, $old_composite_file, $old_db_doc, $old_files, $new_output_prefix, $new_composite_file, $new_db_doc, $new_files)
 {
     // place the upgrade files with the new_files set
     $upgrade_prefix = $new_output_prefix . '_upgrade';
     // pgsql8_diff needs these to intelligently create SQL difference statements in dependency order
     dbsteward::info("Calculating old table foreign key dependency order..");
     pgsql8_diff::$old_table_dependency = xml_parser::table_dependency_order($old_db_doc);
     dbsteward::info("Calculating new table foreign key dependency order..");
     pgsql8_diff::$new_table_dependency = xml_parser::table_dependency_order($new_db_doc);
     pgsql8_diff::diff_doc($old_composite_file, $new_composite_file, $old_db_doc, $new_db_doc, $upgrade_prefix);
     if (dbsteward::$generate_slonik) {
         $replica_sets = pgsql8::get_slony_replica_sets($new_db_doc);
         foreach ($replica_sets as $replica_set) {
             dbsteward::info("Generating replica set " . $replica_set['id'] . " upgrade slonik");
             // separate upgrade slonik file sets for each replica set
             $slonik_upgrade_prefix = $upgrade_prefix . "_slony_replica_set_" . $replica_set['id'];
             // generate upgrade slonik to apply generated sql changes
             $old_new_slonik_header = "# Old definition:  " . implode(', ', $old_files) . "\n" . "# New definition:  " . implode(', ', $new_files) . "\n" . "# Replica set ID " . $replica_set['id'] . "\n";
             $old_replica_set = pgsql8::get_slony_replica_set($old_db_doc, (string) $replica_set['id']);
             pgsql8::build_upgrade_slonik_replica_set($old_db_doc, $new_db_doc, $old_replica_set, $replica_set, $slonik_upgrade_prefix, $old_new_slonik_header);
         }
     }
     return $new_db_doc;
 }