flask-realworld-example-app icon indicating copy to clipboard operation
flask-realworld-example-app copied to clipboard

Fix unique constraint on userprofile.user_id

Open Willis0826 opened this issue 5 years ago • 5 comments

I performed the database migration with postgres 9.6.6, and faced to the error :

sqlalchemy.exc.ProgrammingError: (psycopg2.errors.InvalidForeignKey) there is no unique constraint matching given keys for referenced table "userprofile"
 [SQL: '\nCREATE TABLE followers_assoc (\n\tfollower INTEGER, \n\tfollowed_by INTEGER, \n\tFOREIGN KEY(followed_by) REFERENCES userprofile (user_id), \n\tFOREIGN KEY(follower) REFERENCES userprofile (user_id)\n)\n\n']

After added the unique constraint to userprofile.user_id, the migration can be performed successfully.

Willis0826 avatar Oct 27 '19 02:10 Willis0826

Also had this problem! Thanks @Willis0826 for providing a quick fix. Would like to see this get merged 🙂

Kyle-Verhoog avatar Mar 31 '20 22:03 Kyle-Verhoog

+1 for this PR.

maateen avatar Apr 08 '20 05:04 maateen

Also had this problem!

genchilu avatar Oct 16 '20 16:10 genchilu

There's no problem when using SQLite, but the same problem when using PostgreSQL 9, 11, 12. Willing to see this get merged.

cool21540125 avatar Nov 07 '20 02:11 cool21540125

@mohamed-aziz Hi, I would like to ask for your review for this fix : ) thanks!

Willis0826 avatar Apr 17 '21 05:04 Willis0826