-
-
Notifications
You must be signed in to change notification settings - Fork 121
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
Add support for topological sorting of tables and aggregate function changes #237
Open
joshainglis
wants to merge
15
commits into
djrobstep:master
Choose a base branch
from
joshainglis:upstream-pr
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Conflicts: # poetry.lock # pyproject.toml
# Conflicts: # poetry.lock # pyproject.toml
Updated pyproject.toml and poetry.lock files to switch from psycopg2-binary to psycopg2 for postgres database functionality. The psycopg2-binary package is a stand-alone package that's meant for easy installation purposes and not recommended for production environments. For production-ready functionality and better maintainability, we switched to psycopg2. Accordingly, references to psycopg2-binary were replaced with psycopg2, and binary files related with psycopg2-binary were removed from poetry.lock.
joshainglis
commented
Mar 15, 2024
pyproject.toml
Outdated
# schemainspect = {path="../schemainspect", develop=true} | ||
schemainspect = ">=3.1.1663480743" | ||
#schemainspect = { path = "../schemainspect", develop = true } | ||
schemainspect = { git = "https://github.com/joshainglis/schemainspect.git", rev = "79b3fbdb9c22252574578e8f83dcb7f85ebaf69a" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will need to update this prior to merging if djrobstep/schemainspect#90 gets merged
Is there a pre-built docker image available to test? |
@sgtsquiggs Good idea, just pushed one up. Try |
Also added a few more improvements to schemainspect:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request builds on the changes made in djrobstep/schemainspect#90 to add a few enhancements to migra:
Topological sorting of tables
When generating the SQL statements to create tables, migra now takes into account the full dependency tree between tables. It builds a dependency graph using the new
dependents
attribute added toInspectedTable
in schemainspect. It then sorts the tables topologically based on this graph. This now handles cases where a column is an array of a composite type.Support for changes to aggregate functions
The
get_selectable_changes
function inchanges.py
was updated to include aggregate functions (relationtype 'a') in addition to regular functions when generating SQL statements for function changes.This change utilizes the new
InspectedAggFunction
class and related functionality added in schemainspect to make migra aware of aggregate functions and include them in schema comparisons and migrations.The
Changes
class has a newcomments
property that returns a partial function for generating SQL statements for changes to comments on database objects. Theadd_all_changes
method was updated to include creating and dropping comments at the appropriate points in the migration process.This integrates with the new comment inspection capabilities added in schemainspect, allowing migra to include comment changes as part of schema migrations.
With these changes, migra is now able to generate more accurate migration scripts, particularly in cases involving table dependencies, aggregate functions, and object comments. It can produce migrations that run correctly on the first try in more cases than before.
Please let me know if you have any questions or feedback on these changes. I'm happy to discuss further or make revisions as needed.