Skip to content

Instantly share code, notes, and snippets.

@thetekst
Last active October 4, 2021 17:03
Show Gist options
  • Save thetekst/460d8d92ae9b4890abde1097237114a2 to your computer and use it in GitHub Desktop.
Save thetekst/460d8d92ae9b4890abde1097237114a2 to your computer and use it in GitHub Desktop.
update column with another column value for oracle, postgresql, mssql, etc with where
databaseChangeLog:
- property:
dbms: oracle
name: my_date_type
value: to_date('2021-10-03','YY-MM-DD')
- property:
dbms: postgresql
name: my_date_type
value: date '2021-10-03'
- property:
dbms: mssql
name: my_date_type
value: cast('2021-10-03' as date)
- changeSet:
id: 2021.10.04
author: test
changes:
- update:
tableName: TEST_TAB
columns:
- column:
name: NEW_TEST_DATE
valueComputed: OLD_TEST_DATE # copy column OLD_TEST_DATE to NEW_TEST_DATE
where: OLD_TEST_DATE is not null and NEW_TEST_DATE is null and OLD_TEST_DATE > ${my_date_type}
rollback:
- update:
tableName: TEST_TAB
columns:
- column:
name: NEW_TEST_DATE
valueComputed: null # set null
where: OLD_TEST_DATE is not null and OLD_TEST_DATE > ${my_date_type}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment