mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 19:13:49 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,21 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
class Version20100000000000 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('CREATE EXTENSION IF NOT EXISTS unaccent');
|
||||
$this->addSql('CREATE EXTENSION IF NOT EXISTS pg_trgm');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@@ -1,56 +1,62 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Insert Main Bundle table and indexes
|
||||
* Insert Main Bundle table and indexes.
|
||||
*/
|
||||
class Version20141128194409 extends AbstractMigration
|
||||
{
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql("CREATE TABLE Country (id INT NOT NULL, name JSON NOT NULL, countryCode VARCHAR(3) NOT NULL, PRIMARY KEY(id));");
|
||||
$this->addSql("CREATE TABLE centers (id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id));");
|
||||
$this->addSql("CREATE TABLE Language (id VARCHAR(255) NOT NULL, name JSON NOT NULL, PRIMARY KEY(id));");
|
||||
$this->addSql("CREATE TABLE group_centers (id INT NOT NULL, center_id INT DEFAULT NULL, PRIMARY KEY(id));");
|
||||
$this->addSql("CREATE INDEX IDX_A14D8F3D5932F377 ON group_centers (center_id);");
|
||||
$this->addSql("CREATE TABLE groupcenter_permissionsgroup (groupcenter_id INT NOT NULL, permissionsgroup_id INT NOT NULL, PRIMARY KEY(groupcenter_id, permissionsgroup_id));");
|
||||
$this->addSql("CREATE INDEX IDX_55DFEC607EC2FA68 ON groupcenter_permissionsgroup (groupcenter_id);");
|
||||
$this->addSql("CREATE INDEX IDX_55DFEC606FA97D46 ON groupcenter_permissionsgroup (permissionsgroup_id);");
|
||||
$this->addSql("CREATE TABLE role_scopes (id INT NOT NULL, scope_id INT DEFAULT NULL, role VARCHAR(255) NOT NULL, PRIMARY KEY(id));");
|
||||
$this->addSql("CREATE INDEX IDX_AFF20281682B5931 ON role_scopes (scope_id);");
|
||||
$this->addSql("CREATE TABLE permission_groups (id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id));");
|
||||
$this->addSql("CREATE TABLE permissionsgroup_rolescope (permissionsgroup_id INT NOT NULL, rolescope_id INT NOT NULL, PRIMARY KEY(permissionsgroup_id, rolescope_id));");
|
||||
$this->addSql("CREATE INDEX IDX_B22441DC6FA97D46 ON permissionsgroup_rolescope (permissionsgroup_id);");
|
||||
$this->addSql("CREATE INDEX IDX_B22441DCA0AE1DB7 ON permissionsgroup_rolescope (rolescope_id);");
|
||||
$this->addSql("CREATE TABLE users (id INT NOT NULL, username VARCHAR(80) NOT NULL, password VARCHAR(255) NOT NULL, salt VARCHAR(255) DEFAULT NULL, enabled BOOLEAN NOT NULL, locked BOOLEAN NOT NULL, PRIMARY KEY(id));");
|
||||
$this->addSql("CREATE TABLE user_groupcenter (user_id INT NOT NULL, groupcenter_id INT NOT NULL, PRIMARY KEY(user_id, groupcenter_id));");
|
||||
$this->addSql("CREATE INDEX IDX_33FFE54AA76ED395 ON user_groupcenter (user_id);");
|
||||
$this->addSql("CREATE INDEX IDX_33FFE54A7EC2FA68 ON user_groupcenter (groupcenter_id);");
|
||||
$this->addSql("CREATE TABLE scopes (id INT NOT NULL, name JSON NOT NULL, PRIMARY KEY(id));");
|
||||
$this->addSql("CREATE SEQUENCE Country_id_seq INCREMENT BY 1 MINVALUE 1 START 1;");
|
||||
$this->addSql("CREATE SEQUENCE centers_id_seq INCREMENT BY 1 MINVALUE 1 START 1;");
|
||||
$this->addSql("CREATE SEQUENCE group_centers_id_seq INCREMENT BY 1 MINVALUE 1 START 1;");
|
||||
$this->addSql("CREATE SEQUENCE role_scopes_id_seq INCREMENT BY 1 MINVALUE 1 START 1;");
|
||||
$this->addSql("CREATE SEQUENCE permission_groups_id_seq INCREMENT BY 1 MINVALUE 1 START 1;");
|
||||
$this->addSql("CREATE SEQUENCE users_id_seq INCREMENT BY 1 MINVALUE 1 START 1;");
|
||||
$this->addSql("CREATE SEQUENCE scopes_id_seq INCREMENT BY 1 MINVALUE 1 START 1;");
|
||||
$this->addSql("ALTER TABLE group_centers ADD CONSTRAINT FK_A14D8F3D5932F377 FOREIGN KEY (center_id) REFERENCES centers (id) NOT DEFERRABLE INITIALLY IMMEDIATE;");
|
||||
$this->addSql("ALTER TABLE groupcenter_permissionsgroup ADD CONSTRAINT FK_55DFEC607EC2FA68 FOREIGN KEY (groupcenter_id) REFERENCES group_centers (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;");
|
||||
$this->addSql("ALTER TABLE groupcenter_permissionsgroup ADD CONSTRAINT FK_55DFEC606FA97D46 FOREIGN KEY (permissionsgroup_id) REFERENCES permission_groups (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;");
|
||||
$this->addSql("ALTER TABLE role_scopes ADD CONSTRAINT FK_AFF20281682B5931 FOREIGN KEY (scope_id) REFERENCES scopes (id) NOT DEFERRABLE INITIALLY IMMEDIATE;");
|
||||
$this->addSql("ALTER TABLE permissionsgroup_rolescope ADD CONSTRAINT FK_B22441DC6FA97D46 FOREIGN KEY (permissionsgroup_id) REFERENCES permission_groups (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;");
|
||||
$this->addSql("ALTER TABLE permissionsgroup_rolescope ADD CONSTRAINT FK_B22441DCA0AE1DB7 FOREIGN KEY (rolescope_id) REFERENCES role_scopes (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;");
|
||||
$this->addSql("ALTER TABLE user_groupcenter ADD CONSTRAINT FK_33FFE54AA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;");
|
||||
$this->addSql("ALTER TABLE user_groupcenter ADD CONSTRAINT FK_33FFE54A7EC2FA68 FOREIGN KEY (groupcenter_id) REFERENCES group_centers (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;");
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('CREATE TABLE Country (id INT NOT NULL, name JSON NOT NULL, countryCode VARCHAR(3) NOT NULL, PRIMARY KEY(id));');
|
||||
$this->addSql('CREATE TABLE centers (id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id));');
|
||||
$this->addSql('CREATE TABLE Language (id VARCHAR(255) NOT NULL, name JSON NOT NULL, PRIMARY KEY(id));');
|
||||
$this->addSql('CREATE TABLE group_centers (id INT NOT NULL, center_id INT DEFAULT NULL, PRIMARY KEY(id));');
|
||||
$this->addSql('CREATE INDEX IDX_A14D8F3D5932F377 ON group_centers (center_id);');
|
||||
$this->addSql('CREATE TABLE groupcenter_permissionsgroup (groupcenter_id INT NOT NULL, permissionsgroup_id INT NOT NULL, PRIMARY KEY(groupcenter_id, permissionsgroup_id));');
|
||||
$this->addSql('CREATE INDEX IDX_55DFEC607EC2FA68 ON groupcenter_permissionsgroup (groupcenter_id);');
|
||||
$this->addSql('CREATE INDEX IDX_55DFEC606FA97D46 ON groupcenter_permissionsgroup (permissionsgroup_id);');
|
||||
$this->addSql('CREATE TABLE role_scopes (id INT NOT NULL, scope_id INT DEFAULT NULL, role VARCHAR(255) NOT NULL, PRIMARY KEY(id));');
|
||||
$this->addSql('CREATE INDEX IDX_AFF20281682B5931 ON role_scopes (scope_id);');
|
||||
$this->addSql('CREATE TABLE permission_groups (id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id));');
|
||||
$this->addSql('CREATE TABLE permissionsgroup_rolescope (permissionsgroup_id INT NOT NULL, rolescope_id INT NOT NULL, PRIMARY KEY(permissionsgroup_id, rolescope_id));');
|
||||
$this->addSql('CREATE INDEX IDX_B22441DC6FA97D46 ON permissionsgroup_rolescope (permissionsgroup_id);');
|
||||
$this->addSql('CREATE INDEX IDX_B22441DCA0AE1DB7 ON permissionsgroup_rolescope (rolescope_id);');
|
||||
$this->addSql('CREATE TABLE users (id INT NOT NULL, username VARCHAR(80) NOT NULL, password VARCHAR(255) NOT NULL, salt VARCHAR(255) DEFAULT NULL, enabled BOOLEAN NOT NULL, locked BOOLEAN NOT NULL, PRIMARY KEY(id));');
|
||||
$this->addSql('CREATE TABLE user_groupcenter (user_id INT NOT NULL, groupcenter_id INT NOT NULL, PRIMARY KEY(user_id, groupcenter_id));');
|
||||
$this->addSql('CREATE INDEX IDX_33FFE54AA76ED395 ON user_groupcenter (user_id);');
|
||||
$this->addSql('CREATE INDEX IDX_33FFE54A7EC2FA68 ON user_groupcenter (groupcenter_id);');
|
||||
$this->addSql('CREATE TABLE scopes (id INT NOT NULL, name JSON NOT NULL, PRIMARY KEY(id));');
|
||||
$this->addSql('CREATE SEQUENCE Country_id_seq INCREMENT BY 1 MINVALUE 1 START 1;');
|
||||
$this->addSql('CREATE SEQUENCE centers_id_seq INCREMENT BY 1 MINVALUE 1 START 1;');
|
||||
$this->addSql('CREATE SEQUENCE group_centers_id_seq INCREMENT BY 1 MINVALUE 1 START 1;');
|
||||
$this->addSql('CREATE SEQUENCE role_scopes_id_seq INCREMENT BY 1 MINVALUE 1 START 1;');
|
||||
$this->addSql('CREATE SEQUENCE permission_groups_id_seq INCREMENT BY 1 MINVALUE 1 START 1;');
|
||||
$this->addSql('CREATE SEQUENCE users_id_seq INCREMENT BY 1 MINVALUE 1 START 1;');
|
||||
$this->addSql('CREATE SEQUENCE scopes_id_seq INCREMENT BY 1 MINVALUE 1 START 1;');
|
||||
$this->addSql('ALTER TABLE group_centers ADD CONSTRAINT FK_A14D8F3D5932F377 FOREIGN KEY (center_id) REFERENCES centers (id) NOT DEFERRABLE INITIALLY IMMEDIATE;');
|
||||
$this->addSql('ALTER TABLE groupcenter_permissionsgroup ADD CONSTRAINT FK_55DFEC607EC2FA68 FOREIGN KEY (groupcenter_id) REFERENCES group_centers (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;');
|
||||
$this->addSql('ALTER TABLE groupcenter_permissionsgroup ADD CONSTRAINT FK_55DFEC606FA97D46 FOREIGN KEY (permissionsgroup_id) REFERENCES permission_groups (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;');
|
||||
$this->addSql('ALTER TABLE role_scopes ADD CONSTRAINT FK_AFF20281682B5931 FOREIGN KEY (scope_id) REFERENCES scopes (id) NOT DEFERRABLE INITIALLY IMMEDIATE;');
|
||||
$this->addSql('ALTER TABLE permissionsgroup_rolescope ADD CONSTRAINT FK_B22441DC6FA97D46 FOREIGN KEY (permissionsgroup_id) REFERENCES permission_groups (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;');
|
||||
$this->addSql('ALTER TABLE permissionsgroup_rolescope ADD CONSTRAINT FK_B22441DCA0AE1DB7 FOREIGN KEY (rolescope_id) REFERENCES role_scopes (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;');
|
||||
$this->addSql('ALTER TABLE user_groupcenter ADD CONSTRAINT FK_33FFE54AA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;');
|
||||
$this->addSql('ALTER TABLE user_groupcenter ADD CONSTRAINT FK_33FFE54A7EC2FA68 FOREIGN KEY (groupcenter_id) REFERENCES group_centers (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;');
|
||||
}
|
||||
}
|
||||
|
@@ -1,33 +1,136 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\ORM\Query\ResultSetMapping;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Migrate association from
|
||||
* Migrate association from
|
||||
* ManyToMany between PermissionGroup <-> GroupCenter
|
||||
* to
|
||||
* ManyToOne : a GroupCenter can have only one PermissionGroup
|
||||
*
|
||||
* @link https://redmine.champs-libres.coop/issues/578 The issue describing the move
|
||||
* ManyToOne : a GroupCenter can have only one PermissionGroup.
|
||||
*
|
||||
* @see https://redmine.champs-libres.coop/issues/578 The issue describing the move
|
||||
*/
|
||||
class Version20150821105642 extends AbstractMigration implements
|
||||
\Symfony\Component\DependencyInjection\ContainerAwareInterface
|
||||
class Version20150821105642 extends AbstractMigration implements \Symfony\Component\DependencyInjection\ContainerAwareInterface
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var ContainerInterface
|
||||
*/
|
||||
private $container;
|
||||
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
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 postUp(Schema $schema): void
|
||||
{
|
||||
/*
|
||||
* Before the upgrade to symfony version 4, this code worked.
|
||||
*
|
||||
* But it doesn't work any more after the migration and currently this
|
||||
* code should note be necessary.
|
||||
*
|
||||
* This code is kept for reference, and may be re-activated if needed, but
|
||||
* the probability that this will happens is near 0
|
||||
*/
|
||||
return;
|
||||
//transform data from groupcenter_permissionsgroup table
|
||||
$em = $this->container->get('doctrine.orm.entity_manager');
|
||||
|
||||
//get all existing associations
|
||||
$rsm = new ResultSetMapping();
|
||||
$rsm->addScalarResult('groupcenter_id', 'groupcenter_id');
|
||||
$rsm->addScalarResult('permissionsgroup_id', 'permissionsgroup_id');
|
||||
|
||||
$groupPermissionsAssociations = $em->createNativeQuery(
|
||||
'SELECT groupcenter_id, permissionsgroup_id '
|
||||
. 'FROM groupcenter_permissionsgroup',
|
||||
$rsm
|
||||
)
|
||||
->getScalarResult();
|
||||
|
||||
//update
|
||||
foreach ($groupPermissionsAssociations as $groupPermissionAssociation) {
|
||||
//get the corresponding groupCenter
|
||||
$rsmGroupCenter = new ResultSetMapping();
|
||||
$rsmGroupCenter->addScalarResult('id', 'id');
|
||||
$rsmGroupCenter->addScalarResult('permissionsGroup_id', 'permissionsGroup_id');
|
||||
$rsmGroupCenter->addScalarResult('center_id', 'center_id');
|
||||
|
||||
$groupCenters = $em->createNativeQuery(
|
||||
'SELECT id, permissionsGroup_id, center_id '
|
||||
. 'FROM group_centers '
|
||||
. 'WHERE id = :groupcenter_id AND permissionsGroup_id IS NULL',
|
||||
$rsmGroupCenter
|
||||
)
|
||||
->setParameter('groupcenter_id', $groupPermissionAssociation['groupcenter_id'])
|
||||
->getResult();
|
||||
|
||||
if (count($groupCenters) === 1) {
|
||||
// we have to update this group with the current association
|
||||
$em->getConnection()->executeUpdate(
|
||||
'UPDATE group_centers '
|
||||
. 'SET permissionsGroup_id = ? '
|
||||
. 'WHERE id = ?',
|
||||
[
|
||||
$groupPermissionAssociation['permissionsgroup_id'],
|
||||
$groupPermissionAssociation['groupcenter_id'], ]
|
||||
);
|
||||
} elseif (count($groupCenters) === 0) {
|
||||
// the association was multiple. We have to create a new group_center
|
||||
$rsmNewId = new ResultSetMapping();
|
||||
$rsmNewId->addScalarResult('new_id', 'new_id');
|
||||
$newId = $em->createNativeQuery(
|
||||
"select nextval('group_centers_id_seq') as new_id",
|
||||
$rsmNewId
|
||||
)
|
||||
->getSingleScalarResult();
|
||||
|
||||
$em->getConnection()->insert('group_centers', [
|
||||
'id' => $newId,
|
||||
'center_id' => $group_center['center_id'],
|
||||
'permissionsGroup_id' => $groupPermissionAssociation['permissionsgroup_id'],
|
||||
]);
|
||||
|
||||
// we have to link existing users to new created groupcenter
|
||||
$em->getConnection()->executeQuery('INSERT INTO user_groupcenter '
|
||||
. '(user_id, groupcenter_id) SELECT user_id, ' . $newId . ' '
|
||||
. 'FROM user_groupcenter WHERE groupcenter_id = '
|
||||
. $groupPermissionAssociation['groupcenter_id']);
|
||||
} else {
|
||||
throw new RuntimeException('Error in the data : we should not have two groupCenter '
|
||||
. 'with the same id !');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setContainer(?ContainerInterface $container = null)
|
||||
{
|
||||
if (null === $container) {
|
||||
throw new RuntimeException('Container is not provided. This migration '
|
||||
. 'need container to set a default center');
|
||||
}
|
||||
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
@@ -36,110 +139,5 @@ class Version20150821105642 extends AbstractMigration implements
|
||||
$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)');
|
||||
|
||||
}
|
||||
|
||||
public function postUp(Schema $schema): void
|
||||
{
|
||||
/*
|
||||
* Before the upgrade to symfony version 4, this code worked.
|
||||
*
|
||||
* But it doesn't work any more after the migration and currently this
|
||||
* code should note be necessary.
|
||||
*
|
||||
* This code is kept for reference, and may be re-activated if needed, but
|
||||
* the probability that this will happens is near 0
|
||||
*/
|
||||
return;
|
||||
|
||||
|
||||
//transform data from groupcenter_permissionsgroup table
|
||||
$em = $this->container->get('doctrine.orm.entity_manager');
|
||||
|
||||
//get all existing associations
|
||||
$rsm = new ResultSetMapping();
|
||||
$rsm->addScalarResult('groupcenter_id', 'groupcenter_id');
|
||||
$rsm->addScalarResult('permissionsgroup_id', 'permissionsgroup_id');
|
||||
|
||||
$groupPermissionsAssociations = $em->createNativeQuery(
|
||||
"SELECT groupcenter_id, permissionsgroup_id "
|
||||
. "FROM groupcenter_permissionsgroup",
|
||||
$rsm
|
||||
)
|
||||
->getScalarResult();
|
||||
|
||||
//update
|
||||
foreach ($groupPermissionsAssociations as $groupPermissionAssociation) {
|
||||
//get the corresponding groupCenter
|
||||
$rsmGroupCenter = new ResultSetMapping();
|
||||
$rsmGroupCenter->addScalarResult('id', 'id');
|
||||
$rsmGroupCenter->addScalarResult('permissionsGroup_id', 'permissionsGroup_id');
|
||||
$rsmGroupCenter->addScalarResult('center_id', 'center_id');
|
||||
|
||||
$groupCenters = $em->createNativeQuery("SELECT id, permissionsGroup_id, center_id "
|
||||
. "FROM group_centers "
|
||||
. "WHERE id = :groupcenter_id AND permissionsGroup_id IS NULL",
|
||||
$rsmGroupCenter)
|
||||
->setParameter('groupcenter_id', $groupPermissionAssociation['groupcenter_id'])
|
||||
->getResult();
|
||||
|
||||
if (count($groupCenters) === 1) {
|
||||
// we have to update this group with the current association
|
||||
$em->getConnection()->executeUpdate("UPDATE group_centers "
|
||||
. "SET permissionsGroup_id = ? "
|
||||
. "WHERE id = ?", array(
|
||||
$groupPermissionAssociation['permissionsgroup_id'],
|
||||
$groupPermissionAssociation['groupcenter_id'])
|
||||
);
|
||||
} elseif (count($groupCenters) === 0) {
|
||||
// the association was multiple. We have to create a new group_center
|
||||
$rsmNewId = new ResultSetMapping();
|
||||
$rsmNewId->addScalarResult('new_id', 'new_id');
|
||||
$newId = $em->createNativeQuery("select nextval('group_centers_id_seq') as new_id",
|
||||
$rsmNewId)
|
||||
->getSingleScalarResult();
|
||||
|
||||
$em->getConnection()->insert("group_centers", array(
|
||||
'id' => $newId,
|
||||
'center_id' => $group_center['center_id'],
|
||||
'permissionsGroup_id' => $groupPermissionAssociation['permissionsgroup_id']
|
||||
));
|
||||
|
||||
// we have to link existing users to new created groupcenter
|
||||
$em->getConnection()->executeQuery('INSERT INTO user_groupcenter '
|
||||
. '(user_id, groupcenter_id) SELECT user_id, '.$newId.' '
|
||||
. 'FROM user_groupcenter WHERE groupcenter_id = '
|
||||
.$groupPermissionAssociation['groupcenter_id']);
|
||||
} else {
|
||||
throw new \RuntimeException("Error in the data : we should not have two groupCenter "
|
||||
. "with the same id !");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
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 setContainer(\Symfony\Component\DependencyInjection\ContainerInterface $container = null)
|
||||
{
|
||||
if ($container === NULL) {
|
||||
throw new \RuntimeException('Container is not provided. This migration '
|
||||
. 'need container to set a default center');
|
||||
}
|
||||
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,39 +1,37 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* drop table groupcenter_permissionsgroup, not necessary after
|
||||
* 20150821105642
|
||||
* drop table groupcenter_permissionsgroup, not necessary after
|
||||
* 20150821105642.
|
||||
*/
|
||||
class Version20150821122935 extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
|
||||
$this->addSql('DROP TABLE groupcenter_permissionsgroup');
|
||||
$this->addSql('ALTER TABLE group_centers ALTER permissionsGroup_id SET NOT NULL');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE group_centers ALTER permissionsGroup_id SET DEFAULT NULL');
|
||||
$this->addSql('CREATE TABLE groupcenter_permissionsgroup (groupcenter_id INT NOT NULL, permissionsgroup_id INT NOT NULL, PRIMARY KEY(groupcenter_id, permissionsgroup_id))');
|
||||
$this->addSql('CREATE INDEX idx_55dfec607ec2fa68 ON groupcenter_permissionsgroup (groupcenter_id)');
|
||||
$this->addSql('CREATE INDEX idx_55dfec606fa97d46 ON groupcenter_permissionsgroup (permissionsgroup_id)');
|
||||
|
||||
|
||||
$this->addSql('ALTER TABLE groupcenter_permissionsgroup ADD CONSTRAINT fk_55dfec607ec2fa68 FOREIGN KEY (groupcenter_id) REFERENCES group_centers (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE groupcenter_permissionsgroup ADD CONSTRAINT fk_55dfec606fa97d46 FOREIGN KEY (permissionsgroup_id) REFERENCES permission_groups (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP TABLE groupcenter_permissionsgroup');
|
||||
$this->addSql('ALTER TABLE group_centers ALTER permissionsGroup_id SET NOT NULL');
|
||||
}
|
||||
}
|
||||
|
@@ -1,18 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add postal code and addresses
|
||||
* Add postal code and addresses.
|
||||
*/
|
||||
class Version20160310122322 extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
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 chill_main_address '
|
||||
. 'DROP CONSTRAINT FK_165051F6EECBFDF1');
|
||||
$this->addSql('DROP SEQUENCE chill_main_address_id_seq CASCADE');
|
||||
$this->addSql('DROP SEQUENCE chill_main_postal_code_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_main_address');
|
||||
$this->addSql('DROP TABLE chill_main_postal_code');
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
@@ -46,21 +62,5 @@ class Version20160310122322 extends AbstractMigration
|
||||
. 'FOREIGN KEY (country_id) '
|
||||
. 'REFERENCES Country (id) '
|
||||
. 'NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
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 chill_main_address '
|
||||
. 'DROP CONSTRAINT FK_165051F6EECBFDF1');
|
||||
$this->addSql('DROP SEQUENCE chill_main_address_id_seq CASCADE');
|
||||
$this->addSql('DROP SEQUENCE chill_main_postal_code_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_main_address');
|
||||
$this->addSql('DROP TABLE chill_main_postal_code');
|
||||
}
|
||||
}
|
||||
|
@@ -1,15 +1,32 @@
|
||||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Add index to postal code
|
||||
* Add index to postal code.
|
||||
*/
|
||||
final class Version20180703191509 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('DROP INDEX search_name_code');
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
@@ -17,17 +34,8 @@ final class Version20180703191509 extends AbstractMigration
|
||||
try {
|
||||
$this->addSql('CREATE EXTENSION IF NOT EXISTS pg_trgm');
|
||||
$this->addSql('CREATE INDEX search_name_code ON chill_main_postal_code USING GIN (LOWER(code) gin_trgm_ops, LOWER(label) gin_trgm_ops)');
|
||||
} catch (\Exception $e) {
|
||||
$this->skipIf(true, "Could not create extension pg_trgm");
|
||||
} catch (Exception $e) {
|
||||
$this->skipIf(true, 'Could not create extension pg_trgm');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
$this->addSql('DROP INDEX search_name_code');
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,16 +1,40 @@
|
||||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* add username and username canonical, email and email canonical columns
|
||||
* to users
|
||||
* to users.
|
||||
*/
|
||||
final class Version20180709181423 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('DROP INDEX UNIQ_1483A5E9F5A5DC32');
|
||||
$this->addSql('DROP INDEX UNIQ_1483A5E9885281E');
|
||||
$this->addSql('ALTER TABLE users DROP usernameCanonical');
|
||||
$this->addSql('ALTER TABLE users DROP email');
|
||||
$this->addSql('ALTER TABLE users DROP emailCanonical');
|
||||
$this->addSql('DROP TRIGGER canonicalize_user_on_insert ON users');
|
||||
$this->addSql('DROP FUNCTION canonicalize_user_on_insert()');
|
||||
$this->addSql('DROP TRIGGER canonicalize_user_on_update ON users');
|
||||
$this->addSql('DROP FUNCTION canonicalize_user_on_update()');
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
@@ -23,65 +47,53 @@ final class Version20180709181423 extends AbstractMigration
|
||||
$this->addSql('ALTER TABLE users ADD emailCanonical VARCHAR(150) DEFAULT NULL');
|
||||
$this->addSql('CREATE UNIQUE INDEX UNIQ_1483A5E9F5A5DC32 ON users (usernameCanonical)');
|
||||
$this->addSql('CREATE UNIQUE INDEX UNIQ_1483A5E9885281E ON users (emailCanonical)');
|
||||
|
||||
$this->addSql(<<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION canonicalize_user_on_update() RETURNS TRIGGER AS
|
||||
$BODY$
|
||||
BEGIN
|
||||
IF NEW.username <> OLD.username OR NEW.email <> OLD.email OR OLD.emailcanonical IS NULL OR OLD.usernamecanonical IS NULL THEN
|
||||
UPDATE users SET usernamecanonical=LOWER(UNACCENT(NEW.username)), emailcanonical=LOWER(UNACCENT(NEW.email)) WHERE id=NEW.id;
|
||||
END IF;
|
||||
|
||||
RETURN NEW;
|
||||
END;
|
||||
$BODY$ LANGUAGE PLPGSQL
|
||||
SQL
|
||||
$this->addSql(
|
||||
<<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION canonicalize_user_on_update() RETURNS TRIGGER AS
|
||||
$BODY$
|
||||
BEGIN
|
||||
IF NEW.username <> OLD.username OR NEW.email <> OLD.email OR OLD.emailcanonical IS NULL OR OLD.usernamecanonical IS NULL THEN
|
||||
UPDATE users SET usernamecanonical=LOWER(UNACCENT(NEW.username)), emailcanonical=LOWER(UNACCENT(NEW.email)) WHERE id=NEW.id;
|
||||
END IF;
|
||||
|
||||
RETURN NEW;
|
||||
END;
|
||||
$BODY$ LANGUAGE PLPGSQL
|
||||
SQL
|
||||
);
|
||||
|
||||
$this->addSql(<<<SQL
|
||||
CREATE TRIGGER canonicalize_user_on_update
|
||||
AFTER UPDATE
|
||||
ON users
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE canonicalize_user_on_update();
|
||||
SQL
|
||||
$this->addSql(
|
||||
<<<'SQL'
|
||||
CREATE TRIGGER canonicalize_user_on_update
|
||||
AFTER UPDATE
|
||||
ON users
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE canonicalize_user_on_update();
|
||||
SQL
|
||||
);
|
||||
|
||||
$this->addSql(<<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION canonicalize_user_on_insert() RETURNS TRIGGER AS
|
||||
$BODY$
|
||||
BEGIN
|
||||
UPDATE users SET usernamecanonical=LOWER(UNACCENT(NEW.username)), emailcanonical=LOWER(UNACCENT(NEW.email)) WHERE id=NEW.id;
|
||||
$this->addSql(
|
||||
<<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION canonicalize_user_on_insert() RETURNS TRIGGER AS
|
||||
$BODY$
|
||||
BEGIN
|
||||
UPDATE users SET usernamecanonical=LOWER(UNACCENT(NEW.username)), emailcanonical=LOWER(UNACCENT(NEW.email)) WHERE id=NEW.id;
|
||||
|
||||
RETURN NEW;
|
||||
END;
|
||||
$BODY$ LANGUAGE PLPGSQL;
|
||||
SQL
|
||||
RETURN NEW;
|
||||
END;
|
||||
$BODY$ LANGUAGE PLPGSQL;
|
||||
SQL
|
||||
);
|
||||
|
||||
$this->addSql(<<<SQL
|
||||
CREATE TRIGGER canonicalize_user_on_insert
|
||||
AFTER INSERT
|
||||
ON users
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE canonicalize_user_on_insert();
|
||||
SQL
|
||||
);
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
$this->addSql('DROP INDEX UNIQ_1483A5E9F5A5DC32');
|
||||
$this->addSql('DROP INDEX UNIQ_1483A5E9885281E');
|
||||
$this->addSql('ALTER TABLE users DROP usernameCanonical');
|
||||
$this->addSql('ALTER TABLE users DROP email');
|
||||
$this->addSql('ALTER TABLE users DROP emailCanonical');
|
||||
$this->addSql('DROP TRIGGER canonicalize_user_on_insert ON users');
|
||||
$this->addSql('DROP FUNCTION canonicalize_user_on_insert()');
|
||||
$this->addSql('DROP TRIGGER canonicalize_user_on_update ON users');
|
||||
$this->addSql('DROP FUNCTION canonicalize_user_on_update()');
|
||||
|
||||
$this->addSql(
|
||||
<<<'SQL'
|
||||
CREATE TRIGGER canonicalize_user_on_insert
|
||||
AFTER INSERT
|
||||
ON users
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE canonicalize_user_on_insert();
|
||||
SQL
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,13 @@
|
||||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
|
||||
@@ -10,16 +19,15 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
*/
|
||||
final class Version20180905101426 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE permission_groups DROP COLUMN flags');
|
||||
$this->addSql('ALTER TABLE group_centers ALTER permissionsgroup_id SET DEFAULT NULL');
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE permission_groups ADD flags JSONB DEFAULT \'[]\' NOT NULL');
|
||||
$this->addSql('ALTER TABLE group_centers ALTER permissionsgroup_id DROP NOT NULL');
|
||||
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE permission_groups DROP COLUMN flags');
|
||||
$this->addSql('ALTER TABLE group_centers ALTER permissionsgroup_id SET DEFAULT NULL');
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,13 @@
|
||||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
|
||||
@@ -6,38 +15,38 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Fix error with recursive trigger on update
|
||||
* Fix error with recursive trigger on update.
|
||||
*/
|
||||
final class Version20180911093642 extends AbstractMigration
|
||||
{
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql("DROP TRIGGER canonicalize_user_on_update ON users");
|
||||
|
||||
$this->addSql(<<<SQL
|
||||
CREATE TRIGGER canonicalize_user_on_update
|
||||
AFTER UPDATE
|
||||
ON users
|
||||
FOR EACH ROW
|
||||
WHEN (pg_trigger_depth() = 0)
|
||||
EXECUTE PROCEDURE canonicalize_user_on_update();
|
||||
SQL
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql("DROP TRIGGER canonicalize_user_on_update ON users");
|
||||
|
||||
$this->addSql(<<<SQL
|
||||
CREATE TRIGGER canonicalize_user_on_update
|
||||
AFTER UPDATE
|
||||
ON users
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE canonicalize_user_on_update();
|
||||
SQL
|
||||
);
|
||||
$this->addSql('DROP TRIGGER canonicalize_user_on_update ON users');
|
||||
|
||||
$this->addSql(
|
||||
<<<'SQL'
|
||||
CREATE TRIGGER canonicalize_user_on_update
|
||||
AFTER UPDATE
|
||||
ON users
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE canonicalize_user_on_update();
|
||||
SQL
|
||||
);
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP TRIGGER canonicalize_user_on_update ON users');
|
||||
|
||||
$this->addSql(
|
||||
<<<'SQL'
|
||||
CREATE TRIGGER canonicalize_user_on_update
|
||||
AFTER UPDATE
|
||||
ON users
|
||||
FOR EACH ROW
|
||||
WHEN (pg_trigger_depth() = 0)
|
||||
EXECUTE PROCEDURE canonicalize_user_on_update();
|
||||
SQL
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,13 @@
|
||||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
|
||||
@@ -6,17 +15,17 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add a field "isNoAddress" on addresses
|
||||
* Add a field "isNoAddress" on addresses.
|
||||
*/
|
||||
final class Version20200422122715 extends AbstractMigration
|
||||
{
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_main_address ADD isNoAddress BOOLEAN NOT NULL DEFAULT FALSE');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_main_address DROP isNoAddress');
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_main_address ADD isNoAddress BOOLEAN NOT NULL DEFAULT FALSE');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
@@ -12,18 +19,18 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
*/
|
||||
final class Version20210304085819 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE users DROP attributes');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE users ADD attributes JSONB DEFAULT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
{
|
||||
$this->addSql('ALTER TABLE users DROP attributes');
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,13 @@
|
||||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
|
||||
@@ -6,27 +15,26 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add custom data in address
|
||||
* Add custom data in address.
|
||||
*/
|
||||
final class Version20210308111926 extends AbstractMigration
|
||||
{
|
||||
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 chill_main_address ADD customs JSONB DEFAULT \'[]\'');
|
||||
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
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 chill_main_address DROP customs');
|
||||
}
|
||||
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return "Add custom data in addresses";
|
||||
return 'Add custom data in addresses';
|
||||
}
|
||||
|
||||
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 chill_main_address ADD customs JSONB DEFAULT \'[]\'');
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,13 @@
|
||||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
|
||||
@@ -6,19 +15,11 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Create the postgis extension
|
||||
* Create the postgis extension.
|
||||
*/
|
||||
final class Version20210414091001 extends AbstractMigration
|
||||
{
|
||||
public function up(Schema $schema) : void
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
$this->addSql('CREATE EXTENSION IF NOT EXISTS postgis;');
|
||||
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
@@ -27,6 +28,13 @@ final class Version20210414091001 extends AbstractMigration
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return "Enable the postgis extension in public schema";
|
||||
return 'Enable the postgis extension in public schema';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
$this->addSql('CREATE EXTENSION IF NOT EXISTS postgis;');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
@@ -12,28 +19,7 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
*/
|
||||
final class Version20210420115006 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
{
|
||||
return 'Add a Point data type and modify the Address entity';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_main_address RENAME COLUMN streetaddress1 TO street;');
|
||||
$this->addSql('ALTER TABLE chill_main_address RENAME COLUMN streetaddress2 TO streetNumber;');
|
||||
$this->addSql('ALTER TABLE chill_main_address ADD floor VARCHAR(16) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_main_address ADD corridor VARCHAR(16) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_main_address ADD steps VARCHAR(16) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_main_address ADD buildingName VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_main_address ADD flat VARCHAR(16) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_main_address ADD distribution VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_main_address ADD extra VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_main_address ADD validTo DATE DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_main_address ADD point geometry(POINT,4326) DEFAULT NULL');
|
||||
}
|
||||
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_main_address RENAME COLUMN street TO streetaddress1;');
|
||||
$this->addSql('ALTER TABLE chill_main_address RENAME COLUMN streetNumber TO streetaddress2;');
|
||||
@@ -47,4 +33,24 @@ final class Version20210420115006 extends AbstractMigration
|
||||
$this->addSql('ALTER TABLE chill_main_address DROP validTo');
|
||||
$this->addSql('ALTER TABLE chill_main_address DROP point');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add a Point data type and modify the Address entity';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_main_address RENAME COLUMN streetaddress1 TO street;');
|
||||
$this->addSql('ALTER TABLE chill_main_address RENAME COLUMN streetaddress2 TO streetNumber;');
|
||||
$this->addSql('ALTER TABLE chill_main_address ADD floor VARCHAR(16) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_main_address ADD corridor VARCHAR(16) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_main_address ADD steps VARCHAR(16) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_main_address ADD buildingName VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_main_address ADD flat VARCHAR(16) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_main_address ADD distribution VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_main_address ADD extra VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_main_address ADD validTo DATE DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_main_address ADD point geometry(POINT,4326) DEFAULT NULL');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
@@ -8,10 +15,16 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add a AddressReference table for storing authoritative address data
|
||||
* Add a AddressReference table for storing authoritative address data.
|
||||
*/
|
||||
final class Version20210503085107 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP SEQUENCE chill_main_address_reference_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_main_address_reference');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add a AddressReference table for storing authoritative address data';
|
||||
@@ -24,10 +37,4 @@ final class Version20210503085107 extends AbstractMigration
|
||||
$this->addSql('CREATE INDEX IDX_CA6C1BD7EECBFDF1 ON chill_main_address_reference (postcode_id)');
|
||||
$this->addSql('ALTER TABLE chill_main_address_reference ADD CONSTRAINT FK_CA6C1BD7EECBFDF1 FOREIGN KEY (postcode_id) REFERENCES chill_main_postal_code (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP SEQUENCE chill_main_address_reference_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_main_address_reference');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
@@ -8,10 +15,22 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add linkedToThirdParty field to Address
|
||||
* Add linkedToThirdParty field to Address.
|
||||
*/
|
||||
final class Version20210505153727 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_main_address DROP CONSTRAINT FK_165051F6114B8DD9');
|
||||
$this->addSql('DROP INDEX IDX_165051F6114B8DD9');
|
||||
$this->addSql('ALTER TABLE chill_main_address DROP linkedToThirdParty_id');
|
||||
$this->addSql('DROP TABLE IF EXISTS chill_main_address_legacy');
|
||||
$this->addSql('
|
||||
UPDATE chill_main_address
|
||||
SET validto = null;
|
||||
');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add linkedToThirdParty field to Address';
|
||||
@@ -43,16 +62,4 @@ final class Version20210505153727 extends AbstractMigration
|
||||
);
|
||||
');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_main_address DROP CONSTRAINT FK_165051F6114B8DD9');
|
||||
$this->addSql('DROP INDEX IDX_165051F6114B8DD9');
|
||||
$this->addSql('ALTER TABLE chill_main_address DROP linkedToThirdParty_id');
|
||||
$this->addSql('DROP TABLE IF EXISTS chill_main_address_legacy');
|
||||
$this->addSql('
|
||||
UPDATE chill_main_address
|
||||
SET validto = null;
|
||||
');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
@@ -8,10 +15,16 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Specify ON DELETE behaviour to handle deletion of parents in associated tables
|
||||
* Specify ON DELETE behaviour to handle deletion of parents in associated tables.
|
||||
*/
|
||||
final class Version20210525144016 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_main_address DROP CONSTRAINT fk_165051f6114b8dd9');
|
||||
$this->addSql('ALTER TABLE chill_main_address ADD CONSTRAINT fk_165051f6114b8dd9 FOREIGN KEY (linkedtothirdparty_id) REFERENCES chill_3party.third_party (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Specify ON DELETE behaviour to handle deletion of parents in associated tables';
|
||||
@@ -22,10 +35,4 @@ final class Version20210525144016 extends AbstractMigration
|
||||
$this->addSql('ALTER TABLE chill_main_address DROP CONSTRAINT FK_165051F6114B8DD9');
|
||||
$this->addSql('ALTER TABLE chill_main_address ADD CONSTRAINT FK_165051F6114B8DD9 FOREIGN KEY (linkedToThirdParty_id) REFERENCES chill_3party.third_party (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_main_address DROP CONSTRAINT fk_165051f6114b8dd9');
|
||||
$this->addSql('ALTER TABLE chill_main_address ADD CONSTRAINT fk_165051f6114b8dd9 FOREIGN KEY (linkedtothirdparty_id) REFERENCES chill_3party.third_party (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
@@ -8,10 +15,15 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add extension btree_gist
|
||||
* Add extension btree_gist.
|
||||
*/
|
||||
final class Version20210528090000 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP EXTENSION btree_gist');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'add extension btree_gist';
|
||||
@@ -21,9 +33,4 @@ final class Version20210528090000 extends AbstractMigration
|
||||
{
|
||||
$this->addSql('CREATE EXTENSION IF NOT EXISTS btree_gist');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP EXTENSION btree_gist');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
@@ -8,10 +15,18 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add table for ChillMain/Notification
|
||||
* Add table for ChillMain/Notification.
|
||||
*/
|
||||
final class Version20210610140248 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_main_notification_addresses_user DROP CONSTRAINT FK_E52C5D2BEF1A9D84');
|
||||
$this->addSql('DROP SEQUENCE chill_main_notification_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_main_notification');
|
||||
$this->addSql('DROP TABLE chill_main_notification_addresses_user');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add table for ChillMain/Notification';
|
||||
@@ -31,12 +46,4 @@ final class Version20210610140248 extends AbstractMigration
|
||||
$this->addSql('ALTER TABLE chill_main_notification_addresses_user ADD CONSTRAINT FK_E52C5D2BEF1A9D84 FOREIGN KEY (notification_id) REFERENCES chill_main_notification (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_main_notification_addresses_user ADD CONSTRAINT FK_E52C5D2BA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_main_notification_addresses_user DROP CONSTRAINT FK_E52C5D2BEF1A9D84');
|
||||
$this->addSql('DROP SEQUENCE chill_main_notification_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_main_notification');
|
||||
$this->addSql('DROP TABLE chill_main_notification_addresses_user');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
@@ -12,6 +19,11 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
*/
|
||||
final class Version20210616134328 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_main_postal_code DROP origin');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
@@ -21,9 +33,4 @@ final class Version20210616134328 extends AbstractMigration
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_main_postal_code ADD origin INT DEFAULT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_main_postal_code DROP origin');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
@@ -8,10 +15,24 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add metadata on users
|
||||
* Add metadata on users.
|
||||
*/
|
||||
final class Version20210903144853 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE users DROP CONSTRAINT FK_1483A5E964B65C5B');
|
||||
$this->addSql('DROP SEQUENCE chill_main_user_job_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_main_user_job');
|
||||
$this->addSql('ALTER TABLE users DROP CONSTRAINT FK_1483A5E92C2125C1');
|
||||
$this->addSql('ALTER TABLE users DROP CONSTRAINT FK_1483A5E9115E73F3');
|
||||
$this->addSql('ALTER TABLE users DROP label');
|
||||
$this->addSql('ALTER TABLE users DROP mainCenter_id');
|
||||
$this->addSql('ALTER TABLE users DROP mainScope_id');
|
||||
$this->addSql('ALTER TABLE users DROP userJob_id');
|
||||
$this->addSql('ALTER TABLE users ALTER usernameCanonical DROP NOT NULL');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add metadata on users';
|
||||
@@ -35,18 +56,4 @@ final class Version20210903144853 extends AbstractMigration
|
||||
$this->addSql('CREATE INDEX IDX_1483A5E9115E73F3 ON users (mainScope_id)');
|
||||
$this->addSql('CREATE INDEX IDX_1483A5E964B65C5B ON users (userJob_id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE users DROP CONSTRAINT FK_1483A5E964B65C5B');
|
||||
$this->addSql('DROP SEQUENCE chill_main_user_job_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_main_user_job');
|
||||
$this->addSql('ALTER TABLE users DROP CONSTRAINT FK_1483A5E92C2125C1');
|
||||
$this->addSql('ALTER TABLE users DROP CONSTRAINT FK_1483A5E9115E73F3');
|
||||
$this->addSql('ALTER TABLE users DROP label');
|
||||
$this->addSql('ALTER TABLE users DROP mainCenter_id');
|
||||
$this->addSql('ALTER TABLE users DROP mainScope_id');
|
||||
$this->addSql('ALTER TABLE users DROP userJob_id');
|
||||
$this->addSql('ALTER TABLE users ALTER usernameCanonical DROP NOT NULL');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
@@ -8,10 +15,15 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add a link between address and address reference
|
||||
* Add a link between address and address reference.
|
||||
*/
|
||||
final class Version20210929192242 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_main_address DROP addressReference_id');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add a link between address and address reference';
|
||||
@@ -23,9 +35,4 @@ final class Version20210929192242 extends AbstractMigration
|
||||
$this->addSql('ALTER TABLE chill_main_address ADD CONSTRAINT FK_165051F647069464 FOREIGN KEY (addressReference_id) REFERENCES chill_main_address_reference (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('CREATE INDEX IDX_165051F647069464 ON chill_main_address (addressReference_id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_main_address DROP addressReference_id');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
@@ -8,10 +15,17 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add some fields to PostalCode
|
||||
* Add some fields to PostalCode.
|
||||
*/
|
||||
final class Version20211006151653 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_main_postal_code DROP refPostalCodeId');
|
||||
$this->addSql('ALTER TABLE chill_main_postal_code DROP postalCodeSource');
|
||||
$this->addSql('ALTER TABLE chill_main_postal_code DROP center');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add some fields to PostalCode';
|
||||
@@ -23,11 +37,4 @@ final class Version20211006151653 extends AbstractMigration
|
||||
$this->addSql('ALTER TABLE chill_main_postal_code ADD postalCodeSource VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_main_postal_code ADD center geometry(POINT,4326) DEFAULT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_main_postal_code DROP refPostalCodeId');
|
||||
$this->addSql('ALTER TABLE chill_main_postal_code DROP postalCodeSource');
|
||||
$this->addSql('ALTER TABLE chill_main_postal_code DROP center');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
@@ -8,10 +15,16 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Create civility table
|
||||
* Create civility table.
|
||||
*/
|
||||
final class Version20211007150019 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP SEQUENCE chill_main_civility_id_seq');
|
||||
$this->addSql('DROP TABLE chill_main_civility');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'create civility table';
|
||||
@@ -22,10 +35,4 @@ final class Version20211007150019 extends AbstractMigration
|
||||
$this->addSql('CREATE SEQUENCE chill_main_civility_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
$this->addSql('CREATE TABLE chill_main_civility (id INT NOT NULL, name JSON NOT NULL, abbreviation JSON NOT NULL, active BOOLEAN NOT NULL, PRIMARY KEY(id))');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP SEQUENCE chill_main_civility_id_seq');
|
||||
$this->addSql('DROP TABLE chill_main_civility');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
@@ -12,6 +19,23 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
*/
|
||||
final class Version20211012141336 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE activity DROP CONSTRAINT FK_AC74095A64D218E');
|
||||
$this->addSql('ALTER TABLE activity DROP location_id');
|
||||
|
||||
$this->addSql('ALTER TABLE chill_calendar.calendar DROP CONSTRAINT FK_712315AC64D218E');
|
||||
$this->addSql('ALTER TABLE chill_calendar.calendar DROP location_id');
|
||||
|
||||
$this->addSql('ALTER TABLE chill_main_location DROP CONSTRAINT FK_90E4736AB8B0DA8E');
|
||||
|
||||
$this->addSql('DROP SEQUENCE chill_main_location_id_seq CASCADE');
|
||||
$this->addSql('DROP SEQUENCE chill_main_location_type_id_seq CASCADE');
|
||||
|
||||
$this->addSql('DROP TABLE chill_main_location');
|
||||
$this->addSql('DROP TABLE chill_main_location_type');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add Location and LocationType Entities (for activity and calendar)';
|
||||
@@ -45,22 +69,4 @@ final class Version20211012141336 extends AbstractMigration
|
||||
$this->addSql('ALTER TABLE chill_calendar.calendar ADD CONSTRAINT FK_712315AC64D218E FOREIGN KEY (location_id) REFERENCES chill_main_location (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('CREATE INDEX IDX_712315AC64D218E ON chill_calendar.calendar (location_id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
|
||||
$this->addSql('ALTER TABLE activity DROP CONSTRAINT FK_AC74095A64D218E');
|
||||
$this->addSql('ALTER TABLE activity DROP location_id');
|
||||
|
||||
$this->addSql('ALTER TABLE chill_calendar.calendar DROP CONSTRAINT FK_712315AC64D218E');
|
||||
$this->addSql('ALTER TABLE chill_calendar.calendar DROP location_id');
|
||||
|
||||
$this->addSql('ALTER TABLE chill_main_location DROP CONSTRAINT FK_90E4736AB8B0DA8E');
|
||||
|
||||
$this->addSql('DROP SEQUENCE chill_main_location_id_seq CASCADE');
|
||||
$this->addSql('DROP SEQUENCE chill_main_location_type_id_seq CASCADE');
|
||||
|
||||
$this->addSql('DROP TABLE chill_main_location');
|
||||
$this->addSql('DROP TABLE chill_main_location_type');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
@@ -9,6 +16,15 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20211013124455 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE activitytype DROP locationVisible');
|
||||
$this->addSql('ALTER TABLE activitytype DROP locationLabel');
|
||||
|
||||
// fix old migration !?
|
||||
$this->addSql('ALTER TABLE activitytype ALTER category_id SET DEFAULT 1');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'add location visible admin option';
|
||||
@@ -21,16 +37,5 @@ final class Version20211013124455 extends AbstractMigration
|
||||
|
||||
// fix old migration !?
|
||||
$this->addSql('ALTER TABLE activitytype ALTER category_id DROP DEFAULT');
|
||||
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE activitytype DROP locationVisible');
|
||||
$this->addSql('ALTER TABLE activitytype DROP locationLabel');
|
||||
|
||||
// fix old migration !?
|
||||
$this->addSql('ALTER TABLE activitytype ALTER category_id SET DEFAULT 1');
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
@@ -9,6 +16,12 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20211015084653 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP INDEX IDX_90E4736AF5B7AF75');
|
||||
$this->addSql('CREATE UNIQUE INDEX uniq_90e4736af5b7af75 ON chill_main_location (address_id)');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Location entity: change Address to ManyToOne';
|
||||
@@ -16,13 +29,7 @@ final class Version20211015084653 extends AbstractMigration
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP INDEX uniq_90e4736af5b7af75');
|
||||
$this->addSql('CREATE INDEX IDX_90E4736AF5B7AF75 ON chill_main_location (address_id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP INDEX IDX_90E4736AF5B7AF75');
|
||||
$this->addSql('CREATE UNIQUE INDEX uniq_90e4736af5b7af75 ON chill_main_location (address_id)');
|
||||
$this->addSql('DROP INDEX uniq_90e4736af5b7af75');
|
||||
$this->addSql('CREATE INDEX IDX_90E4736AF5B7AF75 ON chill_main_location (address_id)');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
@@ -8,10 +15,16 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add active on Location and LocationType
|
||||
* Add active on Location and LocationType.
|
||||
*/
|
||||
final class Version20211022094429 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_main_location_type DROP active');
|
||||
$this->addSql('ALTER TABLE chill_main_location DROP active');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add active on Location and LocationType';
|
||||
@@ -22,10 +35,4 @@ final class Version20211022094429 extends AbstractMigration
|
||||
$this->addSql('ALTER TABLE chill_main_location ADD active BOOLEAN DEFAULT TRUE;');
|
||||
$this->addSql('ALTER TABLE chill_main_location_type ADD active BOOLEAN DEFAULT TRUE;');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_main_location_type DROP active');
|
||||
$this->addSql('ALTER TABLE chill_main_location DROP active');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
@@ -8,10 +15,17 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add current location to User entity
|
||||
* Add current location to User entity.
|
||||
*/
|
||||
final class Version20211116162847 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE users DROP CONSTRAINT FK_1483A5E93C219753');
|
||||
$this->addSql('DROP INDEX IDX_1483A5E93C219753');
|
||||
$this->addSql('ALTER TABLE users DROP currentLocation_id');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add current location to User entity';
|
||||
@@ -23,11 +37,4 @@ final class Version20211116162847 extends AbstractMigration
|
||||
$this->addSql('ALTER TABLE users ADD CONSTRAINT FK_1483A5E93C219753 FOREIGN KEY (currentLocation_id) REFERENCES chill_main_location (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('CREATE INDEX IDX_1483A5E93C219753 ON users (currentLocation_id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE users DROP CONSTRAINT FK_1483A5E93C219753');
|
||||
$this->addSql('DROP INDEX IDX_1483A5E93C219753');
|
||||
$this->addSql('ALTER TABLE users DROP currentLocation_id');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
@@ -12,6 +19,11 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
*/
|
||||
final class Version20211119173554 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->throwIrreversibleMigrationException();
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'remove comment on deprecated json_array type';
|
||||
@@ -20,16 +32,11 @@ final class Version20211119173554 extends AbstractMigration
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$columns = [
|
||||
'users.attributes'
|
||||
'users.attributes',
|
||||
];
|
||||
|
||||
foreach ($columns as $col) {
|
||||
$this->addSql("COMMENT ON COLUMN $col IS NULL");
|
||||
$this->addSql("COMMENT ON COLUMN {$col} IS NULL");
|
||||
}
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->throwIrreversibleMigrationException();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user