Add column incomplete for "not null" columns (MySQL)

View: New views
2 Messages — Rating Filter:   Alert me  

Add column incomplete for "not null" columns (MySQL)

by Craig Starr :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Greetings,

Previous attempt bounced due to sourceforge.net zip-file attachment rejection.  Zip-file references valid when I know how to transmit it.

I've noticed a vexing behavior when adding new fields under MySQL that Hibernate determines to be "not null."  On entity source changes adding a new field the HIbernate-generated schema will indicate "not null" in the create table statement.  LiquiBase picks up the new field and generates a changeSet "addColumn" entry in the changelog.xml file, but it is missing the "not null" "modifier" (uncertain of db-lingo for this, I'm a networking guy... ;) ), and the database mods occur according to the changelog file.  See tzchangelog-1.xml, tzupdate-1.sql, and schema.partial.sql in attached zip file (use field "network" for comparison, though it happens consistently with other fields as well).

This in itself might be tolerable, but that is not where the story ends.  On subsequent builds, which should result in no further changes, LiquiBase only THEN picks up the "not null" "modifier" (from Hibernate, presumably), and tries to apply it, generating corresponding
"addNotNullConstraint" changeset entries.  See tzchangelog-2.xml, tzupdate-2.sql, and schema.partial.sql in attached zip file (use field "network" for comparison).  No difficulty is apparent until we get to the updateSQL-generated command set: an error/exception is raised and the file contains the following text (excluding quotes):

"Migration Failed: liquibase.database.sql.SetNullableStatement is not supported on MySQL: Database requires columnDataType parameter.  For more information, use the --logLevel flag)"

Bottom line is my database is out of sync. with respect to my Hibernate schema, and this becomes "persistent" circular behavior for LiquiBase.

This is the manual SQL I had to issue to work around this problem:

alter table ContactSummary drop network;
alter table ContactSummary add network bit not null;

alter table ContactSummary drop transfer;
alter table ContactSummary add transfer bit not null;

alter table AgentContactSummary drop totalVarWrapupTime;
alter table AgentContactSummary add totalVarWrapupTime bigint not null;

In my humble opinion, if setting "not null" as a "constraint" is not an option for MySQL, as it appears not to be, LiquiBase should at least include it in the "addColumn" element in the FIRST changelog it creates.

I think this is a bug. 
Please advise how I should transmit zip file with documenting information.  Previous attempt bounced due to sourceforge.net zip-file attachment rejection.

Thanks,
CJS
-- 
540 North Commercial Street
Manchester, NH 03101
603-296-1454
Good, fast, cheap. Pick two.

[cstarr.vcf]

begin:vcard
fn:Craig Starr
n:Starr;Craig
org:Perimeter Technology;Department of Redundancy Department
adr:;;540 North Commercial Street;Manchester;NH;03101;USA
email;internet:cstarr@...
title:Principal Software Engineer
tel;work:603-296-1454
note:Good, fast, cheap.  Pick two.
x-mozilla-html:TRUE
url:http://www.perimetertechnology.com
version:2.1
end:vcard



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Liquibase-user mailing list
Liquibase-user@...
https://lists.sourceforge.net/lists/listinfo/liquibase-user

Re: Add column incomplete for "not null" columns(MySQL)

by Voxland, Nathan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Do you have the hibernate schema update enabled?   It is probably best to just use Liquibase and not have hibernate try to update your schemas.  That way you won’t run into possible race conditions on who updates the database when and you will not have un-liquibase-tracked changes that were applied by hibernate that get forgotten.

 

The addNotNullConstraint tag should work fine for mysql as long as you use the columnDataType attribute.  The XSD doesn’t require it since most databases don’t need it, but mysql’s sql does require it and that is why you are getting the error.

 

Am I understanding your issue correctly?

 

Nathan

 

From: liquibase-user-bounces@... [mailto:liquibase-user-bounces@...] On Behalf Of Craig Starr
Sent: Thursday, July 17, 2008 12:42 PM
To: Liquibase-user@...
Cc: Joanne Beausoleil; Domenic LaRosa
Subject: [Liquibase-user] Add column incomplete for "not null" columns(MySQL)

 

Greetings,

Previous attempt bounced due to sourceforge.net zip-file attachment rejection.  Zip-file references valid when I know how to transmit it.


I've noticed a vexing behavior when adding new fields under MySQL that Hibernate determines to be "not null."  On entity source changes adding a new field the HIbernate-generated schema will indicate "not null" in the create table statement.  LiquiBase picks up the new field and generates a changeSet "addColumn" entry in the changelog.xml file, but it is missing the "not null" "modifier" (uncertain of db-lingo for this, I'm a networking guy... ;) ), and the database mods occur according to the changelog file.  See tzchangelog-1.xml, tzupdate-1.sql, and schema.partial.sql in attached zip file (use field "network" for comparison, though it happens consistently with other fields as well).

This in itself might be tolerable, but that is not where the story ends.  On subsequent builds, which should result in no further changes, LiquiBase only THEN picks up the "not null" "modifier" (from Hibernate, presumably), and tries to apply it, generating corresponding "addNotNullConstraint" changeset entries.  See tzchangelog-2.xml, tzupdate-2.sql, and schema.partial.sql in attached zip file (use field "network" for comparison).  No difficulty is apparent until we get to the updateSQL-generated command set: an error/exception is raised and the file contains the following text (excluding quotes):

"Migration Failed: liquibase.database.sql.SetNullableStatement is not supported on MySQL: Database requires columnDataType parameter.  For more information, use the --logLevel flag)"

Bottom line is my database is out of sync. with respect to my Hibernate schema, and this becomes "persistent" circular behavior for LiquiBase.

This is the manual SQL I had to issue to work around this problem:

alter table ContactSummary drop network;
alter table ContactSummary add network bit not null;

alter table ContactSummary drop transfer;
alter table ContactSummary add transfer bit not null;

alter table AgentContactSummary drop totalVarWrapupTime;
alter table AgentContactSummary add totalVarWrapupTime bigint not null;

In my humble opinion, if setting "not null" as a "constraint" is not an option for MySQL, as it appears not to be, LiquiBase should at least include it in the "addColumn" element in the FIRST changelog it creates.

I think this is a bug.  Please advise how I should transmit zip file with documenting information.  Previous attempt bounced due to sourceforge.net zip-file attachment rejection.


Thanks,
CJS

-- 
540 North Commercial Street
Manchester, NH 03101
603-296-1454
Good, fast, cheap. Pick two.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Liquibase-user mailing list
Liquibase-user@...
https://lists.sourceforge.net/lists/listinfo/liquibase-user
LightInTheBox - Buy quality products at wholesale price