abbychau/diesel_cli_ext

Proposition to Community For Feature Implementation

Opened this issue · 3 comments

I'm finding it annoying that everytime I update my database schema I lose all of my "models.rs macros" (derive statements and the like) and "impl blocks" and have to manually reformat the document to fix my structs and add my blocks. What if diesel_ext could only format the necessary bits of information rather than generate the entire schema.

Could this be done? I might be interested in working on a solution.

how do you want to suggest making this happen?

@abbychau Hey Abby, thanks for getting back I'm not entirely sure as I haven't looked at the code base but I'd imagine it would be a merge function on the newly generated models.rs and the current one in project scope. essentially just don't touch the derives and only edit the actual fields of the structs. Currently diesel_ext only generates based on the schema.rs file this would require taking the current models.rs into the process.

EDIT
I just looked at the options and it looks like there is an option to add derives. Would it be possible to get a list of the current derives used and have an option to add those by default. As for the other macros that may be present that could be done with the linux diff command and any line starting with '#' character.

I see...struct merge.

looks to be quick a specific workflow. Do you have some specific examples?

a file with structs u created, then a file with structs after regeneration, then the expected result.
what is the strategy for the fields with the same names?