migrations/Version20220930145422.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\Migrations\AbstractMigration;
  7. final class Version20220930145422 extends AbstractMigration
  8. {
  9.     public function getDescription(): string
  10.     {
  11.         return 'New table: autocomplete_address';
  12.     }
  13.     public function up(Schema $schema): void
  14.     {
  15.         $this->skipIf(
  16.             true === $schema->hasTable('autocomplete_address'),
  17.             'The autocomplete_address table already exists!'
  18.         );
  19.         $table $schema->createTable('autocomplete_address');
  20.         $table->addColumn('postal_code'Types::STRING, ['length' => 40])->setNotnull(true);
  21.         $table->addColumn('street'Types::STRING, ['length' => 40])->setNotnull(true);
  22.         $table->addColumn('city'Types::STRING, ['length' => 40])->setNotnull(true);
  23.         $table->addColumn('district'Types::STRING, ['length' => 40])->setNotnull(true);
  24.         $table->addColumn('department'Types::STRING, ['length' => 40])->setNotnull(true);
  25.         $table->addColumn('commune'Types::STRING, ['length' => 40])->setNotnull(true);
  26.         $table->addIndex(['postal_code'], 'address_postalcode_idx');
  27.         $table->setPrimaryKey(['postal_code''street''city']);
  28.     }
  29.     public function down(Schema $schema): void
  30.     {
  31.         $this->skipIf(
  32.             false === $schema->hasTable('autocomplete_address'),
  33.             'The autocomplete_address table has already been removed!'
  34.         );
  35.         $schema->dropTable('autocomplete_address');
  36.     }
  37. }