Skip to content

Add unique constraint to prevent duplicate measurement data#461

Open
maltehuebner wants to merge 1 commit intomainfrom
fix/data-unique-constraint
Open

Add unique constraint to prevent duplicate measurement data#461
maltehuebner wants to merge 1 commit intomainfrom
fix/data-unique-constraint

Conversation

@maltehuebner
Copy link
Contributor

Summary

  • Add unique constraint on (station_id, pollutant, date_time) to data table
  • Handle UniqueConstraintViolationException in PostgisPersister
  • Also adds null check for ValueDataConverter::convert() return value

Context

Without a unique constraint, repeated imports (e.g. retries, overlapping fetches) could insert duplicate rows for the same measurement. The constraint ensures data integrity at the database level.

Test plan

  • Generate and run Doctrine migration: php bin/console doctrine:migrations:diff then php bin/console doctrine:migrations:migrate
  • Verify importing the same data twice does not cause errors
  • Verify normal import flow still works

🤖 Generated with Claude Code

Add a unique constraint on (station_id, pollutant, date_time) to the
data table. This prevents the same measurement from being imported
multiple times. The PostgisPersister now catches
UniqueConstraintViolationException to handle re-imports gracefully.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant