From 3e3f20993d758c719dea09062bb76dfd6b52df47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 28 Apr 2023 15:55:41 +0200 Subject: [PATCH] fix migration after test on real data --- .../migrations/Version20230427102309.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20230427102309.php b/src/Bundle/ChillPersonBundle/migrations/Version20230427102309.php index 7398a2292..662c11d9a 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20230427102309.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20230427102309.php @@ -144,8 +144,9 @@ final class Version20230427102309 extends AbstractMigration $this->addSql(<<<'SQL' INSERT INTO chill_person_accompanying_period_step_history (id, period_id, enddate, startdate, step, createdat, updatedat) - SELECT nextval('chill_person_accompanying_period_step_history_id_seq'), accompanyingperiod_id, NULL, last_date + '2 years'::interval, 'CONFIRMED_INACTIVE_LONG', NOW(), NOW() - FROM inactive_long; + SELECT nextval('chill_person_accompanying_period_step_history_id_seq'), period_id, NULL, sq.g, 'CONFIRMED_INACTIVE_LONG', NOW(), NOW() + FROM (SELECT GREATEST(MAX(startdate), MAX(enddate)) AS g, period_id FROM chill_person_accompanying_period_step_history GROUP BY period_id) AS sq + JOIN inactive_long ON sq.period_id = inactive_long.accompanyingperiod_id SQL); $this->addSql(<<<'SQL' @@ -173,8 +174,9 @@ final class Version20230427102309 extends AbstractMigration $this->addSql(<<<'SQL' INSERT INTO chill_person_accompanying_period_step_history (id, period_id, enddate, startdate, step, createdat, updatedat) - SELECT nextval('chill_person_accompanying_period_step_history_id_seq'), accompanyingperiod_id, NULL, last_date + '6 months'::interval, 'CONFIRMED_INACTIVE_SHORT', NOW(), NOW() - FROM inactive_long; + SELECT nextval('chill_person_accompanying_period_step_history_id_seq'), period_id, NULL, sq.g, 'CONFIRMED_INACTIVE_SHORT', NOW(), NOW() + FROM (SELECT GREATEST(MAX(startdate), MAX(enddate)) AS g, period_id FROM chill_person_accompanying_period_step_history GROUP BY period_id) AS sq + JOIN inactive_long ON sq.period_id = inactive_long.accompanyingperiod_id SQL); $this->addSql(<<<'SQL'