migrations/Version20221025140530.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 Version20221025140530 extends AbstractMigration
  8. {
  9.     public function getDescription(): string
  10.     {
  11.         return 'Adds mycmcm_user table.';
  12.     }
  13.     public function up(Schema $schema): void
  14.     {
  15.         $this->skipIf(
  16.             true === $schema->hasTable('mycmcm_user'),
  17.             'The mycmcm_user table was already created!'
  18.         );
  19.         $table $schema->createTable('mycmcm_user');
  20.         $table->addColumn('id'Types::GUID)->setNotnull(true);
  21.         $table->addColumn('first_name'Types::STRING, ['length' => 80])->setNotnull(false)->setDefault(null);
  22.         $table->addColumn('last_name'Types::STRING, ['length' => 80])->setNotnull(false)->setDefault(null);
  23.         $table->addColumn('avatar_image_url'Types::STRING, ['length' => 80])->setNotnull(false)->setDefault(null);
  24.         $table->addColumn('email'Types::STRING, ['length' => 80])->setNotnull(true);
  25.         $table->addColumn('phone'Types::STRING, ['length' => 80])->setNotnull(false)->setDefault(null);
  26.         $table->addColumn('roles'Types::JSON)->setNotnull(true);
  27.         $table->addColumn('created_at'Types::DATE_IMMUTABLE)->setNotnull(true);
  28.         $table->addColumn('last_modified_at'Types::DATE_IMMUTABLE)->setNotnull(true);
  29.         $table->addColumn('deleted_at'Types::DATE_IMMUTABLE)->setNotnull(false)->setDefault(null);
  30.         $table->addColumn('password'Types::STRING, ['length' => 80])->setNotnull(true);
  31.         $table->addColumn('validated_at'Types::DATE_IMMUTABLE)->setNotnull(false)->setDefault(null);
  32.         $table->addColumn('reset_requested_at'Types::DATE_IMMUTABLE)->setNotnull(false)->setDefault(null);
  33.         $table->addColumn('reset_token'Types::GUID)->setNotnull(false)->setDefault(null);
  34.         $table->setPrimaryKey(['id']);
  35.         $table->addIndex(['reset_token'], 'idx_mycmcm_user_reset_token');
  36.     }
  37.     public function down(Schema $schema): void
  38.     {
  39.         $this->skipIf(
  40.             false === $schema->hasTable('mycmcm_user'),
  41.             'The mycmcm_user tables was already removed!'
  42.         );
  43.         $schema->dropTable('mycmcm_user');
  44.     }
  45. }