Skip to content

Commit c03b2cc

Browse files
committed
fix(0.3/2014-05-28--release_month_and_day.xml): use EXTRACT(YEAR FROM field) instead of YEAR() on PostgreSQL.
The failure was: liquibase.exception.DatabaseException: ERROR: function year(date) does not exist Hint: No function matches the given name and argument types. You might need to add explicit type casts. Position: 35 [Failed SQL: UPDATE series SET release_year=YEAR(released_at) WHERE released_at IS NOT NULL] Addressed to #1034
1 parent 7236ecb commit c03b2cc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/resources/liquibase/version/0.3/2014-05-28--release_month_and_day.xml

+7-1
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,18 @@
3535
<changeSet id="fill-release_year-column-based-on-values-from-released_at" author="php-coder" context="test-data, prod-data">
3636
<comment>Migrates data from series.released_at to series.release_year</comment>
3737

38-
<sql>
38+
<sql dbms="mysql,h2">
3939
UPDATE series
4040
SET release_year=YEAR(released_at)
4141
WHERE released_at IS NOT NULL
4242
</sql>
4343

44+
<sql dbms="postgresql">
45+
UPDATE series
46+
SET release_year=EXTRACT(YEAR FROM released_at)
47+
WHERE released_at IS NOT NULL
48+
</sql>
49+
4450
</changeSet>
4551

4652
<changeSet id="drop-released_at-column-from-series-table" author="php-coder" context="scheme">

0 commit comments

Comments
 (0)