public function renameTable($old_table_name, $new_table_name, Schema $new_schema) { $oldTable = $this->getTable($old_table_name); if ($oldTable->exists()) { if (!$oldTable->temporary()) { $newTable = $new_schema->createTable($new_table_name, $oldTable->getColumns()); copy($oldTable->dataFile->getPath(), $newTable->dataFile->getPath()); copy($oldTable->dataLockFile->getPath(), $newTable->dataLockFile->getPath()); $this->dropTable($old_table_name); } else { $new_schema->loadedTables[$new_table_name] = $this->loadedTables[$old_table_name]; unset($this->loadedTables[$old_table_name]); } return true; } else { return false; } }
public function testDropTableTemp() { $name = 'blah'; $schema = new Schema($this->db, 'myschema'); $schema->create(); $schema->createTable($name, self::$columns, true); $passed = $schema->dropTable($name); $this->assertTrue($passed); $table = $schema->getTable($name); $this->assertFalse($table->exists()); }