ITADN

entity first: allow dropping columns and tables

#2983Openjohnny-smitherson 创建于 2026-03-04
Area:entity-first
<!-- Welcome! Thank you for suggesting features! First of all, please star our repo. Your support is vital to the continued maintenance of SeaORM. Want to ask a question? You can reach us via: - Discord: https://discord.com/invite/uCPdDXzbdv - GitHub Discussions: https://github.com/SeaQL/sea-orm/discussions/new Make sure you have a clear feature specification before open an issue. Alternatively, please start an "Idea" thread on GitHub Discussions and let's formulate the solution together. --> ## 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](https://www.sea-ql.org/blog/2025-10-30-sea-orm-2.0/#footnotes) <!-- what is the use case? what is the expected outcome? --> ## Proposed Solutions - when `sync()` should perform a drop operation, stop and error out with `destructive 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 as `sync()` 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. ## Additional Information <!-- any other additional information that might be helpful -->
1 条评论