<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20220929150415 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this->skipIf(
true === $schema->hasTable('site'),
'The site and public_api_user tables were already created!'
);
$table = $schema->createTable('site');
$table->addColumn('id', Types::GUID)->setNotnull(true);
$table->addColumn('name', Types::STRING, ['length' => 120]);
$table->addColumn('url', Types::STRING, ['length' => 250]);
$table->setPrimaryKey(['id']);
$table = $schema->createTable('public_api_user');
$table->addColumn('id', Types::GUID)->setNotnull(true);
$table->addColumn('site_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->setPrimaryKey(['id']);
$table->addForeignKeyConstraint('site', ['site_id'], ['id'], [], 'fk_public_api_user_site');
}
public function down(Schema $schema): void
{
$this->skipIf(
false === $schema->hasTable('site'),
'The site and public_api_user tables were already removed!'
);
$schema->dropTable('public_api_user');
$schema->dropTable('site');
}
}