mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Fix migration classes namespaces.
This commit is contained in:
parent
84bb56664a
commit
ca3cb787d7
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
@ -1,26 +1,26 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
@ -30,7 +30,7 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
* - RENAMING :
|
||||
* - - date_of_birth TO birthdate
|
||||
* - - genre to gender
|
||||
*
|
||||
*
|
||||
*/
|
||||
class Version20150811152608 extends AbstractMigration
|
||||
{
|
||||
@ -42,7 +42,7 @@ class Version20150811152608 extends AbstractMigration
|
||||
$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,26 +1,26 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
@ -1,26 +1,26 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
@ -44,6 +44,6 @@ class Version20160310161006 extends AbstractMigration
|
||||
$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,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
@ -20,13 +20,13 @@ 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->abortIf(
|
||||
sizeof($personWithTwoAddressWithSameValidFrom) != 0,
|
||||
'There exists some person with multiple adress with the same validFrom'
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
@ -10,20 +10,20 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
*/
|
||||
class Version20170117131924 extends AbstractMigration
|
||||
{
|
||||
|
||||
|
||||
public $fields = array(
|
||||
'address_id' => 'integer',
|
||||
'streetaddress1' => 'varchar(255)',
|
||||
'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)',
|
||||
'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
|
||||
*/
|
||||
@ -35,19 +35,19 @@ CREATE OR REPLACE FUNCTION public.get_last_address (
|
||||
before_date date)
|
||||
RETURNS TABLE(
|
||||
person_id integer,
|
||||
address_id integer,
|
||||
streetaddress1 varchar(255),
|
||||
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),
|
||||
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
|
||||
SELECT
|
||||
pid AS person_id,
|
||||
chill_main_address.id AS address_id,
|
||||
chill_main_address.streetaddress1,
|
||||
@ -61,11 +61,11 @@ SELECT
|
||||
country.id AS country_id
|
||||
FROM chill_main_address
|
||||
JOIN (
|
||||
SELECT
|
||||
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
|
||||
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
|
||||
@ -78,7 +78,7 @@ LANGUAGE sql VOLATILE
|
||||
COST 100;
|
||||
SQL
|
||||
);
|
||||
|
||||
|
||||
// create function to get part of address
|
||||
foreach ($this->fields as $var => $type) {
|
||||
$this->addSql(sprintf(<<<'SQL'
|
||||
@ -111,7 +111,7 @@ DROP FUNCTION get_last_address_$var (
|
||||
SQL
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$this->addSQL(<<<SQL
|
||||
DROP FUNCTION public.get_last_address (
|
||||
pid integer,
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
@ -1,13 +1,13 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
* Correction: copie les infos de email vers contactInfo.
|
||||
*
|
||||
*
|
||||
* Previously, data from contact where stored in 'email' column
|
||||
*/
|
||||
final class Version20180820120000 extends AbstractMigration
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
@ -17,7 +17,7 @@ final class Version20181023101621 extends AbstractMigration
|
||||
$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$
|
||||
@ -42,7 +42,7 @@ SQL
|
||||
EXECUTE PROCEDURE canonicalize_fullname_on_update();
|
||||
SQL
|
||||
);
|
||||
|
||||
|
||||
$this->addSql(<<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION canonicalize_fullname_on_insert() RETURNS TRIGGER AS
|
||||
$BODY$
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
@ -15,7 +15,7 @@ final class Version20191106103452 extends AbstractMigration
|
||||
$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,6 +1,6 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
@ -44,7 +44,7 @@ BEGIN
|
||||
END;
|
||||
$BODY$;
|
||||
SQL;
|
||||
|
||||
|
||||
const CANONICALIZE_FULLNAME_ON_ALT_NAME_ALTER = <<<'SQL'
|
||||
CREATE OR REPLACE FUNCTION public.canonicalize_fullname_on_alt_name_alter()
|
||||
RETURNS trigger
|
||||
@ -89,7 +89,7 @@ BEGIN
|
||||
END;
|
||||
$BODY$;
|
||||
SQL;
|
||||
|
||||
|
||||
const CANONICALIZE_FULLNAME_ON_ALT_NAME_INSERT = <<<SQL
|
||||
CREATE TRIGGER canonicalize_fullname_on_alt_name_insert
|
||||
AFTER INSERT
|
||||
@ -97,7 +97,7 @@ CREATE TRIGGER canonicalize_fullname_on_alt_name_insert
|
||||
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
|
||||
@ -113,7 +113,7 @@ CREATE TRIGGER canonicalize_fullname_on_alt_name_update
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE canonicalize_fullname_on_alt_name_alter();
|
||||
SQL;
|
||||
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// update fullname
|
||||
@ -125,7 +125,7 @@ SQL;
|
||||
$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
|
||||
@ -150,5 +150,5 @@ SQL;
|
||||
SQL
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
@ -19,20 +19,20 @@ CREATE OR REPLACE FUNCTION public.get_last_address (
|
||||
before_date date)
|
||||
RETURNS TABLE(
|
||||
person_id integer,
|
||||
address_id integer,
|
||||
streetaddress1 varchar(255),
|
||||
address_id integer,
|
||||
streetaddress1 varchar(255),
|
||||
streetaddress2 varchar(255),
|
||||
validfrom date,
|
||||
postcode_label varchar(255),
|
||||
postcode_code varchar(100),
|
||||
validfrom date,
|
||||
postcode_label varchar(255),
|
||||
postcode_code varchar(100),
|
||||
postcode_id integer,
|
||||
isnoaddress boolean,
|
||||
country_name json,
|
||||
country_code varchar(3),
|
||||
country_name json,
|
||||
country_code varchar(3),
|
||||
country_id integer)
|
||||
AS
|
||||
$BODY$
|
||||
SELECT
|
||||
SELECT
|
||||
pid AS person_id,
|
||||
chill_main_address.id AS address_id,
|
||||
chill_main_address.streetaddress1,
|
||||
@ -47,11 +47,11 @@ SELECT
|
||||
country.id AS country_id
|
||||
FROM chill_main_address
|
||||
JOIN (
|
||||
SELECT
|
||||
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
|
||||
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
|
||||
@ -90,19 +90,19 @@ CREATE OR REPLACE FUNCTION public.get_last_address (
|
||||
before_date date)
|
||||
RETURNS TABLE(
|
||||
person_id integer,
|
||||
address_id integer,
|
||||
streetaddress1 varchar(255),
|
||||
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),
|
||||
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
|
||||
SELECT
|
||||
pid AS person_id,
|
||||
chill_main_address.id AS address_id,
|
||||
chill_main_address.streetaddress1,
|
||||
@ -116,11 +116,11 @@ SELECT
|
||||
country.id AS country_id
|
||||
FROM chill_main_address
|
||||
JOIN (
|
||||
SELECT
|
||||
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
|
||||
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
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
@ -16,12 +16,12 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
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.
|
||||
*/
|
||||
@ -33,17 +33,17 @@ final class Version20210326113045 extends AbstractMigration
|
||||
$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)
|
||||
@ -63,7 +63,7 @@ final class Version20210326113045 extends AbstractMigration
|
||||
. 'ORDER BY id, person_id ASC '
|
||||
. ') AS jt '
|
||||
. 'WHERE ap.id = jt.id');
|
||||
|
||||
|
||||
// drop join table
|
||||
$this->addSql('DROP TABLE persons_accompanying_periods');
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
@ -24,22 +24,22 @@ final class Version20210329090904 extends AbstractMigration
|
||||
$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');
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
@ -23,29 +23,29 @@ final class Version20210329113152 extends AbstractMigration
|
||||
{
|
||||
$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
|
||||
@ -55,6 +55,6 @@ final class Version20210329113152 extends AbstractMigration
|
||||
|
||||
$this->addSql('DROP SEQUENCE chill_person_accompanying_period_comment_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_person_accompanying_period_comment');
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
@ -22,13 +22,13 @@ final class Version20210329144338 extends AbstractMigration
|
||||
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');
|
||||
@ -37,11 +37,11 @@ final class Version20210329144338 extends AbstractMigration
|
||||
$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)');
|
||||
@ -50,17 +50,17 @@ final class Version20210329144338 extends AbstractMigration
|
||||
|
||||
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 +69,6 @@ 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');
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
@ -16,23 +16,23 @@ final class Version20210331084527 extends AbstractMigration
|
||||
{
|
||||
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');
|
||||
@ -41,7 +41,7 @@ final class Version20210331084527 extends AbstractMigration
|
||||
$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
|
||||
{
|
||||
// 4
|
||||
@ -51,15 +51,15 @@ 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)');
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
namespace Chill\PersonBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
Loading…
x
Reference in New Issue
Block a user