Skip to content

Commit a98ed64

Browse files
committed
refactor: use migrations that work on PostgreSQL also on H2 and MySQL to reduce duplication
Relate to #1034
1 parent f9e79b1 commit a98ed64

File tree

2 files changed

+7
-39
lines changed

2 files changed

+7
-39
lines changed

src/main/resources/liquibase/version/0.3/2014-09-28--collection_slug.xml

+3-16
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,12 @@
1414

1515
</changeSet>
1616

17-
<changeSet id="update-collections-slug" author="php-coder" context="test-data,prod-data" dbms="mysql,h2">
17+
<changeSet id="update-collections-slug" author="php-coder" context="test-data,prod-data">
18+
<validCheckSum>8:f11bf0ed0e440867152a117a7447b8c5</validCheckSum>
1819
<comment>Sets value of slug field to transformed collection's owner's name</comment>
1920

2021
<!-- Unfortunately, H2 doesn't support UPDATE with JOIN -->
21-
<sql>
22-
UPDATE collections c
23-
SET c.slug = (
24-
SELECT LOWER(REPLACE(u.login, ' ', '-'))
25-
FROM users u
26-
WHERE u.id = c.user_id
27-
);
28-
</sql>
29-
30-
</changeSet>
31-
32-
<changeSet id="update-collections-slug" author="php-coder" context="test-data,prod-data" dbms="postgresql">
33-
<comment>Sets value of slug field to transformed collection's owner's name</comment>
34-
35-
<!-- In PostgreSQL it is illegal to prefix columns with table alias in the SET clause -->
22+
<!-- NOTE: In PostgreSQL it is illegal to prefix columns with table alias in a SET clause -->
3623
<sql>
3724
UPDATE collections c
3825
SET slug = (

src/main/resources/liquibase/version/0.4/2018-06-09--add_number_of_stamps_to_collections_series.xml

+4-23
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,12 @@
1313

1414
</changeSet>
1515

16-
<changeSet id="fill-collections_series-number_of_stamps-field" author="php-coder" context="prod-data" dbms="mysql,h2">
16+
<changeSet id="fill-collections_series-number_of_stamps-field" author="php-coder" context="prod-data">
17+
<validCheckSum>8:89cf638686e11255fd45dc41c1250c9d</validCheckSum>
1718
<comment>Sets value of number_of_stamps field to number of stamps in a series</comment>
1819

19-
<sql>
20-
UPDATE collections_series cs
21-
SET cs.number_of_stamps = (
22-
SELECT s.quantity
23-
FROM series s
24-
WHERE s.id = cs.series_id
25-
)
26-
</sql>
27-
28-
<rollback>
29-
<sql>
30-
UPDATE collections_series
31-
SET number_of_stamps = NULL
32-
</sql>
33-
</rollback>
34-
35-
</changeSet>
36-
37-
<changeSet id="fill-collections_series-number_of_stamps-field" author="php-coder" context="prod-data" dbms="postgresql">
38-
<comment>Sets value of number_of_stamps field to number of stamps in a series</comment>
39-
40-
<!-- In PostgreSQL it is illegal to prefix columns with table alias in the SET clause -->
20+
<!-- Unfortunately, H2 doesn't support UPDATE with JOIN -->
21+
<!-- NOTE: In PostgreSQL it is illegal to prefix columns with table alias in a SET clause -->
4122
<sql>
4223
UPDATE collections_series cs
4324
SET number_of_stamps = (

0 commit comments

Comments
 (0)