<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20220930145422 extends AbstractMigration
{
public function getDescription(): string
{
return 'New table: autocomplete_address';
}
public function up(Schema $schema): void
{
$this->skipIf(
true === $schema->hasTable('autocomplete_address'),
'The autocomplete_address table already exists!'
);
$table = $schema->createTable('autocomplete_address');
$table->addColumn('postal_code', Types::STRING, ['length' => 40])->setNotnull(true);
$table->addColumn('street', Types::STRING, ['length' => 40])->setNotnull(true);
$table->addColumn('city', Types::STRING, ['length' => 40])->setNotnull(true);
$table->addColumn('district', Types::STRING, ['length' => 40])->setNotnull(true);
$table->addColumn('department', Types::STRING, ['length' => 40])->setNotnull(true);
$table->addColumn('commune', Types::STRING, ['length' => 40])->setNotnull(true);
$table->addIndex(['postal_code'], 'address_postalcode_idx');
$table->setPrimaryKey(['postal_code', 'street', 'city']);
}
public function down(Schema $schema): void
{
$this->skipIf(
false === $schema->hasTable('autocomplete_address'),
'The autocomplete_address table has already been removed!'
);
$schema->dropTable('autocomplete_address');
}
}