Skip to content

Commit 45e0784

Browse files
committed
Rename table using the editor
1 parent 98a18fd commit 45e0784

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

src/Schema/Schema.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -300,13 +300,10 @@ public function createTable(string $name): Table
300300
*/
301301
public function renameTable(string $oldName, string $newName): self
302302
{
303-
$table = $this->getTable($oldName);
304-
305-
$identifier = new Identifier($newName);
306-
307-
$table->_name = $identifier->_name;
308-
$table->_namespace = $identifier->_namespace;
309-
$table->_quoted = $identifier->_quoted;
303+
$table = $this->getTable($oldName)
304+
->edit()
305+
->setName($newName)
306+
->create();
310307

311308
$this->dropTable($oldName);
312309
$this->_addTable($table);

tests/Schema/SchemaTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,13 @@ public function testCreateTableTwiceThrowsException(): void
7171

7272
public function testRenameTable(): void
7373
{
74-
$tableName = 'foo';
75-
$table = new Table($tableName);
76-
$schema = new Schema([$table]);
74+
$table = new Table('foo');
75+
$schema = new Schema([$table]);
7776

7877
self::assertTrue($schema->hasTable('foo'));
7978
$schema->renameTable('foo', 'bar');
8079
self::assertFalse($schema->hasTable('foo'));
8180
self::assertTrue($schema->hasTable('bar'));
82-
self::assertSame($table, $schema->getTable('bar'));
8381
}
8482

8583
public function testDropTable(): void

0 commit comments

Comments
 (0)