[hibernate-issues] [Hibernate-JIRA] Created: (HHH-6831) Alter and drop columns with hbm2ddl.auto=update

Bozhidar Bozhanov (JIRA) noreply at atlassian.com
Sun Nov 20 03:39:19 EST 2011


Alter and drop columns with hbm2ddl.auto=update
-----------------------------------------------

                 Key: HHH-6831
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6831
             Project: Hibernate Core
          Issue Type: Improvement
          Components: core
    Affects Versions: 3.6.8
            Reporter: Bozhidar Bozhanov


Currently hbm2ddl.auto=update only creates new columns. It doesn't alter or drop columns. This can be done fairly easily - just compare the entity model to the database metadata.

This may be configurable (on/off, to support legacy databases where not all columns and tables are mapped in entities). Note that dropping columns is only required if they are not-null, because if a column does not have a default value and is not-null, and is no longer mapped, the queries will fail. Instead of dropping, hbm2ddl.auto can simply set them to allow null values.

In addition to columns, this can be extended to constraints as well.

It would be really nice to have it so that you can mimic the development process with schemaless nosql databases, where the database depends entirely on the code that uses it.
Optionally, for those willing to risk it, this can even be used in production (after being tested on a stage server, of course). That way you would be able to go almost completely without database migration scripts. Whether this is a good practice is a different topic.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list