-
-
Notifications
You must be signed in to change notification settings - Fork 970
Description
I have a Grails application and using the database migration plugin (DBM) it fails to generate the correct MySQL type for byte arrays.
I have the following domain field with constraints and mapping:
byte[] byteData
static constraints = {
byteData(nullable: false, maxSize: 250000)
}
static mapping = {
byteData(column: 'byte_data', type: 'binary')
}
Without the DBM plugin, the table in question would generate a field of type MEDIUMBLOB . If the maxSize constraint is removed, then the generated type would be TINYBLOB . I would expect the DBM plugin to generate from either the GORM classes or from the MySQL database the change sets for the byte array with its size constraint correctly but this is not the case.
When I use **dbm-generate-gorm-changelog** or **dbm-generate-changelog** they both result in the same column command inside the changeset as follows:
column(name: "byte_data", type: "BLOB") {
constraints(nullable: "false")
}
It seems that the commands are ignoring the maxSize constraint specified above which causes a problem when we assign arrays longer than what the BLOB type allows.
We can manually change the type to MEDIUMBLOB in the change set although it seems like a hack. Not sure if this is a known problem or if it is a problem at all. I would appreciate any advice on this issue.