I have a database and some tables are updated periodically on the dev server and need to be pushed to the database on the prod server. What's the appropriate way to migrate the updated tables from the dev database to the prod database with pg_dump and pg_restore? I could dump the whole database on the dev server and restore it on the prod server, but some tables contain dynamic data (created/updated by applications) that are different between the two databases, so these tables on the prod server must be preserved. Still some tables contain static data that won't be changed and need not be updated on the prod server though it's okay to update them.
So basically what I want to do is to update the data in some tables of the database on the prod server with the data of the corresponding tables from the database on the dev server, using pg_dump and pg_restore (version 15.4). Thanks.
P.S. I've read the manual pages of pg_dump and pg_restore, but still don't have a clear idea how to do what I want. I had tried a few tests and didn't work as I expected. I also searched online and didn't see posts addressing the same issue.
Adding
--clean --if-existsoffers the full table overwrite, while using--schema='specific_schema'and--table='specific_table'you can narrow down what'spg_dumpsupposed to target, skipping all else.postgres_fdwmentioned by @Adrian Klaver can let you link objects ondevto be visible and accessible onprodas if they were present locally, which lets you either just use them directly, or reference them from DML to perform the necessaryprodupdates based ondevon the spot, from withinprod. Demo:The doc also documents multiple replication methods that let you set up an automatic process of moving the data from
devtoprod. In particular, you can set up logical replication to "replay" onprodspecific changes that took place ondev.