public static function diff_constraints_table($ofs, $old_schema, $old_table, $new_schema, $new_table, $type, $drop_constraints = FALSE) { if ($drop_constraints) { // drop constraints that no longer exist or are modified foreach (mssql10_diff_tables::get_drop_constraints($old_schema, $old_table, $new_schema, $new_table, $type) as $constraint) { $ofs->write(mssql10_table::get_constraint_drop_sql($constraint) . "\n"); } } else { // if it is a renamed table, remove all constraints and recreate with new table name conventions if (mssql10_diff_tables::is_renamed_table($new_schema, $new_table)) { foreach (mssql10_constraint::get_table_constraints(dbsteward::$old_database, $old_schema, $old_table, $type) as $constraint) { // rewrite the constraint definer to refer to the new table name // so the constraint by the old name, but part of the new table // will be referenced properly in the drop statement $constraint['table_name'] = $new_table['name']; $ofs->write(mssql10_table::get_constraint_drop_sql($constraint) . "\n"); } // add all defined constraints back to the new table foreach (mssql10_constraint::get_table_constraints(dbsteward::$new_database, $new_schema, $new_table, $type) as $constraint) { $ofs->write(mssql10_table::get_constraint_sql($constraint) . "\n"); } return; } // END if it is a renamed table, remove all constraints and recreate with new table name conventions // add new constraints foreach (mssql10_diff_tables::get_new_constraints($old_schema, $old_table, $new_schema, $new_table, $type) as $constraint) { $ofs->write(mssql10_table::get_constraint_sql($constraint) . "\n"); } } }