for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Cycle\Migrations\Operation\Table;
use Cycle\Database\Driver\HandlerInterface;
use Cycle\Migrations\CapsuleInterface;
use Cycle\Migrations\Exception\Operation\TableException;
use Cycle\Migrations\Operation\AbstractOperation;
final class Create extends AbstractOperation
{
/**
* {@inheritdoc}
*/
public function execute(CapsuleInterface $capsule): void
$schema = $capsule->getSchema($this->getTable());
$database = $this->database ?? '[default]';
database
Cycle\Migrations\Operation\Table\Create
if ($schema->exists()) {
throw new TableException(
"Unable to create table '{$database}'.'{$this->getTable()}', table already exists"
);
}
if (empty($schema->getColumns())) {
"Unable to create table '{$database}'.'{$this->getTable()}', no columns were added"
$schema->save(HandlerInterface::DO_ALL);