<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20240908163000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add mycmcm_user_invitation table';
}
public function up(Schema $schema): void
{
$this->skipIf(
true === $schema->hasTable('mycmcm_user_invitation'),
'The mycmcm_user_invitation table was already added!'
);
$table = $schema->createTable('mycmcm_user_invitation');
$table->addColumn('id', Types::GUID)->setNotnull(true);
$table->addColumn('created_at', Types::DATETIME_IMMUTABLE)->setNotnull(true);
$table->addColumn('affiliate_number', Types::STRING, ['length' => 255, 'notnull' => true]);
$table->addColumn('birth_date', Types::DATETIME_IMMUTABLE, ['notnull' => true]);
$table->addColumn('verification_code', Types::STRING, ['length' => 20, 'notnull' => true]);
$table->addColumn('document_created_at', Types::DATETIME_IMMUTABLE, ['notnull' => false, 'default' => null]);
$table->addColumn('my_cmcm_user_id', Types::GUID)->setNotnull(false)->setdefault(null);
$table->setPrimaryKey(['id']);
$table->addIndex(['affiliate_number'], 'idx_mycmcm_user_invitation_affiliate_number');
$myCmcmUserTable = $schema->getTable('mycmcm_user');
$table->addForeignKeyConstraint(
$myCmcmUserTable,
['my_cmcm_user_id'],
['id'],
[],
'fk_mycmcm_user_invitation_mycmcm_user'
);
}
public function down(Schema $schema): void
{
$this->skipIf(
false === $schema->hasTable('mycmcm_user_invitation'),
'The mycmcm_user_invitation table was already removed!'
);
$schema->dropTable('mycmcm_user_invitation');
}
}