/** * Does this table constrain against a renamed table? * * @param object $db_doc * @param object $schema * @param object $table * return boolean */ public static function constrains_against_renamed_table($db_doc, $schema, $table) { foreach (format_constraint::get_table_constraints($db_doc, $schema, $table, 'constraint') as $constraint) { if (pgsql8_table::constraint_depends_on_renamed_table($db_doc, $constraint)) { dbsteward::info("NOTICE: " . $schema['name'] . "." . $table['name'] . " constrains against a renamed table with constraint " . $constraint['name']); return TRUE; } } return FALSE; }
/** * Returns list of constraints that should be added. * * @param old_table original table * @param new_table new table * @param type whether primary keys should be processed or other constraints should be processed * * @return list of constraints that should be added */ private static function get_new_constraints($old_schema, $old_table, $new_schema, $new_table, $type) { $list = array(); if ($new_table != null) { if ($old_table == null) { foreach (pgsql8_constraint::get_table_constraints(dbsteward::$new_database, $new_schema, $new_table, $type) as $constraint) { $list[] = $constraint; } } else { foreach (pgsql8_constraint::get_table_constraints(dbsteward::$new_database, $new_schema, $new_table, $type) as $constraint) { $old_constraint = pgsql8_constraint::get_table_constraint(dbsteward::$old_database, $old_schema, $old_table, $constraint['name']); if (!pgsql8_table::contains_constraint(dbsteward::$old_database, $old_schema, $old_table, $constraint['name']) || !pgsql8_table::constraint_equals($old_constraint, $constraint) || pgsql8_table::constraint_depends_on_renamed_table(dbsteward::$new_database, $constraint)) { $list[] = $constraint; } } } } return $list; }