/** * Adds commands for removal of columns to the list of commands. * * @param commands list of commands * @param old_table original table * @param new_table new table */ private static function add_drop_table_columns(&$commands, $old_table, $new_table) { foreach (dbx::get_table_columns($old_table) as $old_column) { if (!mssql10_table::contains_column($new_table, $old_column['name'])) { if (!dbsteward::$ignore_oldnames && ($renamed_column_name = mssql10_table::column_name_by_old_name($new_table, $old_column['name'])) !== false) { // table indicating oldTableName = table['name'] present in new schema? don't do DROP statement $old_table_name = mssql10::get_quoted_table_name($old_table['name']); $old_column_name = mssql10::get_quoted_column_name($old_column['name']); $commands[] = array('stage' => 'AFTER3', 'command' => "-- {$old_table_name} DROP COLUMN {$old_column_name} omitted: new column {$renamed_column_name} indicates it is the replacement for " . $old_column_name); } else { //echo "NOTICE: add_drop_table_columns() " . $new_table['name'] . " does not contain " . $old_column['name'] . "\n"; $commands[] = array('stage' => '3', 'command' => "\tDROP COLUMN " . mssql10::get_quoted_column_name($old_column['name'])); // @TODO: when dropping columns with an implicitly created default value // a mssql contraint to enforce the default value is created, but how can we reference it // and drop it, to prevent errors like 'ALTER TABLE DROP COLUMN partial failed because one or more objects access this column.' } } } }