Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SchemaUpdate does not drop tables or delete columns

I am using SchemaUpdate to make changes to the database based on some configuration. It works fine when new tables or columns are added. However, it does not work when columns are deleted or tables are dropped. The mapping file does reflect these changes, but the SchemaUpdate does not seem to recognize this. I don't want to drop the tables and recreate them, as I want the data to be retained.

Does anyone know if this 'Delete and Drop' functionality is supported by SchemaUpdate?

Thanks

like image 499
Zuber Avatar asked Feb 28 '23 23:02

Zuber


1 Answers

It is not - SchemaUpdate will only add new tables/columns. This behavior is by design - your model can (for example) be mapped on a database that is used by many systems, and it could only use a subset of tables/columns. In that case, if SchemaUpdate did drop those columns and tables - it would break all those other systems.

See NHibernate SchemaUpdate for alternatives.

like image 147
maciejkow Avatar answered Mar 07 '23 08:03

maciejkow