flask-realworld-example-app
flask-realworld-example-app copied to clipboard
Fix unique constraint on userprofile.user_id
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.
Also had this problem! Thanks @Willis0826 for providing a quick fix. Would like to see this get merged 🙂
+1 for this PR.
Also had this problem!
There's no problem when using SQLite, but the same problem when using PostgreSQL 9, 11, 12. Willing to see this get merged.
@mohamed-aziz Hi, I would like to ask for your review for this fix : ) thanks!