Skip to content

Commit 6d296fd

Browse files
committed
fix(0.3/2014-09-28--collection_slug.xml): don't prefix a column with table alias in SET clause on PostgreSQL.
The failure was: liquibase.exception.DatabaseException: ERROR: column "c" of relation "collections" does not exist Position: 29 [Failed SQL: UPDATE collections c SET c.slug = ( SELECT LOWER(REPLACE(u.login, ' ', '-')) FROM users u WHERE u.id = c.user_id) ] See also: https://stackoverflow.com/questions/11369757/postgres-wont-accept-table-alias-before-column-name Addressed to #1034
1 parent c03b2cc commit 6d296fd

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<comment>Sets value of slug field to transformed collection's owner's name</comment>
1919

2020
<!-- Unfortunately, H2 doesn't support UPDATE with JOIN -->
21-
<sql>
21+
<sql dbms="mysql,h2">
2222
UPDATE collections c
2323
SET c.slug = (
2424
SELECT LOWER(REPLACE(u.login, ' ', '-'))
@@ -27,6 +27,16 @@
2727
);
2828
</sql>
2929

30+
<!-- In PostgreSQL it is illegal to prefix columns with table alias in the SET clause -->
31+
<sql dbms="postgresql">
32+
UPDATE collections c
33+
SET slug = (
34+
SELECT LOWER(REPLACE(u.login, ' ', '-'))
35+
FROM users u
36+
WHERE u.id = c.user_id
37+
);
38+
</sql>
39+
3040
</changeSet>
3141

3242
<changeSet id="make-slug-field-not-nullable" author="php-coder" context="scheme">

0 commit comments

Comments
 (0)