Feature: avoid duplicates for the same period in acc period user history

This commit is contained in:
2023-06-27 15:30:44 +02:00
parent 90be68002a
commit a7c3089736
2 changed files with 64 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
kind: Feature
body: "Force accompanying period user history to be unique for the same period and
stardate/enddate [:warning: may encounter migration issue]"
time: 2023-06-27T15:16:15.775571488+02:00
custom:
Issue: ""
Long: "If some issue is encountered during migration, use this SQL to find the line which are in conflict, examine the problem and delete some of the concerning line
```sql
-- to see the line which are in conflict with another one
SELECT o.*
FROM chill_person_accompanying_period_user_history o
JOIN chill_person_accompanying_period_user_history c ON o.id < c.id AND o.accompanyingperiod_id = c.accompanyingperiod_id
WHERE tsrange(o.startdate, o.enddate, '[)') && tsrange(c.startdate, c.enddate, '[)')
ORDER BY accompanyingperiod_id;
-- to examine line in conflict for a given accompanyingperiod_id (given by the previous query)
SELECT * FROM chill_person_accompanying_period_user_history WHERE accompanyingperiod_id = IIIIDDDD order by startdate, enddate;
```
"