|
| 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | +<databaseChangeLog |
| 3 | + xmlns="http://www.liquibase.org/xml/ns/dbchangelog" |
| 4 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 5 | + xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog |
| 6 | + http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd"> |
| 7 | + |
| 8 | + <!-- |
| 9 | + We have to create a non-existing index first in order to prevent |
| 10 | + |
| 11 | + ERROR 1025 (HY000): Error on rename of './mystamps/#sql-488_b7' to './mystamps/collections_series' |
| 12 | + (errno: 150 - Foreign key constraint is incorrectly formed) |
| 13 | + |
| 14 | + from happening on MySQL. |
| 15 | + |
| 16 | + It occurs because fk_collections_series_collection_id index hasn't been created when the table was created. |
| 17 | + MySQL is smart enough to understand that it can use uc_collections_series_collection_id_series_id |
| 18 | + compound index instead. Now, when we want to remove this index, MySQL refuses an attempt as in this case |
| 19 | + there will be no index for collection_id field. That's why we create it explicitly. |
| 20 | + --> |
| 21 | + <changeSet id="add-collections_series_series_id-index" author="php-coder" context="scheme" dbms="mysql"> |
| 22 | + |
| 23 | + <createIndex tableName="collections_series" indexName="fk_collections_series_collection_id"> |
| 24 | + <column name="collection_id" /> |
| 25 | + </createIndex> |
| 26 | + |
| 27 | + </changeSet> |
| 28 | + |
| 29 | + <changeSet id="drop-unique-constraint-from-collections_series-table" author="php-coder" context="scheme"> |
| 30 | + |
| 31 | + <dropUniqueConstraint |
| 32 | + tableName="collections_series" |
| 33 | + constraintName="uc_collections_series_collection_id_series_id" /> |
| 34 | + |
| 35 | + <rollback |
| 36 | + changeSetId="add-unique-constraint-to-collections_series-table" |
| 37 | + changeSetAuthor="cssru" |
| 38 | + changeSetPath="classpath:/liquibase/version/0.4/2016-01-04--unique_series_in_collection.xml" /> |
| 39 | + |
| 40 | + </changeSet> |
| 41 | + |
| 42 | +</databaseChangeLog> |
0 commit comments