[hibernate-issues] [JIRA] (HHH-14067) Hibernate SchemaUpdate improve drop constraint

Petar Tahchiev (JIRA) jira at hibernate.atlassian.net
Thu Jun 11 12:53:26 EDT 2020


Petar Tahchiev ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A73158fe0-b393-4cea-be05-e12b3c4c6093 ) *created* an issue

Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMjNhYjg5OWU5ZGVmNDQ1ODk4M2IxYmI0NDEzMTNjZDYiLCJwIjoiaiJ9 ) / Bug ( https://hibernate.atlassian.net/browse/HHH-14067?atlOrigin=eyJpIjoiMjNhYjg5OWU5ZGVmNDQ1ODk4M2IxYmI0NDEzMTNjZDYiLCJwIjoiaiJ9 ) HHH-14067 ( https://hibernate.atlassian.net/browse/HHH-14067?atlOrigin=eyJpIjoiMjNhYjg5OWU5ZGVmNDQ1ODk4M2IxYmI0NDEzMTNjZDYiLCJwIjoiaiJ9 ) Hibernate SchemaUpdate improve drop constraint ( https://hibernate.atlassian.net/browse/HHH-14067?atlOrigin=eyJpIjoiMjNhYjg5OWU5ZGVmNDQ1ODk4M2IxYmI0NDEzMTNjZDYiLCJwIjoiaiJ9 )

Issue Type: Bug Affects Versions: 5.4.15 Assignee: Unassigned Created: 11/Jun/2020 09:53 AM Priority: Major Reporter: Petar Tahchiev ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A73158fe0-b393-4cea-be05-e12b3c4c6093 )

Hello,

we are using the Hibernate SchemaUpdate to create an SQL file like this:

           final SchemaUpdate schemaUpdate = new SchemaUpdate();

           schemaUpdate.setDelimiter(schemaProperties.getDelimiter());
           schemaUpdate.setFormat(schemaProperties.getFormat());
           schemaUpdate.setOutputFile(getHibernateScriptOutputFilename(database, true ));
           schemaUpdate.execute(EnumSet.of(TargetType.SCRIPT), getHibernateConfiguration(database, null ));

which works fine unless when there's a new table. When we have a new table, the new SQL file created is the following:

   create table external_care_product (

      DTYPE varchar(31) not null ,

       id bigint not null ,

       code varchar(255) not null ,

       created_by varchar(255),

       created_date datetime,

       last_modified_by varchar(255),

       last_modified_date datetime,

       external_service_id varchar(255),

       external_service_name varchar(255),

       external_service_provider varchar(255),

       care_product_id bigint,

       primary key (id)

   ) engine=InnoDB;

   alter table external_care_product

      drop constraint UK_c91alca5s7iub60faehho1u54;

   alter table external_care_product

      add constraint UK_c91alca5s7iub60faehho1u54 unique (code);

Notice that it first drops the constraint and then creates the constraint. So whenever we try to execute this script to the DB it fails because the constraint it tries to drop doesn't exist. Would it be possible to use something like "alter table drop constraint if exists"? If not then I think it's more appropriate to skip the drop part.

( https://hibernate.atlassian.net/browse/HHH-14067#add-comment?atlOrigin=eyJpIjoiMjNhYjg5OWU5ZGVmNDQ1ODk4M2IxYmI0NDEzMTNjZDYiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-14067#add-comment?atlOrigin=eyJpIjoiMjNhYjg5OWU5ZGVmNDQ1ODk4M2IxYmI0NDEzMTNjZDYiLCJwIjoiaiJ9 )

Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100128- sha1:3143c77 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200611/ff25465b/attachment.html 


More information about the hibernate-issues mailing list