Electron100 / butane

An ORM for Rust with a focus on simplicity and on writing Rust, not SQL
Apache License 2.0
91 stars 13 forks source link

Add a `butane clean` command #46

Closed Electron100 closed 1 year ago

Electron100 commented 1 year ago

Clean current migration state. Deletes the current migration working state which is generated on each build. This can be used as a workaround to remove stale tables from the schema, as Butane does not currently auto-detect model removals. The next build will recreate with only tables for the extant models.

This is a workaround for #44

jayvdb commented 1 year ago

:+1:

It would be good to call this from within the test harness, so each test module doesnt have all of the migrations of all of the tests. Ideally it is run before the macros in the tests. Running it afterwards (in the db shutdown hook?) would delete potentially useful data, but I guess that doesnt matter much if the tests passed.

Electron100 commented 1 year ago

It would be good to call this from within the test harness, so each test module doesnt have all of the migrations of all of the tests

Maybe I'm being obtuse, but I don't think that will work. In my observation, within a given project cargo test builds all test binaries before executing any of them. Which is perhaps an argument for decoupling schema-generation-time from proc-macro-execution-time -- if they were decoupled then we could do as you suggest.

jayvdb commented 1 year ago

Of course you are right. Sorry for the distraction.