Skip to content

Commit feca32f

Browse files
committed
chore(0.4.2/2019-11-27--add_collections_series_id.xml): fix migration on MySQL.
The error was: liquibase.exception.ValidationFailedException: Validation Failed: 1 changes have validation failures Cannot add a non-primary key identity column, classpath:/liquibase/version/0.4.2/2019-11-27--add_collections_series_id.xml::add-collections_series-id-field::php-coder Use a single <addColumn> statement for MySQL/PostgreSQL and perform it in the 2 steps for H2. Also remove beforeColumn that didn't work -- MySQL doesn't support it so we use FIRST clause instead. PostgreSQL doesn't support defining a column position at all. For H2 use FIRST as well. Correction for 2675e9f commit. Address to #1123
1 parent 553c7b0 commit feca32f

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

src/main/resources/liquibase/version/0.4.2/2019-11-27--add_collections_series_id.xml

+25-2
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,40 @@
55
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
66
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
77

8-
<changeSet id="add-collections_series-id-field" author="php-coder" context="scheme">
8+
<changeSet id="add-collections_series-id-field" author="php-coder" context="scheme" dbms="h2">
99

1010
<addColumn tableName="collections_series">
11-
<column name="id" type="INTEGER" autoIncrement="true" beforeColumn="collection_id" />
11+
<column name="id" type="INTEGER" autoIncrement="true" />
1212
</addColumn>
1313

14+
<modifySql>
15+
<append value=" FIRST" />
16+
</modifySql>
17+
18+
</changeSet>
19+
20+
<changeSet author="php-coder" id="add-collections_series-id-pk" context="scheme" dbms="h2">
21+
1422
<addPrimaryKey
1523
tableName="collections_series"
1624
columnNames="id"
1725
constraintName="pk_collections_series_id" />
1826

1927
</changeSet>
2028

29+
<changeSet id="add-collections_series-id-field" author="php-coder" context="scheme" dbms="mysql,postgresql">
30+
31+
<addColumn tableName="collections_series">
32+
<column name="id" type="INTEGER" autoIncrement="true">
33+
<constraints primaryKey="true" primaryKeyName="pk_collections_series_id" />
34+
</column>
35+
</addColumn>
36+
37+
<modifySql dbms="mysql">
38+
<!-- Workaround for: https://liquibase.jira.com/browse/CORE-2347 -->
39+
<append value=" FIRST" />
40+
</modifySql>
41+
42+
</changeSet>
43+
2144
</databaseChangeLog>

0 commit comments

Comments
 (0)