/** * Drop tables in old_schema no longer defined in new_schema * * @param type $ofs * @param type $old_schema * @param type $new_schema * @param type $old_table * @param type $new_table */ public static function drop_tables($ofs, $old_schema, $new_schema, $old_table = null, $new_table = null) { if ($old_schema != null && $new_schema != null) { foreach (dbx::get_tables($old_schema) as $table) { // if old table was defined if ($old_table != null) { // is this the right old table? if (strcasecmp($table['name'], $old_table['name']) != 0) { continue; } } // does the new schema contain the old table? if (!pgsql8_schema::contains_table($new_schema, $table['name'])) { // if the table was renamed, don't drop it if (!dbsteward::$ignore_oldnames && pgsql8_schema::table_formerly_known_as(dbsteward::$new_database, $new_schema, $table, $reformed_schema, $reformed_table)) { $old_table_name = pgsql8::get_quoted_schema_name($new_schema['name']) . '.' . pgsql8::get_quoted_table_name($table['name']); $reformed_table_name = pgsql8::get_quoted_schema_name($reformed_schema['name']) . '.' . pgsql8::get_quoted_table_name($reformed_table['name']); $ofs->write("-- DROP TABLE {$old_table_name} omitted: new table {$reformed_table_name} indicates it is her replacement\n"); } else { $ofs->write(pgsql8_table::get_drop_sql($old_schema, $table) . "\n"); } } } } }