sqlalchemy / sqlalchemy/alembic
take use_alter=True, other FK / foreign key / foreignkey constraint rules into account when autogenerating create_table / drop_table
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.4k
- Forks
- 375
- PR merge metrics
- No merged PRs in 30d
Description
Migrated issue, originally created by Adrian Vogelsgesang (@vogelsgesang)
If the schema contains circular dependencies, the order of the CREATE TABLE statements is incorrect.
This is because metadata.sorted_tables (used here) returns the tables ordered alphabetically if there are circular dependencies.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in alembic/autogenerate/compare.py at the use of metadata.sorted_tables and trace how circular foreign-key dependencies affect create_table and drop_table generation. Review the handling of use_alter and related foreign-key rules; done means autogenerated statements respect those rules instead of falling back to alphabetical ordering for circular dependencies.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sqlalchemy
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100