Petar Tahchiev (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMjNhYjg5OWU5...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-14067?atlOrigin=eyJpIjoiMjNhYj...
) HHH-14067 (
https://hibernate.atlassian.net/browse/HHH-14067?atlOrigin=eyJpIjoiMjNhYj...
) Hibernate SchemaUpdate improve drop constraint (
https://hibernate.atlassian.net/browse/HHH-14067?atlOrigin=eyJpIjoiMjNhYj...
)
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%...
)
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=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-14067#add-comment?atlOrigin=ey...
)
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....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100128- sha1:3143c77 )