/** * Outputs DDL for addition, removal and modifications of table columns * * @param $ofs1 stage1 output file segmenter * @param $ofs3 stage3 output file segmenter * @param $old_table original table * @param $new_table new table */ public static function diff_tables($ofs1, $ofs3, $old_schema, $new_schema, $old_table_target = null, $new_table_target = null) { self::create_tables($ofs1, $old_schema, $new_schema, $old_table_target, $new_table_target); // were specific tables passed? if ($old_table_target !== null || $new_table_target !== null) { $old_table = $old_table_target; $new_table = $new_table_target; if ($old_table && $new_table) { mssql10_diff_tables::update_table_columns($ofs1, $ofs3, $old_table, $new_schema, $new_table); mssql10_diff_tables::add_alter_statistics($ofs1, $old_table, $new_schema, $new_table); } } else { foreach (dbx::get_tables($new_schema) as $new_table) { if (!$old_schema) { // old_schema not defined continue; } $old_table = dbx::get_table($old_schema, $new_table['name']); dbx::renamed_table_check_pointer($old_schema, $old_table, $new_schema, $new_table); if (!$old_table) { // old_table not defined continue; } mssql10_diff_tables::update_table_columns($ofs1, $ofs3, $old_table, $new_schema, $new_table); mssql10_diff_tables::add_alter_statistics($ofs1, $old_table, $new_schema, $new_table); } } }