Skip to content

Duplicate key violation if start date in metadata is changed

If the start date of a network, station etc. is changed, the code doesn't realise that it already has an entry in the data base and tries to create a new one. The start time might be changed to fix a typo occasionally. This results in a duplicate key violation:

In ./seedpsd/models/db/shared/source.py for example:

doesn't find source if start date has been altered.

source = db_session.find_one( cls.find(network, station, location, channel, start, end) )

source = db_session.query(cls).filter_by(network=network,station=station,location=location,channel=channel).first()

This here will work. In case the start and end times differ, they would have to bee updated. As well, it might have some side effects in other parts of the code. The same will need to be done for network as well. I haven't done this so far, some guidance on how to do this would be great.