fahrzeit-ch / plow_report

Simple App to track snow plowing drives
1 stars 0 forks source link

ActiveRecord::InvalidForeignKey: PG::ForeignKeyViolation: ERROR: insert or update on table "drives" violates foreign key constraint #335

Closed stestaub closed 3 years ago

stestaub commented 3 years ago

https://rollbar.com/stefan.staub/plow-track/items/24

ActiveRecord::InvalidForeignKey: PG::ForeignKeyViolation: ERROR: insert or update on table "drives" violates foreign key constraint "fk_rails_f6cb6fcfda" DETAIL: Key (tour_id)=(db0e8768-c0b8-45ef-815d-e34618c5f602) is not present in table "tours". : INSERT INTO "drives" ("start", "end", "created_at", "updated_at", "driver_id", "customer_id", "site_id", "tour_id") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id"

stestaub commented 3 years ago

Reproduction steps:

The created drives will sent to the server, but the tour is not created yet. Therefore the drives can not be assigned to a tour.

stestaub commented 3 years ago

A straight forward solution to this would be to already create the tour in the database as soon as it is started. Then the tour will be synced as well

stestaub commented 3 years ago

This can be closed as there is no action required on server side