<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20190824083121 extends AbstractMigration
{
public function getDescription(): string
{
return 'Join table for projects and users';
}
/**
* @throws \Doctrine\DBAL\DBALException
*/
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE TABLE project_user (
project_id UUID NOT NULL,
user_id UUID NOT NULL,
PRIMARY KEY(project_id, user_id))');
$this->addSql('CREATE INDEX IDX_B4021E51166D1F9C ON project_user (project_id)');
$this->addSql('CREATE INDEX IDX_B4021E51A76ED395 ON project_user (user_id)');
$this->addSql('COMMENT ON COLUMN project_user.project_id IS \'(DC2Type:uuid)\'');
$this->addSql('COMMENT ON COLUMN project_user.user_id IS \'(DC2Type:uuid)\'');
$this->addSql('ALTER TABLE project_user ADD CONSTRAINT FK_B4021E51166D1F9C FOREIGN KEY (project_id) REFERENCES tmetric_project (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE project_user ADD CONSTRAINT FK_B4021E51A76ED395 FOREIGN KEY (user_id) REFERENCES tmetric_user (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
}
/**
* @throws \Doctrine\DBAL\DBALException
*/
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('DROP TABLE project_user');
}
}