mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-29 10:05:03 +00:00
refactor: Update source code based on PHP conventions.
This commit is contained in:
@@ -1,44 +1,53 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
class Version20141129010948 extends AbstractMigration
|
||||
{
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql("CREATE SEQUENCE ClosingMotive_id_seq INCREMENT BY 1 MINVALUE 1 START 1;");
|
||||
$this->addSql("CREATE SEQUENCE person_history_file_id_seq INCREMENT BY 1 MINVALUE 1 START 1;");
|
||||
$this->addSql("CREATE SEQUENCE Person_id_seq INCREMENT BY 1 MINVALUE 1 START 1;");
|
||||
$this->addSql("CREATE TABLE ClosingMotive (id INT NOT NULL, name JSON NOT NULL, active BOOLEAN NOT NULL, PRIMARY KEY(id));");
|
||||
$this->addSql("CREATE TABLE person_history_file (id INT NOT NULL, person_id INT DEFAULT NULL, date_opening DATE NOT NULL, date_closing DATE DEFAULT NULL, memo TEXT NOT NULL, closingMotive_id INT DEFAULT NULL, PRIMARY KEY(id));");
|
||||
$this->addSql("CREATE INDEX IDX_64A4A621217BBB47 ON person_history_file (person_id);");
|
||||
$this->addSql("CREATE INDEX IDX_64A4A621504CB38D ON person_history_file (closingMotive_id);");
|
||||
$this->addSql("CREATE TABLE Person (id INT NOT NULL, nationality_id INT DEFAULT NULL, firstName VARCHAR(255) NOT NULL, lastName VARCHAR(255) NOT NULL, date_of_birth DATE DEFAULT NULL, place_of_birth VARCHAR(255) NOT NULL, genre VARCHAR(9) NOT NULL, memo TEXT NOT NULL, email TEXT NOT NULL, proxyHistoryOpenState BOOLEAN NOT NULL, cFData TEXT NOT NULL, phonenumber TEXT DEFAULT NULL, countryOfBirth_id INT DEFAULT NULL, PRIMARY KEY(id));");
|
||||
$this->addSql("CREATE INDEX IDX_3370D4403818DA5 ON Person (countryOfBirth_id);");
|
||||
$this->addSql("CREATE INDEX IDX_3370D4401C9DA55 ON Person (nationality_id);");
|
||||
$this->addSql("CREATE INDEX person_names ON Person (firstName, lastName);");
|
||||
$this->addSql("COMMENT ON COLUMN Person.cFData IS '(DC2Type:array)';");
|
||||
$this->addSql("CREATE TABLE persons_spoken_languages (person_id INT NOT NULL, language_id VARCHAR(255) NOT NULL, PRIMARY KEY(person_id, language_id));");
|
||||
$this->addSql("CREATE INDEX IDX_7201106F217BBB47 ON persons_spoken_languages (person_id);");
|
||||
$this->addSql("CREATE INDEX IDX_7201106F82F1BAF4 ON persons_spoken_languages (language_id);");
|
||||
$this->addSql("ALTER TABLE person_history_file ADD CONSTRAINT FK_64A4A621217BBB47 FOREIGN KEY (person_id) REFERENCES Person (id) NOT DEFERRABLE INITIALLY IMMEDIATE;");
|
||||
$this->addSql("ALTER TABLE person_history_file ADD CONSTRAINT FK_64A4A621504CB38D FOREIGN KEY (closingMotive_id) REFERENCES ClosingMotive (id) NOT DEFERRABLE INITIALLY IMMEDIATE;");
|
||||
$this->addSql("ALTER TABLE Person ADD CONSTRAINT FK_3370D4403818DA5 FOREIGN KEY (countryOfBirth_id) REFERENCES Country (id) NOT DEFERRABLE INITIALLY IMMEDIATE;");
|
||||
$this->addSql("ALTER TABLE Person ADD CONSTRAINT FK_3370D4401C9DA55 FOREIGN KEY (nationality_id) REFERENCES Country (id) NOT DEFERRABLE INITIALLY IMMEDIATE;");
|
||||
$this->addSql("ALTER TABLE persons_spoken_languages ADD CONSTRAINT FK_7201106F217BBB47 FOREIGN KEY (person_id) REFERENCES Person (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;");
|
||||
$this->addSql("ALTER TABLE persons_spoken_languages ADD CONSTRAINT FK_7201106F82F1BAF4 FOREIGN KEY (language_id) REFERENCES Language (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 SEQUENCE ClosingMotive_id_seq INCREMENT BY 1 MINVALUE 1 START 1;');
|
||||
$this->addSql('CREATE SEQUENCE person_history_file_id_seq INCREMENT BY 1 MINVALUE 1 START 1;');
|
||||
$this->addSql('CREATE SEQUENCE Person_id_seq INCREMENT BY 1 MINVALUE 1 START 1;');
|
||||
$this->addSql('CREATE TABLE ClosingMotive (id INT NOT NULL, name JSON NOT NULL, active BOOLEAN NOT NULL, PRIMARY KEY(id));');
|
||||
$this->addSql('CREATE TABLE person_history_file (id INT NOT NULL, person_id INT DEFAULT NULL, date_opening DATE NOT NULL, date_closing DATE DEFAULT NULL, memo TEXT NOT NULL, closingMotive_id INT DEFAULT NULL, PRIMARY KEY(id));');
|
||||
$this->addSql('CREATE INDEX IDX_64A4A621217BBB47 ON person_history_file (person_id);');
|
||||
$this->addSql('CREATE INDEX IDX_64A4A621504CB38D ON person_history_file (closingMotive_id);');
|
||||
$this->addSql('CREATE TABLE Person (id INT NOT NULL, nationality_id INT DEFAULT NULL, firstName VARCHAR(255) NOT NULL, lastName VARCHAR(255) NOT NULL, date_of_birth DATE DEFAULT NULL, place_of_birth VARCHAR(255) NOT NULL, genre VARCHAR(9) NOT NULL, memo TEXT NOT NULL, email TEXT NOT NULL, proxyHistoryOpenState BOOLEAN NOT NULL, cFData TEXT NOT NULL, phonenumber TEXT DEFAULT NULL, countryOfBirth_id INT DEFAULT NULL, PRIMARY KEY(id));');
|
||||
$this->addSql('CREATE INDEX IDX_3370D4403818DA5 ON Person (countryOfBirth_id);');
|
||||
$this->addSql('CREATE INDEX IDX_3370D4401C9DA55 ON Person (nationality_id);');
|
||||
$this->addSql('CREATE INDEX person_names ON Person (firstName, lastName);');
|
||||
$this->addSql("COMMENT ON COLUMN Person.cFData IS '(DC2Type:array)';");
|
||||
$this->addSql('CREATE TABLE persons_spoken_languages (person_id INT NOT NULL, language_id VARCHAR(255) NOT NULL, PRIMARY KEY(person_id, language_id));');
|
||||
$this->addSql('CREATE INDEX IDX_7201106F217BBB47 ON persons_spoken_languages (person_id);');
|
||||
$this->addSql('CREATE INDEX IDX_7201106F82F1BAF4 ON persons_spoken_languages (language_id);');
|
||||
$this->addSql('ALTER TABLE person_history_file ADD CONSTRAINT FK_64A4A621217BBB47 FOREIGN KEY (person_id) REFERENCES Person (id) NOT DEFERRABLE INITIALLY IMMEDIATE;');
|
||||
$this->addSql('ALTER TABLE person_history_file ADD CONSTRAINT FK_64A4A621504CB38D FOREIGN KEY (closingMotive_id) REFERENCES ClosingMotive (id) NOT DEFERRABLE INITIALLY IMMEDIATE;');
|
||||
$this->addSql('ALTER TABLE Person ADD CONSTRAINT FK_3370D4403818DA5 FOREIGN KEY (countryOfBirth_id) REFERENCES Country (id) NOT DEFERRABLE INITIALLY IMMEDIATE;');
|
||||
$this->addSql('ALTER TABLE Person ADD CONSTRAINT FK_3370D4401C9DA55 FOREIGN KEY (nationality_id) REFERENCES Country (id) NOT DEFERRABLE INITIALLY IMMEDIATE;');
|
||||
$this->addSql('ALTER TABLE persons_spoken_languages ADD CONSTRAINT FK_7201106F217BBB47 FOREIGN KEY (person_id) REFERENCES Person (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;');
|
||||
$this->addSql('ALTER TABLE persons_spoken_languages ADD CONSTRAINT FK_7201106F82F1BAF4 FOREIGN KEY (language_id) REFERENCES Language (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;');
|
||||
}
|
||||
}
|
||||
|
@@ -1,30 +1,40 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
class Version20150212173934 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE accompanying_period RENAME TO person_history_file;');
|
||||
$this->addSql('ALTER TABLE person RENAME proxyAccompanyingPeriodOpenState TO proxyHistoryOpenState;');
|
||||
$this->addSql('ALTER SEQUENCE accompanying_period_id_seq RENAME TO person_history_file_id_seq;');
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
|
||||
$this->addSql("ALTER TABLE person RENAME proxyHistoryOpenState TO proxyAccompanyingPeriodOpenState;");
|
||||
$this->addSql("ALTER TABLE person_history_file RENAME TO accompanying_period;");
|
||||
$this->addSql("ALTER SEQUENCE person_history_file_id_seq RENAME TO accompanying_period_id_seq;");
|
||||
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql("ALTER TABLE accompanying_period RENAME TO person_history_file;");
|
||||
$this->addSql("ALTER TABLE person RENAME proxyAccompanyingPeriodOpenState TO proxyHistoryOpenState;");
|
||||
$this->addSql("ALTER SEQUENCE accompanying_period_id_seq RENAME TO person_history_file_id_seq;");
|
||||
$this->addSql('ALTER TABLE person RENAME proxyHistoryOpenState TO proxyAccompanyingPeriodOpenState;');
|
||||
$this->addSql('ALTER TABLE person_history_file RENAME TO accompanying_period;');
|
||||
$this->addSql('ALTER SEQUENCE person_history_file_id_seq RENAME TO accompanying_period_id_seq;');
|
||||
}
|
||||
}
|
||||
|
@@ -1,30 +1,51 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* Add a center to class person
|
||||
* Add a center to class person.
|
||||
*/
|
||||
class Version20150607231010 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 Person DROP CONSTRAINT FK_person_center');
|
||||
$this->addSql('DROP INDEX IDX_person_center');
|
||||
$this->addSql('ALTER TABLE Person DROP center_id');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add a center on the person entity. The default center is the first '
|
||||
. 'recorded.';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->abortIf(
|
||||
$this->connection->getDatabasePlatform()->getName() != 'postgresql',
|
||||
$this->connection->getDatabasePlatform()->getName() !== 'postgresql',
|
||||
'Migration can only be executed safely on \'postgresql\'.'
|
||||
);
|
||||
|
||||
@@ -37,7 +58,7 @@ class Version20150607231010 extends AbstractMigration
|
||||
//check if there are data in person table
|
||||
$nbPeople = $this->connection->fetchColumn('SELECT count(*) FROM person');
|
||||
|
||||
if ($nbPeople > 0) {
|
||||
if (0 < $nbPeople) {
|
||||
// we have data ! We have to create a center !
|
||||
$newCenterId = $this->connection->fetchColumn('SELECT nextval(\'centers_id_seq\');');
|
||||
$this->addSql(
|
||||
@@ -51,7 +72,7 @@ class Version20150607231010 extends AbstractMigration
|
||||
$this->addSql('ALTER TABLE person ADD center_id INT');
|
||||
|
||||
if (isset($defaultCenterId)) {
|
||||
$this->addSql('UPDATE person SET center_id = :id', array('id' => $defaultCenterId));
|
||||
$this->addSql('UPDATE person SET center_id = :id', ['id' => $defaultCenterId]);
|
||||
}
|
||||
|
||||
$this->addSql('ALTER TABLE person '
|
||||
@@ -60,19 +81,4 @@ class Version20150607231010 extends AbstractMigration
|
||||
$this->addSql('ALTER TABLE person ALTER center_id SET NOT NULL');
|
||||
$this->addSql('CREATE INDEX IDX_person_center ON person (center_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 Person DROP CONSTRAINT FK_person_center');
|
||||
$this->addSql('DROP INDEX IDX_person_center');
|
||||
$this->addSql('ALTER TABLE Person DROP center_id');
|
||||
}
|
||||
}
|
||||
|
@@ -1,66 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Migration for adapting the Person Bundle to the 'cahier de charge' :
|
||||
* - RENAMING :
|
||||
* - - date_of_birth TO birthdate
|
||||
* - - genre to gender
|
||||
*
|
||||
* - - genre to gender.
|
||||
*/
|
||||
class Version20150811152608 extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
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 person RENAME COLUMN date_of_birth TO birthdate');
|
||||
$this->addSql('ALTER TABLE person RENAME COLUMN genre TO gender');
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @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->connection->getDatabasePlatform()->getName() !== 'postgresql',
|
||||
'Migration can only be executed safely on \'postgresql\'.'
|
||||
);
|
||||
|
||||
$this->addSql('ALTER TABLE person RENAME COLUMN birthdate TO date_of_birth');
|
||||
$this->addSql('ALTER TABLE person RENAME COLUMN gender TO genre');
|
||||
}
|
||||
|
||||
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 person RENAME COLUMN date_of_birth TO birthdate');
|
||||
$this->addSql('ALTER TABLE person RENAME COLUMN genre TO gender');
|
||||
}
|
||||
}
|
||||
|
@@ -1,43 +1,44 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Migration for adding maritalstatus to person
|
||||
* Migration for adding maritalstatus to person.
|
||||
*/
|
||||
class Version20150812110708 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 person DROP CONSTRAINT fk_person_marital_status;');
|
||||
$this->addSql('ALTER TABLE person DROP COLUMN maritalstatus_id;');
|
||||
$this->addSql('DROP TABLE marital_status;');
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->abortIf(
|
||||
$this->connection->getDatabasePlatform()->getName() != 'postgresql',
|
||||
'Migration can only be executed safely on \'postgresql\'.');
|
||||
$this->connection->getDatabasePlatform()->getName() !== 'postgresql',
|
||||
'Migration can only be executed safely on \'postgresql\'.'
|
||||
);
|
||||
|
||||
$this->addSql('CREATE TABLE marital_status (
|
||||
id character varying(10) NOT NULL,
|
||||
@@ -46,18 +47,4 @@ class Version20150812110708 extends AbstractMigration
|
||||
$this->addSql('ALTER TABLE person ADD COLUMN maritalstatus_id character varying(10)');
|
||||
$this->addSql('ALTER TABLE person ADD CONSTRAINT fk_person_marital_status FOREIGN KEY (maritalstatus_id) REFERENCES marital_status (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION');
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 person DROP CONSTRAINT fk_person_marital_status;');
|
||||
$this->addSql('ALTER TABLE person DROP COLUMN maritalstatus_id;');
|
||||
$this->addSql('DROP TABLE marital_status;');
|
||||
}
|
||||
}
|
||||
|
@@ -1,61 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Migration for adapting the Person Bundle to the 'cahier de charge' :
|
||||
* - update of accompanyingPerid
|
||||
* - update of accompanyingPerid.
|
||||
*/
|
||||
class Version20150820113409 extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
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 accompanying_period RENAME COLUMN date_opening TO openingdate;');
|
||||
$this->addSql('ALTER TABLE accompanying_period RENAME COLUMN date_closing TO closingdate;');
|
||||
$this->addSql('ALTER TABLE accompanying_period RENAME COLUMN memo TO remark;');
|
||||
}
|
||||
|
||||
/**
|
||||
* @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->connection->getDatabasePlatform()->getName() !== 'postgresql',
|
||||
'Migration can only be executed safely on \'postgresql\'.'
|
||||
);
|
||||
|
||||
$this->addSql('ALTER TABLE accompanying_period RENAME COLUMN openingdate TO date_opening;');
|
||||
$this->addSql('ALTER TABLE accompanying_period RENAME COLUMN closingdate TO date_closing;');
|
||||
$this->addSql('ALTER TABLE accompanying_period RENAME COLUMN remark TO memo;');
|
||||
}
|
||||
|
||||
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 accompanying_period RENAME COLUMN date_opening TO openingdate;');
|
||||
$this->addSql('ALTER TABLE accompanying_period RENAME COLUMN date_closing TO closingdate;');
|
||||
$this->addSql('ALTER TABLE accompanying_period RENAME COLUMN memo TO remark;');
|
||||
}
|
||||
}
|
||||
|
@@ -1,22 +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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add a many-to-many relationship between person and addresses
|
||||
* Add a many-to-many relationship between person and addresses.
|
||||
*/
|
||||
class Version20160310161006 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('DROP TABLE chill_person_persons_to_addresses');
|
||||
}
|
||||
|
||||
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->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
$this->addSql('CREATE TABLE chill_person_persons_to_addresses ('
|
||||
. 'person_id INT NOT NULL, '
|
||||
@@ -35,15 +50,4 @@ class Version20160310161006 extends AbstractMigration
|
||||
. 'FOREIGN KEY (address_id) '
|
||||
. 'REFERENCES chill_main_address (id) ON DELETE CASCADE 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('DROP TABLE chill_person_persons_to_addresses');
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,18 +1,32 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* Check if each person do not have multiple addresses with the same valideFrom
|
||||
* Check if each person do not have multiple addresses with the same valideFrom.
|
||||
*/
|
||||
class Version20160422000000 extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$stmt = $this->connection->query('SELECT COUNT(*), pe.id, ad.validfrom FROM person AS pe
|
||||
@@ -20,23 +34,16 @@ class Version20160422000000 extends AbstractMigration
|
||||
INNER JOIN chill_main_address AS ad ON ad.id = pe_ad.address_id
|
||||
GROUP BY pe.id, ad.validfrom
|
||||
HAVING COUNT(*) > 1');
|
||||
|
||||
|
||||
$personWithTwoAddressWithSameValidFrom = $stmt->fetchAll();
|
||||
|
||||
|
||||
foreach ($personWithTwoAddressWithSameValidFrom as $p) {
|
||||
$this->warnIf(true, 'The person with id '.$p['id'].' has two adresses with the same validFrom date');
|
||||
$this->warnIf(true, 'The person with id ' . $p['id'] . ' has two adresses with the same validFrom date');
|
||||
}
|
||||
|
||||
|
||||
$this->abortIf(
|
||||
sizeof($personWithTwoAddressWithSameValidFrom) != 0,
|
||||
count($personWithTwoAddressWithSameValidFrom) !== 0,
|
||||
'There exists some person with multiple adress with the same validFrom'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@@ -1,21 +1,40 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* This migration store the cfdata using the postgresql jsonb type instead
|
||||
* of the result of the sterialization
|
||||
* of the result of the sterialization.
|
||||
*/
|
||||
class Version20160818113633 extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* Inverse of up.
|
||||
*/
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSQL('ALTER TABLE person DROP COLUMN cfdata');
|
||||
$this->addSQL('ALTER TABLE person RENAME COLUMN cfdata_old TO cfdata');
|
||||
$this->addSql('ALTER TABLE person ALTER COLUMN cfdata SET NOT NULL');
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a copy of the column cfdata into the column cfdata_old. Then
|
||||
* remplace the sterialized data into a json data.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
@@ -35,16 +54,4 @@ class Version20160818113633 extends AbstractMigration
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Inverse of up
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSQL('ALTER TABLE person DROP COLUMN cfdata');
|
||||
$this->addSQL('ALTER TABLE person RENAME COLUMN cfdata_old TO cfdata');
|
||||
$this->addSql('ALTER TABLE person ALTER COLUMN cfdata SET NOT NULL');
|
||||
}
|
||||
}
|
||||
|
@@ -1,35 +1,26 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add the prefix 'chill_person' to all the (db) table name of this bundle
|
||||
* Add the prefix 'chill_person' to all the (db) table name of this bundle.
|
||||
*/
|
||||
class Version20160818151130 extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE person RENAME TO chill_person_person');
|
||||
$this->addSql('ALTER TABLE person_id_seq RENAME TO chill_person_person_id_seq');
|
||||
|
||||
$this->addSql('ALTER TABLE marital_status RENAME TO chill_person_marital_status');
|
||||
|
||||
$this->addSql('ALTER TABLE accompanying_period RENAME TO chill_person_accompanying_period');
|
||||
$this->addSql('ALTER TABLE accompanying_period_id_seq RENAME TO chill_person_accompanying_period_id_seq');
|
||||
|
||||
$this->addSql('ALTER TABLE closingmotive RENAME TO chill_person_closingmotive');
|
||||
$this->addSql('ALTER TABLE closingmotive_id_seq RENAME TO chill_person_closingmotive_id_seq');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSQL('ALTER TABLE chill_person_person RENAME TO person');
|
||||
@@ -43,4 +34,18 @@ class Version20160818151130 extends AbstractMigration
|
||||
$this->addSQL('ALTER TABLE chill_person_closingmotive RENAME TO closingmotive');
|
||||
$this->addSql('ALTER TABLE chill_person_closingmotive_id_seq RENAME TO closingmotive_id_seq');
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE person RENAME TO chill_person_person');
|
||||
$this->addSql('ALTER TABLE person_id_seq RENAME TO chill_person_person_id_seq');
|
||||
|
||||
$this->addSql('ALTER TABLE marital_status RENAME TO chill_person_marital_status');
|
||||
|
||||
$this->addSql('ALTER TABLE accompanying_period RENAME TO chill_person_accompanying_period');
|
||||
$this->addSql('ALTER TABLE accompanying_period_id_seq RENAME TO chill_person_accompanying_period_id_seq');
|
||||
|
||||
$this->addSql('ALTER TABLE closingmotive RENAME TO chill_person_closingmotive');
|
||||
$this->addSql('ALTER TABLE closingmotive_id_seq RENAME TO chill_person_closingmotive_id_seq');
|
||||
}
|
||||
}
|
||||
|
@@ -1,123 +1,129 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add postgresql functions to compute last address on person.
|
||||
*/
|
||||
class Version20170117131924 extends AbstractMigration
|
||||
{
|
||||
|
||||
public $fields = array(
|
||||
'address_id' => 'integer',
|
||||
'streetaddress1' => 'varchar(255)',
|
||||
'streetaddress2' => 'varchar(255)',
|
||||
'validfrom' => 'date',
|
||||
'postcode_label' => 'varchar(255)',
|
||||
'postcode_code' => 'varchar(100)',
|
||||
'postcode_id' => 'integer',
|
||||
'country_name' => 'json',
|
||||
'country_code' => 'varchar(3)',
|
||||
'country_id' => 'integer'
|
||||
);
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql(<<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION public.get_last_address (
|
||||
pid integer,
|
||||
before_date date)
|
||||
RETURNS TABLE(
|
||||
person_id integer,
|
||||
address_id integer,
|
||||
streetaddress1 varchar(255),
|
||||
streetaddress2 varchar(255),
|
||||
validfrom date,
|
||||
postcode_label varchar(255),
|
||||
postcode_code varchar(100),
|
||||
postcode_id integer,
|
||||
country_name json,
|
||||
country_code varchar(3),
|
||||
country_id integer)
|
||||
AS
|
||||
$BODY$
|
||||
SELECT
|
||||
pid AS person_id,
|
||||
chill_main_address.id AS address_id,
|
||||
chill_main_address.streetaddress1,
|
||||
chill_main_address.streetaddress2,
|
||||
chill_main_address.validfrom,
|
||||
chill_main_postal_code.label,
|
||||
chill_main_postal_code.code,
|
||||
chill_main_postal_code.id AS postal_code_id,
|
||||
country.name,
|
||||
country.countrycode,
|
||||
country.id AS country_id
|
||||
FROM chill_main_address
|
||||
JOIN (
|
||||
SELECT
|
||||
chill_main_address.id AS address_id,
|
||||
validfrom,
|
||||
rank() OVER (PARTITION BY person_id ORDER BY validfrom DESC) as pos
|
||||
FROM chill_person_persons_to_addresses
|
||||
JOIN chill_main_address ON chill_person_persons_to_addresses.address_id = chill_main_address.id
|
||||
WHERE person_id = pid
|
||||
AND chill_main_address.validfrom <= before_date
|
||||
) AS ranking ON ranking.address_id = chill_main_address.id
|
||||
JOIN chill_main_postal_code ON chill_main_address.postcode_id = chill_main_postal_code.id
|
||||
JOIN country ON chill_main_postal_code.country_id = country.id
|
||||
WHERE ranking.pos = 1
|
||||
$BODY$
|
||||
LANGUAGE sql VOLATILE
|
||||
COST 100;
|
||||
SQL
|
||||
);
|
||||
|
||||
// create function to get part of address
|
||||
foreach ($this->fields as $var => $type) {
|
||||
$this->addSql(sprintf(<<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION get_last_address_%s (
|
||||
pid integer,
|
||||
before_date date)
|
||||
RETURNS %s AS
|
||||
$BODY$
|
||||
SELECT %s FROM get_last_address(pid, before_date)
|
||||
$BODY$
|
||||
LANGUAGE sql volatile
|
||||
COST 100;
|
||||
SQL
|
||||
, $var, $type, $var));
|
||||
}
|
||||
}
|
||||
public $fields = [
|
||||
'address_id' => 'integer',
|
||||
'streetaddress1' => 'varchar(255)',
|
||||
'streetaddress2' => 'varchar(255)',
|
||||
'validfrom' => 'date',
|
||||
'postcode_label' => 'varchar(255)',
|
||||
'postcode_code' => 'varchar(100)',
|
||||
'postcode_id' => 'integer',
|
||||
'country_name' => 'json',
|
||||
'country_code' => 'varchar(3)',
|
||||
'country_id' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// drop function to get parts of address
|
||||
foreach ($this->fields as $var => $type) {
|
||||
$this->addSql(<<<SQL
|
||||
$this->addSql(
|
||||
<<<SQL
|
||||
|
||||
DROP FUNCTION get_last_address_$var (
|
||||
pid integer,
|
||||
before_date date)
|
||||
SQL
|
||||
);
|
||||
}
|
||||
|
||||
$this->addSQL(<<<SQL
|
||||
DROP FUNCTION public.get_last_address (
|
||||
pid integer,
|
||||
before_date date)
|
||||
SQL
|
||||
DROP FUNCTION get_last_address_{$var} (
|
||||
pid integer,
|
||||
before_date date)
|
||||
SQL
|
||||
);
|
||||
}
|
||||
|
||||
$this->addSQL(
|
||||
<<<'SQL'
|
||||
DROP FUNCTION public.get_last_address (
|
||||
pid integer,
|
||||
before_date date)
|
||||
SQL
|
||||
);
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql(
|
||||
<<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION public.get_last_address (
|
||||
pid integer,
|
||||
before_date date)
|
||||
RETURNS TABLE(
|
||||
person_id integer,
|
||||
address_id integer,
|
||||
streetaddress1 varchar(255),
|
||||
streetaddress2 varchar(255),
|
||||
validfrom date,
|
||||
postcode_label varchar(255),
|
||||
postcode_code varchar(100),
|
||||
postcode_id integer,
|
||||
country_name json,
|
||||
country_code varchar(3),
|
||||
country_id integer)
|
||||
AS
|
||||
$BODY$
|
||||
SELECT
|
||||
pid AS person_id,
|
||||
chill_main_address.id AS address_id,
|
||||
chill_main_address.streetaddress1,
|
||||
chill_main_address.streetaddress2,
|
||||
chill_main_address.validfrom,
|
||||
chill_main_postal_code.label,
|
||||
chill_main_postal_code.code,
|
||||
chill_main_postal_code.id AS postal_code_id,
|
||||
country.name,
|
||||
country.countrycode,
|
||||
country.id AS country_id
|
||||
FROM chill_main_address
|
||||
JOIN (
|
||||
SELECT
|
||||
chill_main_address.id AS address_id,
|
||||
validfrom,
|
||||
rank() OVER (PARTITION BY person_id ORDER BY validfrom DESC) as pos
|
||||
FROM chill_person_persons_to_addresses
|
||||
JOIN chill_main_address ON chill_person_persons_to_addresses.address_id = chill_main_address.id
|
||||
WHERE person_id = pid
|
||||
AND chill_main_address.validfrom <= before_date
|
||||
) AS ranking ON ranking.address_id = chill_main_address.id
|
||||
JOIN chill_main_postal_code ON chill_main_address.postcode_id = chill_main_postal_code.id
|
||||
JOIN country ON chill_main_postal_code.country_id = country.id
|
||||
WHERE ranking.pos = 1
|
||||
$BODY$
|
||||
LANGUAGE sql VOLATILE
|
||||
COST 100;
|
||||
SQL
|
||||
);
|
||||
|
||||
// create function to get part of address
|
||||
foreach ($this->fields as $var => $type) {
|
||||
$this->addSql(sprintf(<<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION get_last_address_%s (
|
||||
pid integer,
|
||||
before_date date)
|
||||
RETURNS %s AS
|
||||
$BODY$
|
||||
SELECT %s FROM get_last_address(pid, before_date)
|
||||
$BODY$
|
||||
LANGUAGE sql volatile
|
||||
COST 100;
|
||||
SQL
|
||||
, $var, $type, $var));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,24 +1,26 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add a contactInfo and a mobilenumber columns on person. Change the email column.
|
||||
*/
|
||||
final class Version20180518144221 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_person_person ADD contactInfo TEXT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_person_person ADD mobilenumber TEXT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_person_person ALTER email DROP NOT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
@@ -27,4 +29,13 @@ final class Version20180518144221 extends AbstractMigration
|
||||
$this->addSql('ALTER TABLE chill_person_person DROP mobilenumber');
|
||||
$this->addSql('ALTER TABLE chill_person_person ALTER email SET NOT NULL');
|
||||
}
|
||||
|
||||
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_person_person ADD contactInfo TEXT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_person_person ADD mobilenumber TEXT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_person_person ALTER email DROP NOT NULL');
|
||||
}
|
||||
}
|
||||
|
@@ -1,26 +1,28 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Correction: copie les infos de email vers contactInfo.
|
||||
*
|
||||
*
|
||||
* Previously, data from contact where stored in 'email' column
|
||||
*/
|
||||
final class Version20180820120000 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('UPDATE chill_person_person SET contactInfo=email');
|
||||
$this->addSql('UPDATE chill_person_person SET email=\'\'');
|
||||
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
@@ -28,4 +30,12 @@ final class Version20180820120000 extends AbstractMigration
|
||||
$this->addSql('UPDATE chill_person_person SET email=contactInfo');
|
||||
$this->addSql('UPDATE chill_person_person SET contactInfo=\'\'');
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
$this->addSql('UPDATE chill_person_person SET contactInfo=email');
|
||||
$this->addSql('UPDATE chill_person_person SET email=\'\'');
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,15 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
@@ -6,21 +17,21 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Set person gender not null
|
||||
* Set person gender not null.
|
||||
*/
|
||||
final class Version20181005140249 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_person_person ALTER gender DROP NOT NULL');
|
||||
}
|
||||
|
||||
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_person_person ALTER gender SET NOT NULL');
|
||||
}
|
||||
|
||||
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_person_person ALTER gender DROP NOT NULL');
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,15 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
@@ -6,65 +17,10 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add fullnameCanonical column for trigram matching (fast searching)
|
||||
* Add fullnameCanonical column for trigram matching (fast searching).
|
||||
*/
|
||||
final class Version20181023101621 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_person_person ADD fullnameCanonical VARCHAR(255) DEFAULT '' ");
|
||||
$this->addSql("UPDATE chill_person_person SET fullnameCanonical=LOWER(UNACCENT(CONCAT(firstname, ' ', lastname)))");
|
||||
$this->addSql("CREATE INDEX fullnameCanonical_trgm_idx ON chill_person_person USING GIN (fullnameCanonical gin_trgm_ops)");
|
||||
|
||||
$this->addSql(<<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION canonicalize_fullname_on_update() RETURNS TRIGGER AS
|
||||
$BODY$
|
||||
BEGIN
|
||||
IF NEW.firstname <> OLD.firstname OR NEW.lastname <> OLD.lastname
|
||||
THEN
|
||||
UPDATE chill_person_person
|
||||
SET fullnameCanonical=LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname)))
|
||||
WHERE id=NEW.id;
|
||||
END IF;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$BODY$ LANGUAGE PLPGSQL;
|
||||
SQL
|
||||
);
|
||||
$this->addSql(<<<SQL
|
||||
CREATE TRIGGER canonicalize_fullname_on_update
|
||||
AFTER UPDATE
|
||||
ON chill_person_person
|
||||
FOR EACH ROW
|
||||
WHEN (pg_trigger_depth() = 0)
|
||||
EXECUTE PROCEDURE canonicalize_fullname_on_update();
|
||||
SQL
|
||||
);
|
||||
|
||||
$this->addSql(<<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION canonicalize_fullname_on_insert() RETURNS TRIGGER AS
|
||||
$BODY$
|
||||
BEGIN
|
||||
UPDATE chill_person_person
|
||||
SET fullnameCanonical=LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname)))
|
||||
WHERE id=NEW.id;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$BODY$ LANGUAGE PLPGSQL;
|
||||
SQL
|
||||
);
|
||||
$this->addSql(<<<SQL
|
||||
CREATE TRIGGER canonicalize_fullname_on_insert
|
||||
AFTER INSERT
|
||||
ON chill_person_person
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE canonicalize_fullname_on_insert();
|
||||
SQL
|
||||
);
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
@@ -76,4 +32,63 @@ SQL
|
||||
$this->addSql('DROP TRIGGER canonicalize_fullname_on_insert ON chill_person_person');
|
||||
$this->addSql('DROP FUNCTION canonicalize_fullname_on_insert()');
|
||||
}
|
||||
|
||||
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_person_person ADD fullnameCanonical VARCHAR(255) DEFAULT '' ");
|
||||
$this->addSql("UPDATE chill_person_person SET fullnameCanonical=LOWER(UNACCENT(CONCAT(firstname, ' ', lastname)))");
|
||||
$this->addSql('CREATE INDEX fullnameCanonical_trgm_idx ON chill_person_person USING GIN (fullnameCanonical gin_trgm_ops)');
|
||||
|
||||
$this->addSql(
|
||||
<<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION canonicalize_fullname_on_update() RETURNS TRIGGER AS
|
||||
$BODY$
|
||||
BEGIN
|
||||
IF NEW.firstname <> OLD.firstname OR NEW.lastname <> OLD.lastname
|
||||
THEN
|
||||
UPDATE chill_person_person
|
||||
SET fullnameCanonical=LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname)))
|
||||
WHERE id=NEW.id;
|
||||
END IF;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$BODY$ LANGUAGE PLPGSQL;
|
||||
SQL
|
||||
);
|
||||
$this->addSql(
|
||||
<<<'SQL'
|
||||
CREATE TRIGGER canonicalize_fullname_on_update
|
||||
AFTER UPDATE
|
||||
ON chill_person_person
|
||||
FOR EACH ROW
|
||||
WHEN (pg_trigger_depth() = 0)
|
||||
EXECUTE PROCEDURE canonicalize_fullname_on_update();
|
||||
SQL
|
||||
);
|
||||
|
||||
$this->addSql(
|
||||
<<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION canonicalize_fullname_on_insert() RETURNS TRIGGER AS
|
||||
$BODY$
|
||||
BEGIN
|
||||
UPDATE chill_person_person
|
||||
SET fullnameCanonical=LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname)))
|
||||
WHERE id=NEW.id;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$BODY$ LANGUAGE PLPGSQL;
|
||||
SQL
|
||||
);
|
||||
$this->addSql(
|
||||
<<<'SQL'
|
||||
CREATE TRIGGER canonicalize_fullname_on_insert
|
||||
AFTER INSERT
|
||||
ON chill_person_person
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE canonicalize_fullname_on_insert();
|
||||
SQL
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,15 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
@@ -6,19 +17,19 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add a link between accompanying periods and users
|
||||
* Add a link between accompanying periods and users.
|
||||
*/
|
||||
final class Version20190701124238 extends AbstractMigration
|
||||
{
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD user_id INT DEFAULT NULL;');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD CONSTRAINT FK_E260A868A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE;');
|
||||
$this->addSql('CREATE INDEX IDX_E260A868A76ED395 ON chill_person_accompanying_period (user_id);');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP user_id');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP user_id');
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD user_id INT DEFAULT NULL;');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD CONSTRAINT FK_E260A868A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE;');
|
||||
$this->addSql('CREATE INDEX IDX_E260A868A76ED395 ON chill_person_accompanying_period (user_id);');
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,15 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
@@ -6,25 +17,24 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add an index for phonenumber and mobile number
|
||||
* Add an index for phonenumber and mobile number.
|
||||
*/
|
||||
final class Version20191106103452 extends AbstractMigration
|
||||
{
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql("CREATE INDEX phonenumber_trgm_idx
|
||||
ON public.chill_person_person USING gin
|
||||
(phonenumber gin_trgm_ops)");
|
||||
|
||||
$this->addSql("CREATE INDEX mobilenumber_trgm_idx
|
||||
ON public.chill_person_person USING gin
|
||||
(mobilenumber gin_trgm_ops)");
|
||||
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql("DROP INDEX phonenumber_trgm_idx");
|
||||
$this->addSql("DROP INDEX mobilenumber_trgm_idx");
|
||||
$this->addSql('DROP INDEX phonenumber_trgm_idx');
|
||||
$this->addSql('DROP INDEX mobilenumber_trgm_idx');
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('CREATE INDEX phonenumber_trgm_idx
|
||||
ON public.chill_person_person USING gin
|
||||
(phonenumber gin_trgm_ops)');
|
||||
|
||||
$this->addSql('CREATE INDEX mobilenumber_trgm_idx
|
||||
ON public.chill_person_person USING gin
|
||||
(mobilenumber gin_trgm_ops)');
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,15 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
@@ -6,26 +17,26 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add person alt name table
|
||||
* Add person alt name table.
|
||||
*/
|
||||
final class Version20200128084445 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 SEQUENCE chill_person_alt_name_id_seq INCREMENT BY 1 MINVALUE 1 START 1");
|
||||
$this->addSql("CREATE TABLE chill_person_alt_name (id INT NOT NULL, person_id INT DEFAULT NULL, key VARCHAR(255) NOT NULL, label TEXT NOT NULL, PRIMARY KEY(id))");
|
||||
$this->addSql("CREATE INDEX IDX_2628668E217BBB47 ON chill_person_alt_name (person_id)");
|
||||
$this->addSql("ALTER TABLE chill_person_alt_name ADD CONSTRAINT FK_2628668E217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE");
|
||||
}
|
||||
|
||||
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 IDX_2628668E217BBB47");
|
||||
$this->addSql("DROP TABLE chill_person_alt_name");
|
||||
$this->addSql("DROP SEQUENCE chill_person_alt_name_id_seq");
|
||||
$this->addSql('DROP INDEX IDX_2628668E217BBB47');
|
||||
$this->addSql('DROP TABLE chill_person_alt_name');
|
||||
$this->addSql('DROP SEQUENCE chill_person_alt_name_id_seq');
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
$this->addSql('CREATE SEQUENCE chill_person_alt_name_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
$this->addSql('CREATE TABLE chill_person_alt_name (id INT NOT NULL, person_id INT DEFAULT NULL, key VARCHAR(255) NOT NULL, label TEXT NOT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('CREATE INDEX IDX_2628668E217BBB47 ON chill_person_alt_name (person_id)');
|
||||
$this->addSql('ALTER TABLE chill_person_alt_name ADD CONSTRAINT FK_2628668E217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,15 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
@@ -6,149 +17,148 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add triggers for canicalizing alt names
|
||||
* Add triggers for canicalizing alt names.
|
||||
*/
|
||||
final class Version20200130213446 extends AbstractMigration
|
||||
{
|
||||
const CANONICALIZE_FULLNAME_ON_UPDATE = <<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION public.canonicalize_fullname_on_update()
|
||||
RETURNS trigger
|
||||
LANGUAGE 'plpgsql'
|
||||
COST 100
|
||||
VOLATILE NOT LEAKPROOF
|
||||
AS $BODY$
|
||||
DECLARE
|
||||
cur_alt_names CURSOR(pid INTEGER) FOR SELECT label FROM chill_person_alt_name WHERE person_id = pid;
|
||||
alt_name RECORD;
|
||||
fullname_canonicalized TEXT;
|
||||
BEGIN
|
||||
fullname_canonicalized := LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname)));
|
||||
OPEN cur_alt_names(pid:=NEW.id);
|
||||
LOOP
|
||||
FETCH cur_alt_names INTO alt_name;
|
||||
public const CANONICALIZE_FULLNAME_ON_ALT_NAME_ALTER = <<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION public.canonicalize_fullname_on_alt_name_alter()
|
||||
RETURNS trigger
|
||||
LANGUAGE 'plpgsql'
|
||||
COST 100
|
||||
VOLATILE NOT LEAKPROOF
|
||||
AS $BODY$
|
||||
DECLARE
|
||||
target_person_id INTEGER;
|
||||
cur_person CURSOR(pid INTEGER) FOR SELECT firstname, lastname FROM chill_person_person WHERE id = pid;
|
||||
person RECORD;
|
||||
cur_alt_names CURSOR(pid INTEGER) FOR SELECT label FROM chill_person_alt_name WHERE person_id = pid;
|
||||
alt_name RECORD;
|
||||
fullname_canonicalized TEXT;
|
||||
BEGIN
|
||||
IF TG_OP = 'INSERT' OR TG_OP = 'UPDATE'
|
||||
THEN target_person_id := NEW.person_id;
|
||||
ELSE target_person_id := OLD.person_id;
|
||||
END IF;
|
||||
|
||||
EXIT WHEN NOT FOUND;
|
||||
OPEN cur_person(pid:=target_person_id);
|
||||
FETCH cur_person INTO person;
|
||||
fullname_canonicalized := LOWER(UNACCENT(CONCAT(person.firstname, ' ', person.lastname)));
|
||||
-- loop over alt names
|
||||
OPEN cur_alt_names(pid:=target_person_id);
|
||||
LOOP
|
||||
FETCH cur_alt_names INTO alt_name;
|
||||
|
||||
fullname_canonicalized := CONCAT(fullname_canonicalized, ' ',
|
||||
LOWER(UNACCENT(alt_name.label)));
|
||||
END LOOP;
|
||||
CLOSE cur_alt_names;
|
||||
EXIT WHEN NOT FOUND;
|
||||
|
||||
IF fullname_canonicalized <> OLD.fullnameCanonical
|
||||
THEN
|
||||
UPDATE chill_person_person
|
||||
SET fullnameCanonical=fullname_canonicalized
|
||||
WHERE id=NEW.id;
|
||||
END IF;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$BODY$;
|
||||
SQL;
|
||||
|
||||
const CANONICALIZE_FULLNAME_ON_ALT_NAME_ALTER = <<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION public.canonicalize_fullname_on_alt_name_alter()
|
||||
RETURNS trigger
|
||||
LANGUAGE 'plpgsql'
|
||||
COST 100
|
||||
VOLATILE NOT LEAKPROOF
|
||||
AS $BODY$
|
||||
DECLARE
|
||||
target_person_id INTEGER;
|
||||
cur_person CURSOR(pid INTEGER) FOR SELECT firstname, lastname FROM chill_person_person WHERE id = pid;
|
||||
person RECORD;
|
||||
cur_alt_names CURSOR(pid INTEGER) FOR SELECT label FROM chill_person_alt_name WHERE person_id = pid;
|
||||
alt_name RECORD;
|
||||
fullname_canonicalized TEXT;
|
||||
BEGIN
|
||||
IF TG_OP = 'INSERT' OR TG_OP = 'UPDATE'
|
||||
THEN target_person_id := NEW.person_id;
|
||||
ELSE target_person_id := OLD.person_id;
|
||||
END IF;
|
||||
fullname_canonicalized := CONCAT(fullname_canonicalized, ' ',
|
||||
LOWER(UNACCENT(alt_name.label)));
|
||||
END LOOP;
|
||||
CLOSE cur_alt_names;
|
||||
CLOSE cur_person;
|
||||
|
||||
OPEN cur_person(pid:=target_person_id);
|
||||
FETCH cur_person INTO person;
|
||||
fullname_canonicalized := LOWER(UNACCENT(CONCAT(person.firstname, ' ', person.lastname)));
|
||||
-- loop over alt names
|
||||
OPEN cur_alt_names(pid:=target_person_id);
|
||||
LOOP
|
||||
FETCH cur_alt_names INTO alt_name;
|
||||
UPDATE chill_person_person
|
||||
SET fullnameCanonical=fullname_canonicalized
|
||||
WHERE id=target_person_id;
|
||||
|
||||
EXIT WHEN NOT FOUND;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$BODY$;
|
||||
SQL;
|
||||
|
||||
fullname_canonicalized := CONCAT(fullname_canonicalized, ' ',
|
||||
LOWER(UNACCENT(alt_name.label)));
|
||||
END LOOP;
|
||||
CLOSE cur_alt_names;
|
||||
CLOSE cur_person;
|
||||
public const CANONICALIZE_FULLNAME_ON_ALT_NAME_DELETE = <<<'SQL'
|
||||
CREATE TRIGGER canonicalize_fullname_on_alt_name_delete
|
||||
AFTER DELETE
|
||||
ON chill_person_alt_name
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE canonicalize_fullname_on_alt_name_alter();
|
||||
SQL;
|
||||
|
||||
UPDATE chill_person_person
|
||||
SET fullnameCanonical=fullname_canonicalized
|
||||
WHERE id=target_person_id;
|
||||
public const CANONICALIZE_FULLNAME_ON_ALT_NAME_INSERT = <<<'SQL'
|
||||
CREATE TRIGGER canonicalize_fullname_on_alt_name_insert
|
||||
AFTER INSERT
|
||||
ON chill_person_alt_name
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE canonicalize_fullname_on_alt_name_alter();
|
||||
SQL;
|
||||
|
||||
RETURN NEW;
|
||||
END;
|
||||
$BODY$;
|
||||
SQL;
|
||||
|
||||
const CANONICALIZE_FULLNAME_ON_ALT_NAME_INSERT = <<<SQL
|
||||
CREATE TRIGGER canonicalize_fullname_on_alt_name_insert
|
||||
AFTER INSERT
|
||||
ON chill_person_alt_name
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE canonicalize_fullname_on_alt_name_alter();
|
||||
SQL;
|
||||
|
||||
const CANONICALIZE_FULLNAME_ON_ALT_NAME_DELETE = <<<SQL
|
||||
CREATE TRIGGER canonicalize_fullname_on_alt_name_delete
|
||||
AFTER DELETE
|
||||
ON chill_person_alt_name
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE canonicalize_fullname_on_alt_name_alter();
|
||||
SQL;
|
||||
public const CANONICALIZE_FULLNAME_ON_ALT_NAME_UPDATE = <<<'SQL'
|
||||
CREATE TRIGGER canonicalize_fullname_on_alt_name_update
|
||||
AFTER UPDATE
|
||||
ON chill_person_alt_name
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE canonicalize_fullname_on_alt_name_alter();
|
||||
SQL;
|
||||
|
||||
public const CANONICALIZE_FULLNAME_ON_UPDATE = <<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION public.canonicalize_fullname_on_update()
|
||||
RETURNS trigger
|
||||
LANGUAGE 'plpgsql'
|
||||
COST 100
|
||||
VOLATILE NOT LEAKPROOF
|
||||
AS $BODY$
|
||||
DECLARE
|
||||
cur_alt_names CURSOR(pid INTEGER) FOR SELECT label FROM chill_person_alt_name WHERE person_id = pid;
|
||||
alt_name RECORD;
|
||||
fullname_canonicalized TEXT;
|
||||
BEGIN
|
||||
fullname_canonicalized := LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname)));
|
||||
OPEN cur_alt_names(pid:=NEW.id);
|
||||
LOOP
|
||||
FETCH cur_alt_names INTO alt_name;
|
||||
|
||||
EXIT WHEN NOT FOUND;
|
||||
|
||||
fullname_canonicalized := CONCAT(fullname_canonicalized, ' ',
|
||||
LOWER(UNACCENT(alt_name.label)));
|
||||
END LOOP;
|
||||
CLOSE cur_alt_names;
|
||||
|
||||
IF fullname_canonicalized <> OLD.fullnameCanonical
|
||||
THEN
|
||||
UPDATE chill_person_person
|
||||
SET fullnameCanonical=fullname_canonicalized
|
||||
WHERE id=NEW.id;
|
||||
END IF;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$BODY$;
|
||||
SQL;
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP TRIGGER canonicalize_fullname_on_alt_name_update ON chill_person_alt_name;');
|
||||
$this->addSql('DROP TRIGGER canonicalize_fullname_on_alt_name_insert ON chill_person_alt_name;');
|
||||
$this->addSql('DROP TRIGGER canonicalize_fullname_on_alt_name_delete ON chill_person_alt_name;');
|
||||
$this->addSql('DROP FUNCTION canonicalize_fullname_on_alt_name_alter();');
|
||||
$this->addSql(
|
||||
<<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION canonicalize_fullname_on_update() RETURNS TRIGGER AS
|
||||
$BODY$
|
||||
BEGIN
|
||||
IF NEW.firstname <> OLD.firstname OR NEW.lastname <> OLD.lastname
|
||||
THEN
|
||||
UPDATE chill_person_person
|
||||
SET fullnameCanonical=LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname)))
|
||||
WHERE id=NEW.id;
|
||||
END IF;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$BODY$ LANGUAGE PLPGSQL;
|
||||
SQL
|
||||
);
|
||||
}
|
||||
|
||||
const CANONICALIZE_FULLNAME_ON_ALT_NAME_UPDATE = <<<SQL
|
||||
CREATE TRIGGER canonicalize_fullname_on_alt_name_update
|
||||
AFTER UPDATE
|
||||
ON chill_person_alt_name
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE canonicalize_fullname_on_alt_name_alter();
|
||||
SQL;
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// update fullname
|
||||
$this->addSql("ALTER TABLE chill_person_person ALTER fullnamecanonical TYPE TEXT;");
|
||||
$this->addSql("ALTER TABLE chill_person_person ALTER fullnamecanonical DROP DEFAULT;");
|
||||
$this->addSql('ALTER TABLE chill_person_person ALTER fullnamecanonical TYPE TEXT;');
|
||||
$this->addSql('ALTER TABLE chill_person_person ALTER fullnamecanonical DROP DEFAULT;');
|
||||
// insert function and triggers
|
||||
$this->addSql(self::CANONICALIZE_FULLNAME_ON_UPDATE);
|
||||
$this->addSql(self::CANONICALIZE_FULLNAME_ON_ALT_NAME_ALTER);
|
||||
$this->addSql(self::CANONICALIZE_FULLNAME_ON_ALT_NAME_INSERT);
|
||||
$this->addSql(self::CANONICALIZE_FULLNAME_ON_ALT_NAME_DELETE);
|
||||
$this->addSql(self::CANONICALIZE_FULLNAME_ON_ALT_NAME_UPDATE);
|
||||
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql("DROP TRIGGER canonicalize_fullname_on_alt_name_update ON chill_person_alt_name;");
|
||||
$this->addSql("DROP TRIGGER canonicalize_fullname_on_alt_name_insert ON chill_person_alt_name;");
|
||||
$this->addSql("DROP TRIGGER canonicalize_fullname_on_alt_name_delete ON chill_person_alt_name;");
|
||||
$this->addSql("DROP FUNCTION canonicalize_fullname_on_alt_name_alter();");
|
||||
$this->addSql(<<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION canonicalize_fullname_on_update() RETURNS TRIGGER AS
|
||||
$BODY$
|
||||
BEGIN
|
||||
IF NEW.firstname <> OLD.firstname OR NEW.lastname <> OLD.lastname
|
||||
THEN
|
||||
UPDATE chill_person_person
|
||||
SET fullnameCanonical=LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname)))
|
||||
WHERE id=NEW.id;
|
||||
END IF;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$BODY$ LANGUAGE PLPGSQL;
|
||||
SQL
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,4 +1,15 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
@@ -6,10 +17,18 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add a relationship parent/child inside closing motives
|
||||
* Add a relationship parent/child inside closing motives.
|
||||
*/
|
||||
final class Version20200310090632 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 chill_person_closingmotive DROP parent_id');
|
||||
$this->addSql('ALTER TABLE chill_person_closingmotive DROP ordering');
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
@@ -20,12 +39,4 @@ final class Version20200310090632 extends AbstractMigration
|
||||
$this->addSql('CREATE INDEX IDX_92351ECE727ACA70 ON chill_person_closingmotive (parent_id)');
|
||||
$this->addsql("ALTER TABLE chill_person_closingmotive ADD ordering DOUBLE PRECISION DEFAULT '0' NOT NULL;");
|
||||
}
|
||||
|
||||
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_person_closingmotive DROP parent_id');
|
||||
$this->addSql('ALTER TABLE chill_person_closingmotive DROP ordering');
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,15 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
@@ -10,129 +21,130 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
*/
|
||||
final class Version20200422125935 extends AbstractMigration
|
||||
{
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP FUNCTION get_last_address(integer, date)');
|
||||
$this->addSql(<<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION public.get_last_address (
|
||||
pid integer,
|
||||
before_date date)
|
||||
RETURNS TABLE(
|
||||
person_id integer,
|
||||
address_id integer,
|
||||
streetaddress1 varchar(255),
|
||||
streetaddress2 varchar(255),
|
||||
validfrom date,
|
||||
postcode_label varchar(255),
|
||||
postcode_code varchar(100),
|
||||
postcode_id integer,
|
||||
isnoaddress boolean,
|
||||
country_name json,
|
||||
country_code varchar(3),
|
||||
country_id integer)
|
||||
AS
|
||||
$BODY$
|
||||
SELECT
|
||||
pid AS person_id,
|
||||
chill_main_address.id AS address_id,
|
||||
chill_main_address.streetaddress1,
|
||||
chill_main_address.streetaddress2,
|
||||
chill_main_address.validfrom,
|
||||
chill_main_postal_code.label,
|
||||
chill_main_postal_code.code,
|
||||
chill_main_postal_code.id AS postal_code_id,
|
||||
chill_main_address.isnoaddress AS isnoaddress,
|
||||
country.name,
|
||||
country.countrycode,
|
||||
country.id AS country_id
|
||||
FROM chill_main_address
|
||||
JOIN (
|
||||
SELECT
|
||||
chill_main_address.id AS address_id,
|
||||
validfrom,
|
||||
rank() OVER (PARTITION BY person_id ORDER BY validfrom DESC) as pos
|
||||
FROM chill_person_persons_to_addresses
|
||||
JOIN chill_main_address ON chill_person_persons_to_addresses.address_id = chill_main_address.id
|
||||
WHERE person_id = pid
|
||||
AND chill_main_address.validfrom <= before_date
|
||||
) AS ranking ON ranking.address_id = chill_main_address.id
|
||||
JOIN chill_main_postal_code ON chill_main_address.postcode_id = chill_main_postal_code.id
|
||||
JOIN country ON chill_main_postal_code.country_id = country.id
|
||||
WHERE ranking.pos = 1
|
||||
$BODY$
|
||||
LANGUAGE sql VOLATILE
|
||||
COST 100;
|
||||
SQL
|
||||
);
|
||||
|
||||
$this->addSql(<<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION get_last_address_isnoaddress (
|
||||
pid integer,
|
||||
before_date date)
|
||||
RETURNS BOOL AS
|
||||
$BODY$
|
||||
SELECT isnoaddress FROM get_last_address(pid, before_date)
|
||||
$BODY$
|
||||
LANGUAGE sql volatile
|
||||
COST 100;
|
||||
SQL
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP FUNCTION public.get_last_address_isnoaddress(integer, date);');
|
||||
$this->addSql('DROP FUNCTION get_last_address(integer, date)');
|
||||
$this->addSql(<<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION public.get_last_address (
|
||||
pid integer,
|
||||
before_date date)
|
||||
RETURNS TABLE(
|
||||
person_id integer,
|
||||
address_id integer,
|
||||
streetaddress1 varchar(255),
|
||||
streetaddress2 varchar(255),
|
||||
validfrom date,
|
||||
postcode_label varchar(255),
|
||||
postcode_code varchar(100),
|
||||
postcode_id integer,
|
||||
country_name json,
|
||||
country_code varchar(3),
|
||||
country_id integer)
|
||||
AS
|
||||
$BODY$
|
||||
SELECT
|
||||
pid AS person_id,
|
||||
chill_main_address.id AS address_id,
|
||||
chill_main_address.streetaddress1,
|
||||
chill_main_address.streetaddress2,
|
||||
chill_main_address.validfrom,
|
||||
chill_main_postal_code.label,
|
||||
chill_main_postal_code.code,
|
||||
chill_main_postal_code.id AS postal_code_id,
|
||||
country.name,
|
||||
country.countrycode,
|
||||
country.id AS country_id
|
||||
FROM chill_main_address
|
||||
JOIN (
|
||||
SELECT
|
||||
chill_main_address.id AS address_id,
|
||||
validfrom,
|
||||
rank() OVER (PARTITION BY person_id ORDER BY validfrom DESC) as pos
|
||||
FROM chill_person_persons_to_addresses
|
||||
JOIN chill_main_address ON chill_person_persons_to_addresses.address_id = chill_main_address.id
|
||||
WHERE person_id = pid
|
||||
AND chill_main_address.validfrom <= before_date
|
||||
) AS ranking ON ranking.address_id = chill_main_address.id
|
||||
JOIN chill_main_postal_code ON chill_main_address.postcode_id = chill_main_postal_code.id
|
||||
JOIN country ON chill_main_postal_code.country_id = country.id
|
||||
WHERE ranking.pos = 1
|
||||
$BODY$
|
||||
LANGUAGE sql VOLATILE
|
||||
COST 100;
|
||||
SQL
|
||||
$this->addSql(
|
||||
<<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION public.get_last_address (
|
||||
pid integer,
|
||||
before_date date)
|
||||
RETURNS TABLE(
|
||||
person_id integer,
|
||||
address_id integer,
|
||||
streetaddress1 varchar(255),
|
||||
streetaddress2 varchar(255),
|
||||
validfrom date,
|
||||
postcode_label varchar(255),
|
||||
postcode_code varchar(100),
|
||||
postcode_id integer,
|
||||
country_name json,
|
||||
country_code varchar(3),
|
||||
country_id integer)
|
||||
AS
|
||||
$BODY$
|
||||
SELECT
|
||||
pid AS person_id,
|
||||
chill_main_address.id AS address_id,
|
||||
chill_main_address.streetaddress1,
|
||||
chill_main_address.streetaddress2,
|
||||
chill_main_address.validfrom,
|
||||
chill_main_postal_code.label,
|
||||
chill_main_postal_code.code,
|
||||
chill_main_postal_code.id AS postal_code_id,
|
||||
country.name,
|
||||
country.countrycode,
|
||||
country.id AS country_id
|
||||
FROM chill_main_address
|
||||
JOIN (
|
||||
SELECT
|
||||
chill_main_address.id AS address_id,
|
||||
validfrom,
|
||||
rank() OVER (PARTITION BY person_id ORDER BY validfrom DESC) as pos
|
||||
FROM chill_person_persons_to_addresses
|
||||
JOIN chill_main_address ON chill_person_persons_to_addresses.address_id = chill_main_address.id
|
||||
WHERE person_id = pid
|
||||
AND chill_main_address.validfrom <= before_date
|
||||
) AS ranking ON ranking.address_id = chill_main_address.id
|
||||
JOIN chill_main_postal_code ON chill_main_address.postcode_id = chill_main_postal_code.id
|
||||
JOIN country ON chill_main_postal_code.country_id = country.id
|
||||
WHERE ranking.pos = 1
|
||||
$BODY$
|
||||
LANGUAGE sql VOLATILE
|
||||
COST 100;
|
||||
SQL
|
||||
);
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP FUNCTION get_last_address(integer, date)');
|
||||
$this->addSql(
|
||||
<<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION public.get_last_address (
|
||||
pid integer,
|
||||
before_date date)
|
||||
RETURNS TABLE(
|
||||
person_id integer,
|
||||
address_id integer,
|
||||
streetaddress1 varchar(255),
|
||||
streetaddress2 varchar(255),
|
||||
validfrom date,
|
||||
postcode_label varchar(255),
|
||||
postcode_code varchar(100),
|
||||
postcode_id integer,
|
||||
isnoaddress boolean,
|
||||
country_name json,
|
||||
country_code varchar(3),
|
||||
country_id integer)
|
||||
AS
|
||||
$BODY$
|
||||
SELECT
|
||||
pid AS person_id,
|
||||
chill_main_address.id AS address_id,
|
||||
chill_main_address.streetaddress1,
|
||||
chill_main_address.streetaddress2,
|
||||
chill_main_address.validfrom,
|
||||
chill_main_postal_code.label,
|
||||
chill_main_postal_code.code,
|
||||
chill_main_postal_code.id AS postal_code_id,
|
||||
chill_main_address.isnoaddress AS isnoaddress,
|
||||
country.name,
|
||||
country.countrycode,
|
||||
country.id AS country_id
|
||||
FROM chill_main_address
|
||||
JOIN (
|
||||
SELECT
|
||||
chill_main_address.id AS address_id,
|
||||
validfrom,
|
||||
rank() OVER (PARTITION BY person_id ORDER BY validfrom DESC) as pos
|
||||
FROM chill_person_persons_to_addresses
|
||||
JOIN chill_main_address ON chill_person_persons_to_addresses.address_id = chill_main_address.id
|
||||
WHERE person_id = pid
|
||||
AND chill_main_address.validfrom <= before_date
|
||||
) AS ranking ON ranking.address_id = chill_main_address.id
|
||||
JOIN chill_main_postal_code ON chill_main_address.postcode_id = chill_main_postal_code.id
|
||||
JOIN country ON chill_main_postal_code.country_id = country.id
|
||||
WHERE ranking.pos = 1
|
||||
$BODY$
|
||||
LANGUAGE sql VOLATILE
|
||||
COST 100;
|
||||
SQL
|
||||
);
|
||||
|
||||
$this->addSql(
|
||||
<<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION get_last_address_isnoaddress (
|
||||
pid integer,
|
||||
before_date date)
|
||||
RETURNS BOOL AS
|
||||
$BODY$
|
||||
SELECT isnoaddress FROM get_last_address(pid, before_date)
|
||||
$BODY$
|
||||
LANGUAGE sql volatile
|
||||
COST 100;
|
||||
SQL
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
@@ -12,12 +21,19 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
*/
|
||||
final class Version20210128152747 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('DROP SEQUENCE chill_person_not_duplicate_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_person_not_duplicate');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE SEQUENCE chill_person_not_duplicate_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
@@ -29,11 +45,4 @@ final class Version20210128152747 extends AbstractMigration
|
||||
$this->addSql('ALTER TABLE chill_person_not_duplicate ADD CONSTRAINT FK_BD211EE22C402DF5 FOREIGN KEY (person2_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_person_not_duplicate ADD CONSTRAINT FK_BD211EE2A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('DROP SEQUENCE chill_person_not_duplicate_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_person_not_duplicate');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
@@ -12,12 +21,19 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
*/
|
||||
final class Version20210318095831 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('DROP SEQUENCE chill_person_phone_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_person_phone');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
|
||||
@@ -26,11 +42,4 @@ final class Version20210318095831 extends AbstractMigration
|
||||
$this->addSql('CREATE INDEX IDX_72C1F87217BBB47 ON chill_person_phone (person_id)');
|
||||
$this->addSql('ALTER TABLE chill_person_phone ADD CONSTRAINT FK_72C1F87217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('DROP SEQUENCE chill_person_phone_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_person_phone');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
@@ -12,20 +21,20 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
*/
|
||||
final class Version20210325141540 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE chill_person_phone ADD type TEXT DEFAULT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your need
|
||||
$this->addSql('ALTER TABLE chill_person_phone DROP type');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE chill_person_phone ADD type TEXT DEFAULT NULL');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
@@ -9,46 +18,17 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Change model relation between Person and AccompagnyingPeriod
|
||||
* Migrate datas into new join table
|
||||
*
|
||||
* @author Mathieu Jaumotte mathieu.jaumotte@champs-libres.coop
|
||||
* Migrate datas into new join table.
|
||||
*/
|
||||
final class Version20210326113045 extends AbstractMigration
|
||||
{
|
||||
private $datas = [];
|
||||
|
||||
public function getDescription() : string
|
||||
{
|
||||
return 'Change model relation between Person and AccompagnyingPeriod, without losing datas when going up';
|
||||
}
|
||||
|
||||
/**
|
||||
* In these direction, there is no loss.
|
||||
*/
|
||||
public function up(Schema $schema) : void
|
||||
{
|
||||
// create join table
|
||||
$this->addSql('CREATE TABLE persons_accompanying_periods (person_id INT NOT NULL, accompanyingperiod_id INT NOT NULL, PRIMARY KEY(person_id, accompanyingperiod_id))');
|
||||
$this->addSql('CREATE INDEX IDX_49A3871F217BBB47 ON persons_accompanying_periods (person_id)');
|
||||
$this->addSql('CREATE INDEX IDX_49A3871F550B0C53 ON persons_accompanying_periods (accompanyingperiod_id)');
|
||||
$this->addSql('ALTER TABLE persons_accompanying_periods ADD CONSTRAINT FK_49A3871F217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE persons_accompanying_periods ADD CONSTRAINT FK_49A3871F550B0C53 FOREIGN KEY (accompanyingperiod_id) REFERENCES chill_person_accompanying_period (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
|
||||
// insert datas in new join table
|
||||
$this->addSql('INSERT INTO persons_accompanying_periods (person_id, accompanyingperiod_id) '
|
||||
. 'SELECT person_id, id as accompagnying_period_id FROM chill_person_accompanying_period WHERE person_id IS NOT NULL');
|
||||
|
||||
// drop column
|
||||
$this->addSql('DROP INDEX idx_64a4a621217bbb47');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP CONSTRAINT fk_64a4a621217bbb47');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP person_id');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The distinct clause makes that for each group of duplicates, it keeps only the first row in the returned result set.
|
||||
* Then we have only few lost datas. Lost datas: when many persons for one AccompanyingPeriod (keep only first person)
|
||||
* Then we have only few lost datas. Lost datas: when many persons for one AccompanyingPeriod (keep only first person).
|
||||
*/
|
||||
public function down(Schema $schema) : void
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// add column
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD person_id INT DEFAULT NULL');
|
||||
@@ -59,12 +39,39 @@ final class Version20210326113045 extends AbstractMigration
|
||||
$this->addSql('UPDATE chill_person_accompanying_period AS ap '
|
||||
. 'SET person_id = jt.person_id '
|
||||
. 'FROM ( '
|
||||
. 'SELECT DISTINCT ON (accompanyingperiod_id) accompanyingperiod_id AS id, person_id FROM persons_accompanying_periods '
|
||||
. 'ORDER BY id, person_id ASC '
|
||||
. 'SELECT DISTINCT ON (accompanyingperiod_id) accompanyingperiod_id AS id, person_id FROM persons_accompanying_periods '
|
||||
. 'ORDER BY id, person_id ASC '
|
||||
. ') AS jt '
|
||||
. 'WHERE ap.id = jt.id');
|
||||
|
||||
|
||||
// drop join table
|
||||
$this->addSql('DROP TABLE persons_accompanying_periods');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Change model relation between Person and AccompagnyingPeriod, without losing datas when going up';
|
||||
}
|
||||
|
||||
/**
|
||||
* In these direction, there is no loss.
|
||||
*/
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// create join table
|
||||
$this->addSql('CREATE TABLE persons_accompanying_periods (person_id INT NOT NULL, accompanyingperiod_id INT NOT NULL, PRIMARY KEY(person_id, accompanyingperiod_id))');
|
||||
$this->addSql('CREATE INDEX IDX_49A3871F217BBB47 ON persons_accompanying_periods (person_id)');
|
||||
$this->addSql('CREATE INDEX IDX_49A3871F550B0C53 ON persons_accompanying_periods (accompanyingperiod_id)');
|
||||
$this->addSql('ALTER TABLE persons_accompanying_periods ADD CONSTRAINT FK_49A3871F217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE persons_accompanying_periods ADD CONSTRAINT FK_49A3871F550B0C53 FOREIGN KEY (accompanyingperiod_id) REFERENCES chill_person_accompanying_period (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
|
||||
// insert datas in new join table
|
||||
$this->addSql('INSERT INTO persons_accompanying_periods (person_id, accompanyingperiod_id) '
|
||||
. 'SELECT person_id, id as accompagnying_period_id FROM chill_person_accompanying_period WHERE person_id IS NOT NULL');
|
||||
|
||||
// drop column
|
||||
$this->addSql('DROP INDEX idx_64a4a621217bbb47');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP CONSTRAINT fk_64a4a621217bbb47');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP person_id');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
@@ -8,38 +17,34 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add AccompanyingPeriod Origin table
|
||||
*
|
||||
* @author Mathieu Jaumotte mathieu.jaumotte@champs-libres.coop
|
||||
* Add AccompanyingPeriod Origin table.
|
||||
*/
|
||||
final class Version20210329090904 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP CONSTRAINT FK_E260A86856A273CC');
|
||||
|
||||
$this->addSql('DROP SEQUENCE chill_person_accompanying_period_origin_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_person_accompanying_period_origin');
|
||||
|
||||
$this->addSql('DROP INDEX IDX_E260A86856A273CC');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP origin_id');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add AccompanyingPeriod Origin table';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('CREATE SEQUENCE chill_person_accompanying_period_origin_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
$this->addSql('CREATE TABLE chill_person_accompanying_period_origin (id INT NOT NULL, label VARCHAR(255) NOT NULL, noActiveAfter DATE DEFAULT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_origin.noActiveAfter IS \'(DC2Type:date_immutable)\'');
|
||||
|
||||
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD origin_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD CONSTRAINT FK_E260A86856A273CC FOREIGN KEY (origin_id) REFERENCES chill_person_accompanying_period_origin (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('CREATE INDEX IDX_E260A86856A273CC ON chill_person_accompanying_period (origin_id)');
|
||||
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP CONSTRAINT FK_E260A86856A273CC');
|
||||
|
||||
$this->addSql('DROP SEQUENCE chill_person_accompanying_period_origin_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_person_accompanying_period_origin');
|
||||
|
||||
$this->addSql('DROP INDEX IDX_E260A86856A273CC');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP origin_id');
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
@@ -8,53 +17,48 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add AccompanyingPeriod Comment and Resource tables
|
||||
*
|
||||
* @author Mathieu Jaumotte mathieu.jaumotte@champs-libres.coop
|
||||
* Add AccompanyingPeriod Comment and Resource tables.
|
||||
*/
|
||||
final class Version20210329113152 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
{
|
||||
return 'Add AccompanyingPeriod Comment and Resource tables';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
{
|
||||
$this->addSql('CREATE SEQUENCE chill_person_accompanying_period_comment_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
$this->addSql('CREATE TABLE chill_person_accompanying_period_comment (id INT NOT NULL, creator_id INT NOT NULL, createdAt TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updatedAt TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, content TEXT NOT NULL, accompanyingPeriod_id INT NOT NULL, updatedBy_id INT NOT NULL, PRIMARY KEY(id))');
|
||||
|
||||
$this->addSql('CREATE INDEX IDX_CD960EF3D7FA8EF0 ON chill_person_accompanying_period_comment (accompanyingPeriod_id)');
|
||||
$this->addSql('CREATE INDEX IDX_CD960EF361220EA6 ON chill_person_accompanying_period_comment (creator_id)');
|
||||
$this->addSql('CREATE INDEX IDX_CD960EF365FF1AEC ON chill_person_accompanying_period_comment (updatedBy_id)');
|
||||
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_comment ADD CONSTRAINT FK_CD960EF3D7FA8EF0 FOREIGN KEY (accompanyingPeriod_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_comment ADD CONSTRAINT FK_CD960EF361220EA6 FOREIGN KEY (creator_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_comment ADD CONSTRAINT FK_CD960EF365FF1AEC FOREIGN KEY (updatedBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
|
||||
|
||||
$this->addSql('CREATE SEQUENCE chill_person_accompanying_period_resource_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
$this->addSql('CREATE TABLE chill_person_accompanying_period_resource (id INT NOT NULL, person_id INT DEFAULT NULL, comment_id INT DEFAULT NULL, accompanyingPeriod_id INT NOT NULL, thirdParty_id INT DEFAULT NULL, PRIMARY KEY(id))');
|
||||
|
||||
$this->addSql('CREATE INDEX IDX_DC78989FD7FA8EF0 ON chill_person_accompanying_period_resource (accompanyingPeriod_id)');
|
||||
$this->addSql('CREATE INDEX IDX_DC78989F3EA5CAB0 ON chill_person_accompanying_period_resource (thirdParty_id)');
|
||||
$this->addSql('CREATE INDEX IDX_DC78989F217BBB47 ON chill_person_accompanying_period_resource (person_id)');
|
||||
$this->addSql('CREATE INDEX IDX_DC78989FF8697D13 ON chill_person_accompanying_period_resource (comment_id)');
|
||||
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_resource ADD CONSTRAINT FK_DC78989FD7FA8EF0 FOREIGN KEY (accompanyingPeriod_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_resource ADD CONSTRAINT FK_DC78989F3EA5CAB0 FOREIGN KEY (thirdParty_id) REFERENCES chill_3party.third_party (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_resource ADD CONSTRAINT FK_DC78989F217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_resource ADD CONSTRAINT FK_DC78989FF8697D13 FOREIGN KEY (comment_id) REFERENCES chill_person_accompanying_period_comment (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP SEQUENCE chill_person_accompanying_period_resource_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_person_accompanying_period_resource');
|
||||
|
||||
$this->addSql('DROP SEQUENCE chill_person_accompanying_period_comment_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_person_accompanying_period_comment');
|
||||
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add AccompanyingPeriod Comment and Resource tables';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('CREATE SEQUENCE chill_person_accompanying_period_comment_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
$this->addSql('CREATE TABLE chill_person_accompanying_period_comment (id INT NOT NULL, creator_id INT NOT NULL, createdAt TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updatedAt TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, content TEXT NOT NULL, accompanyingPeriod_id INT NOT NULL, updatedBy_id INT NOT NULL, PRIMARY KEY(id))');
|
||||
|
||||
$this->addSql('CREATE INDEX IDX_CD960EF3D7FA8EF0 ON chill_person_accompanying_period_comment (accompanyingPeriod_id)');
|
||||
$this->addSql('CREATE INDEX IDX_CD960EF361220EA6 ON chill_person_accompanying_period_comment (creator_id)');
|
||||
$this->addSql('CREATE INDEX IDX_CD960EF365FF1AEC ON chill_person_accompanying_period_comment (updatedBy_id)');
|
||||
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_comment ADD CONSTRAINT FK_CD960EF3D7FA8EF0 FOREIGN KEY (accompanyingPeriod_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_comment ADD CONSTRAINT FK_CD960EF361220EA6 FOREIGN KEY (creator_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_comment ADD CONSTRAINT FK_CD960EF365FF1AEC FOREIGN KEY (updatedBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
|
||||
$this->addSql('CREATE SEQUENCE chill_person_accompanying_period_resource_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
$this->addSql('CREATE TABLE chill_person_accompanying_period_resource (id INT NOT NULL, person_id INT DEFAULT NULL, comment_id INT DEFAULT NULL, accompanyingPeriod_id INT NOT NULL, thirdParty_id INT DEFAULT NULL, PRIMARY KEY(id))');
|
||||
|
||||
$this->addSql('CREATE INDEX IDX_DC78989FD7FA8EF0 ON chill_person_accompanying_period_resource (accompanyingPeriod_id)');
|
||||
$this->addSql('CREATE INDEX IDX_DC78989F3EA5CAB0 ON chill_person_accompanying_period_resource (thirdParty_id)');
|
||||
$this->addSql('CREATE INDEX IDX_DC78989F217BBB47 ON chill_person_accompanying_period_resource (person_id)');
|
||||
$this->addSql('CREATE INDEX IDX_DC78989FF8697D13 ON chill_person_accompanying_period_resource (comment_id)');
|
||||
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_resource ADD CONSTRAINT FK_DC78989FD7FA8EF0 FOREIGN KEY (accompanyingPeriod_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_resource ADD CONSTRAINT FK_DC78989F3EA5CAB0 FOREIGN KEY (thirdParty_id) REFERENCES chill_3party.third_party (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_resource ADD CONSTRAINT FK_DC78989F217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_resource ADD CONSTRAINT FK_DC78989FF8697D13 FOREIGN KEY (comment_id) REFERENCES chill_person_accompanying_period_comment (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
@@ -8,59 +17,22 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Complete accompanying period table
|
||||
*
|
||||
* @author Mathieu Jaumotte mathieu.jaumotte@champs-libres.coop
|
||||
* Complete accompanying period table.
|
||||
*/
|
||||
final class Version20210329144338 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
return 'Complete AccompanyingPeriod table';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
{
|
||||
$this->addSql('CREATE TABLE accompanying_periods_scopes (accompanying_period_id INT NOT NULL, scope_id INT NOT NULL, PRIMARY KEY(accompanying_period_id, scope_id))');
|
||||
|
||||
$this->addSql('CREATE INDEX IDX_87C4EAB032A7A428 ON accompanying_periods_scopes (accompanying_period_id)');
|
||||
$this->addSql('CREATE INDEX IDX_87C4EAB0682B5931 ON accompanying_periods_scopes (scope_id)');
|
||||
|
||||
$this->addSql('ALTER TABLE accompanying_periods_scopes ADD CONSTRAINT FK_87C4EAB032A7A428 FOREIGN KEY (accompanying_period_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE accompanying_periods_scopes ADD CONSTRAINT FK_87C4EAB0682B5931 FOREIGN KEY (scope_id) REFERENCES scopes (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD step VARCHAR(32) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD intensity VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD createdBy_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD requestorPerson_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD requestorThirdParty_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD requestorAnonymous BOOLEAN NOT NULL DEFAULT \'false\'');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD emergency BOOLEAN NOT NULL DEFAULT \'false\'');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD confidential BOOLEAN NOT NULL DEFAULT \'false\'');
|
||||
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD CONSTRAINT FK_E260A8683174800F FOREIGN KEY (createdBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD CONSTRAINT FK_E260A86834269C3F FOREIGN KEY (requestorPerson_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD CONSTRAINT FK_E260A868CFE4D554 FOREIGN KEY (requestorThirdParty_id) REFERENCES chill_3party.third_party (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
|
||||
$this->addSql('CREATE INDEX IDX_E260A8683174800F ON chill_person_accompanying_period (createdBy_id)');
|
||||
$this->addSql('CREATE INDEX IDX_E260A86834269C3F ON chill_person_accompanying_period (requestorPerson_id)');
|
||||
$this->addSql('CREATE INDEX IDX_E260A868CFE4D554 ON chill_person_accompanying_period (requestorThirdParty_id)');
|
||||
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
{
|
||||
|
||||
$this->addSql('DROP TABLE accompanying_periods_scopes');
|
||||
|
||||
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP CONSTRAINT FK_E260A8683174800F');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP CONSTRAINT FK_E260A86834269C3F');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP CONSTRAINT FK_E260A868CFE4D554');
|
||||
|
||||
|
||||
$this->addSql('DROP INDEX IDX_E260A8683174800F');
|
||||
$this->addSql('DROP INDEX IDX_E260A86834269C3F');
|
||||
$this->addSql('DROP INDEX IDX_E260A868CFE4D554');
|
||||
|
||||
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP step');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP intensity');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP createdBy_id');
|
||||
@@ -69,6 +41,38 @@ final class Version20210329144338 extends AbstractMigration
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP requestorAnonymous');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP emergency');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP confidential');
|
||||
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Complete AccompanyingPeriod table';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('CREATE TABLE accompanying_periods_scopes (accompanying_period_id INT NOT NULL, scope_id INT NOT NULL, PRIMARY KEY(accompanying_period_id, scope_id))');
|
||||
|
||||
$this->addSql('CREATE INDEX IDX_87C4EAB032A7A428 ON accompanying_periods_scopes (accompanying_period_id)');
|
||||
$this->addSql('CREATE INDEX IDX_87C4EAB0682B5931 ON accompanying_periods_scopes (scope_id)');
|
||||
|
||||
$this->addSql('ALTER TABLE accompanying_periods_scopes ADD CONSTRAINT FK_87C4EAB032A7A428 FOREIGN KEY (accompanying_period_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE accompanying_periods_scopes ADD CONSTRAINT FK_87C4EAB0682B5931 FOREIGN KEY (scope_id) REFERENCES scopes (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD step VARCHAR(32) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD intensity VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD createdBy_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD requestorPerson_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD requestorThirdParty_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD requestorAnonymous BOOLEAN NOT NULL DEFAULT \'false\'');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD emergency BOOLEAN NOT NULL DEFAULT \'false\'');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD confidential BOOLEAN NOT NULL DEFAULT \'false\'');
|
||||
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD CONSTRAINT FK_E260A8683174800F FOREIGN KEY (createdBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD CONSTRAINT FK_E260A86834269C3F FOREIGN KEY (requestorPerson_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD CONSTRAINT FK_E260A868CFE4D554 FOREIGN KEY (requestorThirdParty_id) REFERENCES chill_3party.third_party (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
|
||||
$this->addSql('CREATE INDEX IDX_E260A8683174800F ON chill_person_accompanying_period (createdBy_id)');
|
||||
$this->addSql('CREATE INDEX IDX_E260A86834269C3F ON chill_person_accompanying_period (requestorPerson_id)');
|
||||
$this->addSql('CREATE INDEX IDX_E260A868CFE4D554 ON chill_person_accompanying_period (requestorThirdParty_id)');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
@@ -8,28 +17,26 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Rename table closinmotive
|
||||
*
|
||||
* @author Mathieu Jaumotte mathieu.jaumotte@champs-libres.coop
|
||||
* Rename table closinmotive.
|
||||
*/
|
||||
final class Version20210330164922 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
{
|
||||
return 'Rename table closinmotive';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_person_closingmotive RENAME TO chill_person_accompanying_period_closingmotive');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_closingmotive RENAME CONSTRAINT fk_92351ece727aca70 TO FK_72D110E8727ACA70');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period RENAME CONSTRAINT fk_64a4a621504cb38d TO FK_E260A868504CB38D');
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_closingmotive RENAME TO chill_person_closingmotive');
|
||||
$this->addSql('ALTER TABLE chill_person_closingmotive RENAME CONSTRAINT FK_72D110E8727ACA70 TO fk_92351ece727aca70');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period RENAME CONSTRAINT FK_E260A868504CB38D TO fk_64a4a621504cb38d');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Rename table closinmotive';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_person_closingmotive RENAME TO chill_person_accompanying_period_closingmotive');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_closingmotive RENAME CONSTRAINT fk_92351ece727aca70 TO FK_72D110E8727ACA70');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period RENAME CONSTRAINT fk_64a4a621504cb38d TO FK_E260A868504CB38D');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
@@ -8,41 +17,11 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Transform join table between Person and AccompanyingPeriod in Doctrine entity
|
||||
* Transform join table between Person and AccompanyingPeriod in Doctrine entity.
|
||||
*/
|
||||
final class Version20210331084527 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
{
|
||||
return 'Transform join table between Person and AccompanyingPeriod in Doctrine entity';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
{
|
||||
// 1
|
||||
$this->addSql('ALTER TABLE persons_accompanying_periods DROP CONSTRAINT persons_accompanying_periods_pkey');
|
||||
$this->addSql('ALTER TABLE persons_accompanying_periods RENAME TO chill_person_accompanying_period_participation');
|
||||
|
||||
// 2
|
||||
// SERIAL automatically create sequence with NEXTVAL()
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation ADD COLUMN id SERIAL NOT NULL PRIMARY KEY');
|
||||
// drop NEXTVAL() in column definition
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation ALTER id DROP DEFAULT');
|
||||
|
||||
// 3
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation ADD startDate DATE NOT NULL DEFAULT \'1970-01-01\'');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation ADD endDate DATE DEFAULT NULL');
|
||||
|
||||
// 4
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation DROP CONSTRAINT fk_49a3871f217bbb47');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation DROP CONSTRAINT fk_49a3871f550b0c53');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation ADD CONSTRAINT FK_A59DF89F217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation ADD CONSTRAINT FK_A59DF89F550B0C53 FOREIGN KEY (accompanyingperiod_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER INDEX idx_49a3871f217bbb47 RENAME TO IDX_A59DF89F217BBB47');
|
||||
$this->addSql('ALTER INDEX idx_49a3871f550b0c53 RENAME TO IDX_A59DF89F550B0C53');
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// 4
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation DROP CONSTRAINT FK_A59DF89F217BBB47');
|
||||
@@ -51,17 +30,47 @@ final class Version20210331084527 extends AbstractMigration
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation ADD CONSTRAINT fk_49a3871f550b0c53 FOREIGN KEY (accompanyingperiod_id) REFERENCES chill_person_accompanying_period (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER INDEX idx_a59df89f550b0c53 RENAME TO idx_49a3871f550b0c53');
|
||||
$this->addSql('ALTER INDEX idx_a59df89f217bbb47 RENAME TO idx_49a3871f217bbb47');
|
||||
|
||||
|
||||
// 3
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation DROP startDate');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation DROP endDate');
|
||||
|
||||
|
||||
// 2
|
||||
$this->addSql('DROP SEQUENCE chill_person_accompanying_period_participation_id_seq CASCADE');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation DROP id');
|
||||
|
||||
|
||||
// 1
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation RENAME TO persons_accompanying_periods');
|
||||
$this->addSql('ALTER TABLE persons_accompanying_periods ADD CONSTRAINT persons_accompanying_periods_pkey PRIMARY KEY (person_id, accompanyingperiod_id)');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Transform join table between Person and AccompanyingPeriod in Doctrine entity';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// 1
|
||||
$this->addSql('ALTER TABLE persons_accompanying_periods DROP CONSTRAINT persons_accompanying_periods_pkey');
|
||||
$this->addSql('ALTER TABLE persons_accompanying_periods RENAME TO chill_person_accompanying_period_participation');
|
||||
|
||||
// 2
|
||||
// SERIAL automatically create sequence with NEXTVAL()
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation ADD COLUMN id SERIAL NOT NULL PRIMARY KEY');
|
||||
// drop NEXTVAL() in column definition
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation ALTER id DROP DEFAULT');
|
||||
|
||||
// 3
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation ADD startDate DATE NOT NULL DEFAULT \'1970-01-01\'');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation ADD endDate DATE DEFAULT NULL');
|
||||
|
||||
// 4
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation DROP CONSTRAINT fk_49a3871f217bbb47');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation DROP CONSTRAINT fk_49a3871f550b0c53');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation ADD CONSTRAINT FK_A59DF89F217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation ADD CONSTRAINT FK_A59DF89F550B0C53 FOREIGN KEY (accompanyingperiod_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER INDEX idx_49a3871f217bbb47 RENAME TO IDX_A59DF89F217BBB47');
|
||||
$this->addSql('ALTER INDEX idx_49a3871f550b0c53 RENAME TO IDX_A59DF89F550B0C53');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
@@ -8,25 +17,24 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Rename sequence "closing motive"
|
||||
* Rename sequence "closing motive".
|
||||
*/
|
||||
final class Version20210419105054 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
{
|
||||
return 'rename sequence "closing motive"';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_person_closingmotive_id_seq RENAME TO '
|
||||
. 'chill_person_accompanying_period_closingmotive_id_seq');
|
||||
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_closingmotive_id_seq '
|
||||
. 'RENAME TO chill_person_closingmotive_id_seq');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'rename sequence "closing motive"';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_person_closingmotive_id_seq RENAME TO '
|
||||
. 'chill_person_accompanying_period_closingmotive_id_seq');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
@@ -8,24 +17,11 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* set label for origin as json
|
||||
* set label for origin as json.
|
||||
*/
|
||||
final class Version20210419105940 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
{
|
||||
return 'set label for origin as json';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_origin '
|
||||
. 'ALTER label TYPE JSON USING json_build_object(\'fr\', label)::jsonb');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_origin '
|
||||
. 'ALTER label DROP DEFAULT');
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this will keep the '"' at first and last character, but is acceptable
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_origin '
|
||||
@@ -33,4 +29,17 @@ final class Version20210419105940 extends AbstractMigration
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_origin '
|
||||
. 'ALTER label DROP DEFAULT');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'set label for origin as json';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_origin '
|
||||
. 'ALTER label TYPE JSON USING json_build_object(\'fr\', label)::jsonb');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_origin '
|
||||
. 'ALTER label DROP DEFAULT');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
@@ -8,22 +17,22 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* fix deprecated json array
|
||||
* fix deprecated json array.
|
||||
*/
|
||||
final class Version20210419112619 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_closingmotive.name IS \'(DC2Type:json_array)\'');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'fix deprecated json_array';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_closingmotive.name IS NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
{
|
||||
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_closingmotive.name IS \'(DC2Type:json_array)\'');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
@@ -8,16 +17,40 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Create Social action, Social Issue, Work Goal and Work Result
|
||||
* Create Social action, Social Issue, Work Goal and Work Result.
|
||||
*/
|
||||
final class Version20210426145930 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_person_social_action DROP CONSTRAINT FK_B7ABFAB8727ACA70');
|
||||
$this->addSql('ALTER TABLE chill_person_social_action_goal DROP CONSTRAINT FK_163CA4DD3DC32179');
|
||||
$this->addSql('ALTER TABLE chill_person_social_action_result DROP CONSTRAINT FK_CA98C58C3DC32179');
|
||||
$this->addSql('ALTER TABLE chill_person_social_action DROP CONSTRAINT FK_B7ABFAB85E7AA58C');
|
||||
$this->addSql('ALTER TABLE chill_person_social_issue DROP CONSTRAINT FK_7A484DAE727ACA70');
|
||||
$this->addSql('ALTER TABLE chill_person_social_action_goal DROP CONSTRAINT FK_163CA4DD667D1AFE');
|
||||
$this->addSql('ALTER TABLE chill_person_social_work_goal_result DROP CONSTRAINT FK_F3BAEEA9667D1AFE');
|
||||
$this->addSql('ALTER TABLE chill_person_social_action_result DROP CONSTRAINT FK_CA98C58C7A7B643');
|
||||
$this->addSql('ALTER TABLE chill_person_social_work_goal_result DROP CONSTRAINT FK_F3BAEEA97A7B643');
|
||||
$this->addSql('DROP SEQUENCE chill_person_social_action_id_seq CASCADE');
|
||||
$this->addSql('DROP SEQUENCE chill_person_social_issue_id_seq CASCADE');
|
||||
$this->addSql('DROP SEQUENCE chill_person_social_work_goal_id_seq CASCADE');
|
||||
$this->addSql('DROP SEQUENCE chill_person_social_work_result_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_person_social_action');
|
||||
$this->addSql('DROP TABLE chill_person_social_action_goal');
|
||||
$this->addSql('DROP TABLE chill_person_social_action_result');
|
||||
$this->addSql('DROP TABLE chill_person_social_issue');
|
||||
$this->addSql('DROP TABLE chill_person_social_work_goal');
|
||||
$this->addSql('DROP TABLE chill_person_social_work_goal_result');
|
||||
$this->addSql('DROP TABLE chill_person_social_work_result');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Create Social action, Social Issue, Work Goal and Work Result';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('CREATE SEQUENCE chill_person_social_action_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
$this->addSql('CREATE SEQUENCE chill_person_social_issue_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
@@ -50,28 +83,4 @@ final class Version20210426145930 extends AbstractMigration
|
||||
$this->addSql('ALTER TABLE chill_person_social_work_goal_result ADD CONSTRAINT FK_F3BAEEA9667D1AFE FOREIGN KEY (goal_id) REFERENCES chill_person_social_work_goal (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_person_social_work_goal_result ADD CONSTRAINT FK_F3BAEEA97A7B643 FOREIGN KEY (result_id) REFERENCES chill_person_social_work_result (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_person_social_action DROP CONSTRAINT FK_B7ABFAB8727ACA70');
|
||||
$this->addSql('ALTER TABLE chill_person_social_action_goal DROP CONSTRAINT FK_163CA4DD3DC32179');
|
||||
$this->addSql('ALTER TABLE chill_person_social_action_result DROP CONSTRAINT FK_CA98C58C3DC32179');
|
||||
$this->addSql('ALTER TABLE chill_person_social_action DROP CONSTRAINT FK_B7ABFAB85E7AA58C');
|
||||
$this->addSql('ALTER TABLE chill_person_social_issue DROP CONSTRAINT FK_7A484DAE727ACA70');
|
||||
$this->addSql('ALTER TABLE chill_person_social_action_goal DROP CONSTRAINT FK_163CA4DD667D1AFE');
|
||||
$this->addSql('ALTER TABLE chill_person_social_work_goal_result DROP CONSTRAINT FK_F3BAEEA9667D1AFE');
|
||||
$this->addSql('ALTER TABLE chill_person_social_action_result DROP CONSTRAINT FK_CA98C58C7A7B643');
|
||||
$this->addSql('ALTER TABLE chill_person_social_work_goal_result DROP CONSTRAINT FK_F3BAEEA97A7B643');
|
||||
$this->addSql('DROP SEQUENCE chill_person_social_action_id_seq CASCADE');
|
||||
$this->addSql('DROP SEQUENCE chill_person_social_issue_id_seq CASCADE');
|
||||
$this->addSql('DROP SEQUENCE chill_person_social_work_goal_id_seq CASCADE');
|
||||
$this->addSql('DROP SEQUENCE chill_person_social_work_result_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_person_social_action');
|
||||
$this->addSql('DROP TABLE chill_person_social_action_goal');
|
||||
$this->addSql('DROP TABLE chill_person_social_action_result');
|
||||
$this->addSql('DROP TABLE chill_person_social_issue');
|
||||
$this->addSql('DROP TABLE chill_person_social_work_goal');
|
||||
$this->addSql('DROP TABLE chill_person_social_work_goal_result');
|
||||
$this->addSql('DROP TABLE chill_person_social_work_result');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?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.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
@@ -8,16 +17,33 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Create tables for the entites AccomanyingPeriodWork, AccomanyingPeriodWorkGoal & Social/WorkEvaluation
|
||||
* Create tables for the entites AccomanyingPeriodWork, AccomanyingPeriodWorkGoal & Social/WorkEvaluation.
|
||||
*/
|
||||
final class Version20210427125700 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_result DROP CONSTRAINT FK_46E95929B99F6060');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_third_party DROP CONSTRAINT FK_83B57B86B99F6060');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_goal DROP CONSTRAINT FK_911B88FEC55C1209');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_goal_result DROP CONSTRAINT FK_3E37D1F37B14AD03');
|
||||
$this->addSql('DROP SEQUENCE chill_person_accompanying_period_work_id_seq CASCADE');
|
||||
$this->addSql('DROP SEQUENCE chill_person_accompanying_period_work_goal_id_seq CASCADE');
|
||||
$this->addSql('DROP SEQUENCE chill_person_social_work_evaluation_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_person_accompanying_period_work');
|
||||
$this->addSql('DROP TABLE chill_person_accompanying_period_work_result');
|
||||
$this->addSql('DROP TABLE chill_person_accompanying_period_work_third_party');
|
||||
$this->addSql('DROP TABLE chill_person_accompanying_period_work_goal');
|
||||
$this->addSql('DROP TABLE chill_person_accompanying_period_work_goal_result');
|
||||
$this->addSql('DROP TABLE chill_person_social_work_evaluation');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Create tables for the entites AccomanyingPeriodWork, AccomanyingPeriodWorkGoal & Social/WorkEvaluation';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('CREATE SEQUENCE chill_person_accompanying_period_work_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
$this->addSql('CREATE SEQUENCE chill_person_accompanying_period_work_goal_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
@@ -57,21 +83,4 @@ final class Version20210427125700 extends AbstractMigration
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_goal_result ADD CONSTRAINT FK_3E37D1F37A7B643 FOREIGN KEY (result_id) REFERENCES chill_person_social_work_result (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_person_social_work_evaluation ADD CONSTRAINT FK_2E23F3FEBF32A3DA FOREIGN KEY (socialAction_id) REFERENCES chill_person_social_action (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_result DROP CONSTRAINT FK_46E95929B99F6060');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_third_party DROP CONSTRAINT FK_83B57B86B99F6060');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_goal DROP CONSTRAINT FK_911B88FEC55C1209');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_goal_result DROP CONSTRAINT FK_3E37D1F37B14AD03');
|
||||
$this->addSql('DROP SEQUENCE chill_person_accompanying_period_work_id_seq CASCADE');
|
||||
$this->addSql('DROP SEQUENCE chill_person_accompanying_period_work_goal_id_seq CASCADE');
|
||||
$this->addSql('DROP SEQUENCE chill_person_social_work_evaluation_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_person_accompanying_period_work');
|
||||
$this->addSql('DROP TABLE chill_person_accompanying_period_work_result');
|
||||
$this->addSql('DROP TABLE chill_person_accompanying_period_work_third_party');
|
||||
$this->addSql('DROP TABLE chill_person_accompanying_period_work_goal');
|
||||
$this->addSql('DROP TABLE chill_person_accompanying_period_work_goal_result');
|
||||
$this->addSql('DROP TABLE chill_person_social_work_evaluation');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user