dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #36209
Re: Duplicate PERIOD records - WHY no startdate+enddate constraint on PERIOD table?
Hi Calle,
we do have such a uniqueness constraint on period table. It is called
"period_periodtypeid_key". If it is not there then it means it somehow was
removed, then duplicates was inserted which prevents hibernate to put it
back when starting DHIS. You can try adding it manually with this SQL:
ALTER TABLE period ADD CONSTRAINT period_periodtypeid_key
UNIQUE(periodtypeid, startdate, enddate);
If that fails, please remove the duplicates and run it again.
best regards,
Lars
On Sat, Feb 28, 2015 at 11:39 PM, Calle Hedberg <calle.hedberg@xxxxxxxxx>
wrote:
> Hi
>
> I have over the last 2-3 weeks had multiple cases with duplicated PERIOD
> records in DHIS2 instances. In the latest case, it looks like capturing of
> daily data in some cases created duplicated period records - two records
> with identical startdate+enddate+periodtype, and sequential periodid. With
> most duplicate pairs, only the first periodid had a record in the datavalue
> table.
>
> I will try to track down the root cause of this duplicate generation, BUT
> what I don't understand is the lack of a periodtypeid+startdate+enddate
> constraint on the period table.
>
> Any periodtypeid+startdate+enddate combination would in reality be unique?
>
> I see there's an integrity check for it, but a constraint on the table is
> better, I would think.
>
> Besides - where can I view the code/sql used for those integrity checks?
>
> Regards
> calle
>
> *******************************************
>
> Calle Hedberg
>
> 46D Alma Road, 7700 Rosebank, SOUTH AFRICA
>
> Tel/fax (home): +27-21-685-6472
>
> Cell: +27-82-853-5352
>
> Iridium SatPhone: +8816-315-19274
>
> Email: calle.hedberg@xxxxxxxxx
>
> Skype: calle_hedberg
>
> *******************************************
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dhis2-devs
> Post to : dhis2-devs@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dhis2-devs
> More help : https://help.launchpad.net/ListHelp
>
>
Follow ups
References