Skip to content

Commit 7282a7b

Browse files
committed
fix(0.4/2015-06-22--image_url.xml): explicitly cast a string to an integer on PostgreSQL.
The failure was: liquibase.exception.DatabaseException: ERROR: column "image_id" is of type integer but expression is of type text Hint: You will need to rewrite or cast the expression. Position: 75 [Failed SQL: INSERT INTO series_images(series_id, image_id) SELECT id AS series_id, REPLACE(image_url, '/image/', '') AS image_id FROM series] Addressed to #1034
1 parent 6d296fd commit 7282a7b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/main/resources/liquibase/version/0.4/2015-06-22--image_url.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,19 @@
3434

3535
<comment>Migrates data from series.image_url to series_images</comment>
3636

37-
<sql>
37+
<sql dbms="mysql,h2">
3838
INSERT INTO series_images(series_id, image_id)
3939
SELECT id AS series_id, REPLACE(image_url, '/image/', '') AS image_id
4040
FROM series
4141
</sql>
4242

43+
<!-- PostgreSQL requires us to cast a string to an integer explicitly -->
44+
<sql dbms="postgresql">
45+
INSERT INTO series_images(series_id, image_id)
46+
SELECT id AS series_id, CAST(REPLACE(image_url, '/image/', '') AS INT) AS image_id
47+
FROM series
48+
</sql>
49+
4350
</changeSet>
4451

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

0 commit comments

Comments
 (0)