migrations/Identity/Version20200227100835_UserPassport.php line 1
<?php
declare(strict_types=1);
namespace DoctrineMigrations\Identity;
use App\Doctrine\Type\Identity\PassportType;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200227100835_UserPassport extends AbstractMigration
{
public function getDescription(): string
{
return 'Create identity table';
}
public function up(Schema $schema): void
{
$passportType = PassportType::getName();
$this->addSql("CREATE TABLE user_passport (
id SERIAL PRIMARY KEY,
owner_id INTEGER NOT NULL REFERENCES public.user (id),
value CHARACTER VARYING NOT NULL,
verified BOOLEAN,
is_main BOOLEAN,
type {$passportType} NOT NULL,
created_by INTEGER REFERENCES public.user (id),
updated_by INTEGER REFERENCES public.user (id),
created_at TIMESTAMP(0) WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP(0) WITH TIME ZONE,
deleted_at TIMESTAMP(0) WITH TIME ZONE,
CONSTRAINT user_passport_value_key UNIQUE (value)
)");
$this->addSql("CREATE INDEX user_passport_owner_id_idx ON user_passport (owner_id)");
$this->addSql("CREATE INDEX user_passport_created_by_idx ON user_passport (created_by)");
$this->addSql("CREATE INDEX user_passport_updated_by_idx ON user_passport (updated_by)");
}
public function down(Schema $schema): void
{
$this->addSql("DROP TABLE IF EXISTS user_passport");
}
}