/** * Returns true if table contains given constraint $name * * @param $name name of the constraint * * @return boolean true if table contains given constraint $name otherwise false */ public static function contains_constraint($db_doc, $node_schema, $node_table, $name) { return format_constraint::get_table_constraint($db_doc, $node_schema, $node_table, $name) != null; }
/** * 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 */ protected 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 (format_constraint::get_table_constraints(dbsteward::$new_database, $new_schema, $new_table, $type) as $constraint) { $list[] = $constraint; } } else { foreach (format_constraint::get_table_constraints(dbsteward::$new_database, $new_schema, $new_table, $type) as $constraint) { $old_constraint = format_constraint::get_table_constraint(dbsteward::$old_database, $old_schema, $old_table, $constraint['name']); if (!format_table::contains_constraint(dbsteward::$old_database, $old_schema, $old_table, $constraint['name']) || !format_constraint::equals($old_constraint, $constraint)) { $list[] = $constraint; } } } } return $list; }