oracle - rollback of addPrimaryKey also drops associated index -
in liquibase 3.5.0 under oracle 11g, have added following changeset :
<changeset author="me" id="pk_creation"> <createindex tablename="my_table" indexname="my_index" unique="true"> <column name="id" /> </createindex> <addprimarykey tablename="my_table" columnnames="id" constraintname="my_pk" forindexname="my_index" /> </changeset>
the result of updatesql
operation expect :
create unique index my_index on my_table(id);
alter table my_table add constraint my_pk primary key (id) using index my_index;
but (default) rollbacksql
operation drops index @ same time primary key in first instruction, causes second instruction fail :
alter table my_table drop primary key drop index;
drop index my_index;
is there way make work without specifying custom rollback operation ?
it looks auto-generated sql drop primary key includes drop index , has quite while. i'm not sure original rationale including since it's been way while it'll take research figure out why makes sense. created https://liquibase.jira.com/browse/core-2749 more part of 4.0 changes.
for now, easiest route add custom rollback block specifies dropprimarykey:
<changeset author="me" id="pk_creation"> <createindex tablename="my_table" indexname="my_index" unique="true"> <column name="id" /> </createindex> <addprimarykey tablename="my_table" columnnames="id" constraintname="my_pk" forindexname="my_index" /> <rollback> <dropprimarykey tablename="my_table"/> </rollback> </changeset>
otherwise, create custom extension of own overrides dropprimarykeygenerator , not include drop index portion. see http://liquibase.org/extensions more information on writing extensions.
Comments
Post a Comment