grails-database-migration icon indicating copy to clipboard operation
grails-database-migration copied to clipboard

createTable/column is not behaving the same as addColumn

Open bassmartin opened this issue 9 years ago • 6 comments

When there a table creation written by the plugin createTable/column : java.lang.Integer = type: "INT" org.joda.time.LocalDateTime = type: "timestamp" (my dialect is not taken into account, it should be timestamptz)

When there is a column added written by the plugin addColumn : java.lang.Integer = type: "int4" org.joda.time.LocalDateTime = type: "timestamptz"

The schema is not consistent.

bassmartin avatar Apr 29 '16 15:04 bassmartin

@bassmartin Can you provide a sample project?

jameskleeh avatar Jul 02 '16 15:07 jameskleeh

@Schlogen see https://github.com/bassmartin/sample_grails_dbm

bassmartin avatar Jul 15 '16 19:07 bassmartin

Essentially the issue is here: https://github.com/liquibase/liquibase/blob/91a4e47bfe278e2ac17d1a8cca932554547fc5e7/liquibase-core/src/main/java/liquibase/datatype/core/DateTimeType.java#L144

The database is GormDatabase so it doesn't match any that are checked. The originalDefinition is timestamptz and the getName() resolves to timestamp.

jameskleeh avatar Jul 18 '16 14:07 jameskleeh

The root of this is how columns are handled when a column is missing vs when a table is missing:

How columns are handled when a table is missing: https://github.com/liquibase/liquibase/blob/0c2c0fea18abeda20ab9b9921b11bb3dfaad7d71/liquibase-core/src/main/java/liquibase/diff/output/changelog/core/MissingTableChangeGenerator.java#L70

How columns are handled when a column is missing: https://github.com/liquibase/liquibase/blob/0c2c0fea18abeda20ab9b9921b11bb3dfaad7d71/liquibase-core/src/main/java/liquibase/diff/output/changelog/core/MissingColumnChangeGenerator.java#L70

jameskleeh avatar Jul 18 '16 16:07 jameskleeh

The MissingColumnChangeGenerator should use the same logic as MissingTableChangeGenerator

nvoxland avatar Jul 18 '16 20:07 nvoxland

@nvoxland Is there an issue for this in your system anywhere?

jameskleeh avatar Oct 31 '16 12:10 jameskleeh