Add topological sorting for dumped views using TSort#337
Conversation
|
Not sure how do you deal with the Hound so made a separate commit to satisfy it |
|
This is great, thank you @msorc this one saved us a bunch of time. Any thoughts on merging this one @derekprior @calebhearth, as it relates to #263. Anvyl would be happy to help QA a pre-release version. |
| source_v = relation["source_table"] | ||
| dependent = relation["dependent_view"] |
There was a problem hiding this comment.
| source_v = relation["source_table"] | |
| dependent = relation["dependent_view"] | |
| source_v = "#{relation["source_schema"]}.#{relation["source_table"]}" | |
| dependent = "#{relation["dependent_schema"]}.#{relation["dependent_view"]}" |
Needs schema here in our app otherwise order is wrong.
| AND source_table.relkind IN ('m', 'v') AND dependent_view.relkind IN ('m', 'v') | ||
| ORDER BY dependent_view.relname; |
There was a problem hiding this comment.
| AND source_table.relkind IN ('m', 'v') AND dependent_view.relkind IN ('m', 'v') | |
| ORDER BY dependent_view.relname; | |
| AND source_table.relkind IN ('m', 'v') AND dependent_view.relkind IN ('m', 'v'); |
Iterating over result does not need this order so this line can be removed.
|
Anyone please merge this to clean up the schema diffs :( |
|
No, I don't want to rebase it myself :) |
|
Check my comments above - |
|
superseded by #398 |
This introduces topological sorting (https://ruby-doc.org/stdlib-2.6.8/libdoc/tsort/rdoc/TSort.html#method-i-tsort) for views in dumps which will sort views alphabetically and in case of dependencies between views will use a topological sorting.
That provides a consistent views ordering in database dumps and prevents of having occasional diffs in schema dumps.
Based on discussion here #263 and code samples #263 (comment) and #263 (comment)