cal-itp/eligibility-server

Handle duplicate records more gracefully

Closed this issue · 0 comments

Instead of blowing up the entire import, just pass or something more benign, since we don't care about duplicates.

The following error is showing an insert for a duplicate (user_id, eligibility_id) pair, i.e. we've seen this user before in the file with the same eligibility_type:

2023-08-16T23:27:26.377814411Z + bin/init.sh
2023-08-16T23:27:26.475205459Z + flask init-db
2023-08-16T23:27:31.625888170Z Creating table...
2023-08-16T23:27:31.646114774Z Table created.
2023-08-16T23:27:31.646660982Z Importing users from: config/data.csv
2023-08-16T23:29:25.424788642Z Traceback (most recent call last):
...
2023-08-16T23:29:25.517656718Z sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) UNIQUE constraint failed: 
user_eligibility.user_id, user_eligibility.eligibility_id
2023-08-16T23:29:25.517668718Z [SQL: INSERT INTO user_eligibility (user_id, eligibility_id) VALUES (?, ?)]
2023-08-16T23:29:25.517673218Z [parameters: (5551, 1)]