3

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

How can I migrate it to a production server?

6
  • 2
    why not pg_dump and restore?.. Commented Feb 8, 2018 at 14:55
  • liquibase.org Commented Feb 8, 2018 at 15:12
  • @VaoTsun I get following error while using pg_dump: pg_dump: server version: 9.6.5; pg_dump version: 9.5.10 pg_dump: aborting because of server version mismatch Commented Feb 8, 2018 at 16:03
  • @a_horse_with_no_name liquibase or flyway is good approach, but I'am at the end of developing my app. These tools must be used from the start of developing an app (put each sql script into file and store them ) Commented Feb 8, 2018 at 16:05
  • 3
    @DauletNurgali you try to use old pg_dump with new server - while you should do the opposite. try locate bin/pg_dump to find pg_dump for 9.6 version Commented Feb 8, 2018 at 16:13

2 Answers 2

1

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
Sign up to request clarification or add additional context in comments.

Comments

1

Try using flyway. It does exactly this. Dump your schema into an sql file and migrate using flyway.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.