feat: Add migration graph subcommand to generate a graph for visualization - #643
feat: Add migration graph subcommand to generate a graph for visualization#643ElijahAhianyo wants to merge 8 commits into
Conversation
|
| Project | cot |
| Branch | elijah/migration-graph |
| Testbed | github-ubuntu-latest |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result microseconds (µs) (Result Δ%) | Upper Boundary microseconds (µs) (Limit %) |
|---|---|---|---|
| empty_router/empty_router | 📈 view plot 🚷 view threshold | 13,443.00 µs(+54.90%)Baseline: 8,678.27 µs | 16,573.66 µs (81.11%) |
| json_api/json_api | 📈 view plot 🚷 view threshold | 1,016.40 µs(-3.22%)Baseline: 1,050.26 µs | 1,370.15 µs (74.18%) |
| nested_routers/nested_routers | 📈 view plot 🚷 view threshold | 961.45 µs(-2.17%)Baseline: 982.77 µs | 1,255.98 µs (76.55%) |
| single_root_route/single_root_route | 📈 view plot 🚷 view threshold | 924.80 µs(-2.28%)Baseline: 946.35 µs | 1,218.60 µs (75.89%) |
| single_root_route_burst/single_root_route_burst | 📈 view plot 🚷 view threshold | 17,608.00 µs(+3.02%)Baseline: 17,091.19 µs | 21,557.42 µs (81.68%) |
| // canvas regardless of where it's rendered. | ||
| let _ = writeln!( | ||
| out, | ||
| "%%{{init: {{'theme': 'base', 'themeVariables': {{'background': 'transparent'}}}}}}%%" |
There was a problem hiding this comment.
Setting the background to transparent, on some occasions, doesn't work well with dark mode. It sometimes leaves a white background. check example here. I think the best way to handle this is to set styles for dark mode and light mode themes and also have users specify themes in the CLI but also provide a senseble default. I didn't want to spend time doing that in this PR and its also very low priority since the point is to allow users to visualize the graph, not necessarily to render it on a page.
| /// # Errors | ||
| /// | ||
| /// Returns an error if the dependency graph cannot be generated | ||
| pub fn to_graph(&self, format: GraphFormat) -> Result<String> { |
There was a problem hiding this comment.
I'm not quite sure if we should expose this as a public API. Public API means it's difficult to change/remove, and I believe it's not a functionality that would be particularly useful outside of the CLI. What's even more important, this functionality lies completely outside of the "MigrationEngine" scope. The role of this struct is to handle applying and rolling back migrations in a safe manner. Rendering a graph is pretty much unrelated to that.
I think we should remove this from MigrationEngine and instead it should just be a separate feature accessible only through the CLI subcommand. We'll probably need to add a getter that will return the migrations slice in the MigrationEngine.
There was a problem hiding this comment.
yeah I completely agree. should've done a better job with the abstraction
There was a problem hiding this comment.
I've moved this into a GraphExporter struct now
Description
Add graph subcommand to the migration subcommand to generate graphs in Graphiz dot format and mermaidjs.
Example usage
By default, this uses the dot format and prints to stdout.
This is analogous to :
> cargo run migration graph --format dotYou can also specify an output file to write the output to :
Type of change