-
-
Notifications
You must be signed in to change notification settings - Fork 678
Description
Motivation
The 2.0 entity first workflow is very valuable for rapid prototyping. You can simply do the sync on app start and move fast.
But the very basic use-case of removing tables and columns is not covered. In rapid prototyping, you try out something, figure out you don't need it anymore, and then drop the data, and rewrite it in another way.
So that means you either have to clear out the whole database when you want to do destructive changes, or go back to writing migrations and never use the sync operations at all. Or you edit the database by hand. All of these defeat the purpose of using the sync operation.
Also, the fact that DROP operations are not executed is not warned/errored about in the sync() operation. Missing columns from entities are simply ignored. So you have to go back to the blog post and look at the footnotes
Proposed Solutions
- when
sync()should perform a drop operation, stop and error out withdestructive operation detected - would need to run DROP TABLE something; DROP COLUMN something; which is disabled for sync() - add
destructive_sync()function that does the same assync()but also allows running those operations - maybe add options for manual input
[Yes/no]type keyboard input to confirm drop of tables and columns
By supporting the whole lifecycle including DROPs you can adopt this entity-first workflow without resetting the db all the time or fiddling with it manually.