mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
48 lines
1.7 KiB
PHP
48 lines
1.7 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\Main;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
use Doctrine\ORM\Query\ResultSetMapping;
|
|
use RuntimeException;
|
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
|
|
use function count;
|
|
|
|
/**
|
|
* Migrate association from
|
|
* ManyToMany between PermissionGroup <-> GroupCenter
|
|
* to
|
|
* ManyToOne : a GroupCenter can have only one PermissionGroup.
|
|
*/
|
|
class Version20150821105642 extends AbstractMigration
|
|
{
|
|
public function down(Schema $schema): void
|
|
{
|
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
|
|
|
$this->addSql('ALTER TABLE group_centers DROP CONSTRAINT FK_A14D8F3D447BBB3B');
|
|
$this->addSql('DROP INDEX IDX_A14D8F3D447BBB3B');
|
|
$this->addSql('ALTER TABLE group_centers DROP permissionGroup_id');
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
|
|
|
$this->addSql('ALTER TABLE group_centers ADD permissionsGroup_id INT DEFAULT NULL');
|
|
$this->addSql('ALTER TABLE group_centers ADD CONSTRAINT FK_A14D8F3D447BBB3B FOREIGN KEY (permissionsGroup_id) REFERENCES permission_groups (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
|
$this->addSql('CREATE INDEX IDX_A14D8F3D447BBB3B ON group_centers (permissionsGroup_id)');
|
|
}
|
|
}
|