Conditions | 3 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
37 | public function execute(CapsuleInterface $capsule): void |
||
38 | { |
||
39 | $schema = $capsule->getSchema($this->getTable()); |
||
40 | $database = $this->database ?? '[default]'; |
||
|
|||
41 | |||
42 | if (!$schema->exists()) { |
||
43 | throw new TableException( |
||
44 | "Unable to rename table '{$database}'.'{$this->getTable()}', table does not exists" |
||
45 | ); |
||
46 | } |
||
47 | |||
48 | if ($capsule->getDatabase()->hasTable($this->newName)) { |
||
49 | throw new TableException( |
||
50 | "Unable to rename table '{$database}'.'{$this->getTable()}', table '{$this->newName}' already exists" |
||
51 | ); |
||
52 | } |
||
53 | |||
54 | $schema->setName($this->newName); |
||
55 | $schema->save(HandlerInterface::DO_ALL); |
||
56 | } |
||
58 |