ETretyakov / hero-app

The Hero app is an example of ultimate setup for async web-service performance.
MIT License
93 stars 20 forks source link

Having trouble with Relationship between models #3

Open gmartindelcye opened 1 year ago

gmartindelcye commented 1 year ago

When trying to create let say a role table and permission table with the relation role->permissions, when using the prefix to name the tables and using the same to set the foreign_key produce the error:

prefix = "rol"

Foreign key associated with column 'rol_permissions.role_id' could not find table 'rol_roles' with which to generate a foreign key to target column 'id'

If I change the f"{prefix}_roles" with "rol_roles" both in the name and the foreign key it works.

  1. Is there a flag or what can I do to maintain the same code and have relationship between tables?
  2. What about using relationship between models from different models?