migrations/Version20231011110332.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 Version20231011110332 extends AbstractMigration
  8. {
  9.     public function getDescription(): string
  10.     {
  11.         return 'Add tables_settings for the employee table';
  12.     }
  13.     public function up(Schema $schema): void
  14.     {
  15.         $this->skipIf(
  16.             true === $schema->getTable('employee')->hasColumn('tables_settings'),
  17.             'The field tables_settings is already created in the employee table!'
  18.         );
  19.         $schema->getTable('employee')
  20.             ->addColumn('tables_settings'Types::JSON, ['notnull' => false]);
  21.     }
  22.     public function down(Schema $schema): void
  23.     {
  24.         $this->skipIf(
  25.             false === $schema->getTable('employee')->hasColumn('tables_settings'),
  26.             'The field tables_settings doesn\'t exist on the employee table! '
  27.         );
  28.         $schema->getTable('employee')->dropColumn('tables_settings');
  29.     }
  30. }