multiple, conflicting postgres sequences are generated for each new domain class.
The diff generates an explicit sequence change statement for each new domain. This sequence is bad, and should never be put in the database.
This did not happen in grails2.x version of this plugin.
Given a new domain class, DuplicateDetection.groovy `package com.temp
class DuplicateDetection {
static constraints = {
}
}`
Running diff generates:
`databaseChangeLog = {
changeSet(author: "me (generated)", id: "1486614694673-1") {
createSequence(sequenceName: "seq_duplicate_detection")
}
changeSet(author: "me (generated)", id: "1486614694673-2") {
createTable(tableName: "duplicate_detection") {
column(autoIncrement: "true", name: "id", type: "BIGINT") {
constraints(primaryKey: "true", primaryKeyName: "duplicate_detectionPK")
}
}
}
}`
Running update generates the following table and corresponding, conflicting sequence:
CREATE TABLE public.duplicate_detection ( id bigint NOT NULL DEFAULT nextval('duplicate_detection_id_seq'::regclass), CONSTRAINT "duplicate_detectionPK" PRIMARY KEY (id) ) WITH ( OIDS=FALSE ); ALTER TABLE public.duplicate_detection OWNER TO postgres;
'seq_duplicate_detection' is incorrect, and breaks the convention of all other tables and sequences previously generated by the grails2.x plugin. This statement should not be generated by the diff.
The grails 3.x plugin is still correctly generating 'duplicate_detection_id_seq' and attaching that to the new table.
(I'm guessing this is due to a liquibase core or a hibernate bug.)
runtime 'org.grails.plugins:database-migration:2.0.0 grails 3.1.14 postgres 9.6 java 8
Did you specify compile 'org.liquibase:liquibase-core:3.5.3' in your build.gradle?
Yes, I did.
compile 'org.liquibase:liquibase-core:3.5.3'
ah, I think I see the problem. Most of my tables need to use a specific sequence name for legacy reasons. The old plugin correctly detected and handled the custom sequence defined in the mapping. The new plugin does not handle it, so it keeps trying to generate a new sequence each time.
static mapping = { id column: "duplicate_detection_id", generator: "native", params: [sequence: 'duplicate_detection_id_seq'] }