且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将 .sql 文件导入 Heroku postgres 数据库?

更新时间:2022-05-31 22:53:36

这就是你的做法:

heroku pg:psql --app YOUR_APP_NAME_HERE < updates.sql

如果您想将生产恢复到暂存状态(假设两者都是 heroku postgres 数据库):

And if you want to restore your production into staging (assuming both are heroku postgres DBs):

heroku pgbackups:restore YOUR_STAGING_DATABASE_NAME `heroku pgbackups:url --app YOUR_PRODUCTION_APP_NAME` --app YOUR_STAGING_APP_NAME --confirm YOUR_STAGING_APP_NAME

确保保留 heroku pgbackups:url --app YOUR_PRODUCTION_APP_NAME 周围的特殊单引号.

Make sure to preserve the special single quotes around heroku pgbackups:url --app YOUR_PRODUCTION_APP_NAME.

Heroku 最近更新了他们的工具带,因此旧的命令不再有效(请参阅 此链接 了解更多信息).下面是恢复命令的新版本.

Heroku has recently updated their toolbelt so the old commands are no longer valid (see this link for more info). Below is the new version of the restore command.

heroku pg:backups restore 
  `heroku pg:backups public-url -a YOUR_PRODUCTION_APP_NAME` 
  YOUR_STAGING_DATABASE_NAME 
  --app YOUR_STAGING_APP_NAME 
  --confirm YOUR_STAGING_APP_NAME