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'