Introduce a --diff-schema
flag for diesel migration generate
#3496
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.
If that flag is set diesel-cli will compare the current
schema.rs
file against the provided database and generate a corresponding stub for up/down migrations. This feature is not designed to generate perfect migrations all the times, but to generate the "boring" stuff most of the time.It currently handles:
It mostly generates the correct sql side types in most of the cases, although that depends a bit on what users specify (see the test cases for examples). It is expected that users need to check and potentially modify the generated migrations. I would expect that the type mapping get some improvements over time as people start using this feature
It cannot handle more complex patterns like changing primary keys or adding unique indices or migrating the data stored in tables itself. This is by definition not part of the designed feature set and will always require manual input from the user.