DanCardin / sqlalchemy-declarative-extensions

Library to declare additional kinds of objects not natively supported by SqlAlchemy/Alembic.
https://sqlalchemy-declarative-extensions.readthedocs.io/en/latest/
Apache License 2.0
36 stars 7 forks source link

Add support for drop_all #83

Closed jacobeatsspam closed 2 months ago

jacobeatsspam commented 2 months ago

What it says on the tin. I'm unable to get drop_all to delete views, and I don't see the method mentioned in the documentation, so I'm assuming this needs to be plumbed still.

DanCardin commented 2 months ago

Indeed, this is not plumbed. I'm curious what your usecase is? My only personal reason for create_all is tests, where I've simply never had the need.

I expect it will be very straightfoward to add. basically just register a on before_drop or whatever, and compare_* with a desired metadata state of a MetaData() with nothing registered on it.

jacobeatsspam commented 2 months ago

Yeah, my use case is development workflow on a remote server, where I can't easily trash the entire database instance and start over. I'm also considering whether I want these in alembic at all. Currently, when I register views for alembic, they are re-created for every migration, and it's getting annoying editing every migration to remove redundant ones that haven't changed, but create_all issues a drop-create cycle, which is good enough for even production.

DanCardin commented 2 months ago

erm, why are they changing? i dont really understand lol.

jacobeatsspam commented 2 months ago

lol I'm lost too. The only thing I realized is that two of the views were deleted from the codebase and I forgot, and those are the only two being deleted. I unfortunately have to pause on this issue, but hope to investigate further in a few weeks.

DanCardin commented 2 months ago

Well whether or not you ultimately need it, like i said, it was straightforward to support.

jacobeatsspam commented 2 months ago

Tested locally and can confirm. All views dropped. I'll try to report back when I test with Procedures and Triggers. Thanks again!!