mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
household list of accompanying periods + upgrade DBAL version to 3.1
This commit is contained in:
@@ -17,7 +17,6 @@ class Version20150607231010 extends AbstractMigration
|
||||
. 'recorded.';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
@@ -28,36 +27,26 @@ class Version20150607231010 extends AbstractMigration
|
||||
'Migration can only be executed safely on \'postgresql\'.'
|
||||
);
|
||||
|
||||
// retrieve center for setting a default center
|
||||
$centers = $this->connection->fetchAll('SELECT id FROM centers');
|
||||
|
||||
if (count($centers) > 0) {
|
||||
$defaultCenterId = $centers[0]['id'];
|
||||
} else { // if no center, performs other checks
|
||||
//check if there are data in person table
|
||||
$nbPeople = $this->connection->fetchColumn('SELECT count(*) FROM person');
|
||||
|
||||
if ($nbPeople > 0) {
|
||||
// we have data ! We have to create a center !
|
||||
$newCenterId = $this->connection->fetchColumn('SELECT nextval(\'centers_id_seq\');');
|
||||
$this->addSql(
|
||||
'INSERT INTO centers (id, name) VALUES (:id, :name)',
|
||||
['id' => $newCenterId, 'name' => 'Auto-created center']
|
||||
);
|
||||
$defaultCenterId = $newCenterId;
|
||||
}
|
||||
}
|
||||
|
||||
$this->addSql('ALTER TABLE person ADD center_id INT');
|
||||
|
||||
// retrieve center for setting a default center
|
||||
$stmt = $this->connection->executeQuery("SELECT id FROM centers ORDER BY id ASC LIMIT 1");
|
||||
$center = $stmt->fetchOne();
|
||||
|
||||
if ($center !== false) {
|
||||
$defaultCenterId = $center['id'];
|
||||
}
|
||||
|
||||
if (isset($defaultCenterId)) {
|
||||
$this->addSql('UPDATE person SET center_id = :id', array('id' => $defaultCenterId));
|
||||
}
|
||||
|
||||
// this will fail if a person is defined, which should not happen any more at this
|
||||
// time of writing (2021-11-09)
|
||||
$this->addSql('ALTER TABLE person ALTER center_id SET NOT NULL');
|
||||
$this->addSql('ALTER TABLE person '
|
||||
. 'ADD CONSTRAINT FK_person_center FOREIGN KEY (center_id) '
|
||||
. 'REFERENCES centers (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE person ALTER center_id SET NOT NULL');
|
||||
$this->addSql('CREATE INDEX IDX_person_center ON person (center_id)');
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,6 @@ final class Version20200310090632 extends AbstractMigration
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE chill_person_closingmotive ADD parent_id INT DEFAULT NULL');
|
||||
$this->addSql('COMMENT ON COLUMN chill_person_closingmotive.name IS \'(DC2Type:json_array)\'');
|
||||
$this->addSql('ALTER TABLE chill_person_closingmotive ADD CONSTRAINT FK_92351ECE727ACA70 FOREIGN KEY (parent_id) REFERENCES chill_person_closingmotive (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$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;");
|
||||
|
@@ -24,6 +24,5 @@ final class Version20210419112619 extends AbstractMigration
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
{
|
||||
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_closingmotive.name IS \'(DC2Type:json_array)\'');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user