PostgreSQL 架构迁移?

PostgreSQL schema migration?

我有包含表、约束、关系等的本地 PostgreSQL 数据库。

如何将其迁移到生产服务器?

尝试使用 flyway。它正是这样做的。将您的架构转储到 sql 文件中并使用 flyway 进行迁移。

来自 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 客户。

将名为 mydb 的数据库转储到 SQL 脚本文件中:

$ pg_dump mydb > db.sql

将这样的脚本重新加载到名为 newdb 的(新创建的)数据库中:

$ psql -d newdb -f db.sql