Created
July 25, 2018 07:27
-
-
Save gurneyalex/1c9a7259636e98d2873074fc708afc0d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- in restored dump | |
| COPY ( | |
| SELECT t.id, e.identification_id | |
| FROM transport_order t JOIN hr_employee e ON (t.driver_id = e.id) | |
| ) TO '/tmp/transport.dat' | |
| WITH (FORMAT binary); | |
| -- in production database | |
| CREATE TABLE tmp_transport (id INTEGER, driver VARCHAR); | |
| COPY tmp_transport FROM '/tmp/transport.dat' WITH (FORMAT binary); | |
| BEGIN; | |
| UPDATE transport_order SET driver_id = tmp.employee_id | |
| FROM ( | |
| SELECT t.id transport_id, e.id employee_id | |
| FROM tmp_transport t JOIN hr_employee e on (e.identification_id = t.driver) | |
| ) tmp | |
| WHERE id = tmp.transport_id; | |
| -- check the result (not shown here) | |
| COMMIT; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment