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?
[mailto:liquibase-user-bounces@...] On Behalf Of Craig
Sent: Thursday, July 17, 2008 12:42 PM
Cc: Joanne Beausoleil; Domenic LaRosa
Subject: [Liquibase-user] Add column incomplete for "not null"
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.
540 North Commercial Street
Manchester, NH 03101
Good, fast, cheap. Pick two.