postgresqlschema-migration

PostgreSQL schema migration?


I've local PostgreSQL database with tables, constraints, relations etc.

How can I migrate it to a production server?


Solution

  • From pg_dump manual page you can try with pg_dump and psql, you can also check other flags for data, schema or table specific tasks. I personally sometime do this kind of job using Navicat or pgAdmin client.

    To dump a database called mydb into a SQL-script file:

    $ pg_dump mydb > db.sql
    

    To reload such a script into a (freshly created) database named newdb:

    $ psql -d newdb -f db.sql