grails - Does removing a property from a domain class cause an automatic update to the schema, whereby the corresponding column is dropped? -
I'm kind of new on Grails. I've worked a bit with it, but not so much though I am very familiar with Java. Regarding the question schema update, I understand that Grails creates mapping to be seen in hibernation by looking at domain classes, and so if I add a new property, Grails will automatically add a column for that property in the database. Is Reverse also True? If I remove an asset, is that column removed? I am not seeing that behavior and so I am thinking that this is a configuration problem.
If I want to go into a more robust database-management, then I guess I have to use something like Database-Management plugin or LIQUIDB. However, the project I am working on is very simple and for the moment, we have not decided that we are still going in that direction.
In your Liquibase is a great library and it's popular, so it's easy to get support for both. Once you get points in development, then when your schema is stable, then you should use the plugin. dbCreate settings
DataSource.groovy Depends on If it is
create or
create-drop , then everything is all set to start again. If this is a
update , then get new tables and columns. If this is some other setting then no changes are made.
Update does not do that which most people expect. It is pessimistic and will not make such changes which can result in data loss or corruption. Therefore, it can not even change the size of a column, even if it is broad (like
VARCHAR (50) ->
VARCHAR (200) ). It will not add indexed. This will add a new column, which is specified as a null-empty, but it will add it as faucet due to the already inserted rows not valid. But it will not leave a column or table so you can easily find in that scenario where you can rename a column and end it with two - old and new.
Comments
Post a Comment