<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20221025140530 extends AbstractMigration
{
public function getDescription(): string
{
return 'Adds mycmcm_user table.';
}
public function up(Schema $schema): void
{
$this->skipIf(
true === $schema->hasTable('mycmcm_user'),
'The mycmcm_user table was already created!'
);
$table = $schema->createTable('mycmcm_user');
$table->addColumn('id', Types::GUID)->setNotnull(true);
$table->addColumn('first_name', Types::STRING, ['length' => 80])->setNotnull(false)->setDefault(null);
$table->addColumn('last_name', Types::STRING, ['length' => 80])->setNotnull(false)->setDefault(null);
$table->addColumn('avatar_image_url', Types::STRING, ['length' => 80])->setNotnull(false)->setDefault(null);
$table->addColumn('email', Types::STRING, ['length' => 80])->setNotnull(true);
$table->addColumn('phone', Types::STRING, ['length' => 80])->setNotnull(false)->setDefault(null);
$table->addColumn('roles', Types::JSON)->setNotnull(true);
$table->addColumn('created_at', Types::DATE_IMMUTABLE)->setNotnull(true);
$table->addColumn('last_modified_at', Types::DATE_IMMUTABLE)->setNotnull(true);
$table->addColumn('deleted_at', Types::DATE_IMMUTABLE)->setNotnull(false)->setDefault(null);
$table->addColumn('password', Types::STRING, ['length' => 80])->setNotnull(true);
$table->addColumn('validated_at', Types::DATE_IMMUTABLE)->setNotnull(false)->setDefault(null);
$table->addColumn('reset_requested_at', Types::DATE_IMMUTABLE)->setNotnull(false)->setDefault(null);
$table->addColumn('reset_token', Types::GUID)->setNotnull(false)->setDefault(null);
$table->setPrimaryKey(['id']);
$table->addIndex(['reset_token'], 'idx_mycmcm_user_reset_token');
}
public function down(Schema $schema): void
{
$this->skipIf(
false === $schema->hasTable('mycmcm_user'),
'The mycmcm_user tables was already removed!'
);
$schema->dropTable('mycmcm_user');
}
}