Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Foreign Key Contraints (and others) Naming convention #331

Open
BaccanoMob opened this issue Jan 6, 2025 · 0 comments
Open

[FEATURE] Foreign Key Contraints (and others) Naming convention #331

BaccanoMob opened this issue Jan 6, 2025 · 0 comments

Comments

@BaccanoMob
Copy link

Currently, the name is {primary_key_table}{column_name}_fk, which is not ideal when you use that some primary key for multiple foreign keys.

With reference to Alembic docs, for foreign key constraint format may be as below,

"fk" - fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s

For example, Hero Table with id referenced by Team table will be like fk_hero_id_team

Other constraints if needed
"ix" - ix_%(column_0_label)s
"uq" - uq_%(table_name)s_%(column_0_name)s
"ck" - ck_%(table_name)s_%(constraint_name)s
"pk" - pk_%(table_name)s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant