Files
chill-bundles/src/Bundle/ChillEventBundle/migrations/Version20250702144312.php

80 lines
3.1 KiB
PHP

<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\Migrations\Event;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20250702144312 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add internal and external animators to event entity';
}
public function up(Schema $schema): void
{
$this->addSql(<<<'SQL'
CREATE TABLE chill_event_animatorsintern (event_id INT NOT NULL, user_id INT NOT NULL, PRIMARY KEY(event_id, user_id))
SQL);
$this->addSql(<<<'SQL'
CREATE INDEX IDX_E699558771F7E88B ON chill_event_animatorsintern (event_id)
SQL);
$this->addSql(<<<'SQL'
CREATE INDEX IDX_E6995587A76ED395 ON chill_event_animatorsintern (user_id)
SQL);
$this->addSql(<<<'SQL'
CREATE TABLE chill_event_animatorsextern (event_id INT NOT NULL, thirdparty_id INT NOT NULL, PRIMARY KEY(event_id, thirdparty_id))
SQL);
$this->addSql(<<<'SQL'
CREATE INDEX IDX_7EFBF7DE71F7E88B ON chill_event_animatorsextern (event_id)
SQL);
$this->addSql(<<<'SQL'
CREATE INDEX IDX_7EFBF7DEC7D3A8E6 ON chill_event_animatorsextern (thirdparty_id)
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE chill_event_animatorsintern ADD CONSTRAINT FK_E699558771F7E88B FOREIGN KEY (event_id) REFERENCES chill_event_event (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE chill_event_animatorsintern ADD CONSTRAINT FK_E6995587A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE chill_event_animatorsextern ADD CONSTRAINT FK_7EFBF7DE71F7E88B FOREIGN KEY (event_id) REFERENCES chill_event_event (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE chill_event_animatorsextern ADD CONSTRAINT FK_7EFBF7DEC7D3A8E6 FOREIGN KEY (thirdparty_id) REFERENCES chill_3party.third_party (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE
SQL);
}
public function down(Schema $schema): void
{
$this->addSql(<<<'SQL'
ALTER TABLE chill_event_animatorsintern DROP CONSTRAINT FK_E699558771F7E88B
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE chill_event_animatorsintern DROP CONSTRAINT FK_E6995587A76ED395
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE chill_event_animatorsextern DROP CONSTRAINT FK_7EFBF7DE71F7E88B
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE chill_event_animatorsextern DROP CONSTRAINT FK_7EFBF7DEC7D3A8E6
SQL);
$this->addSql(<<<'SQL'
DROP TABLE chill_event_animatorsintern
SQL);
$this->addSql(<<<'SQL'
DROP TABLE chill_event_animatorsextern
SQL);
}
}