abbychau / diesel_cli_ext

It contains different code generation (not rust codegen) cli tools that may help your life with Diesel easier.
Apache License 2.0
111 stars 30 forks source link

Proposition to Community For Feature Implementation #64

Open anthonybtedesco opened 5 months ago

anthonybtedesco commented 5 months ago

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.

abbychau commented 5 months ago

how do you want to suggest making this happen?

anthonybtedesco commented 4 months ago

@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.

abbychau commented 4 months ago

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?