【问题标题】:Heroku pg:pull failing to populate schemaHeroku pg:pull 无法填充模式
【发布时间】:2014-11-10 07:09:47
【问题描述】:

所以我在pg:pull 上阅读了documentation,但似乎无法让它发挥作用。当我使用正确的参数运行命令时,我的 Heroku DB 被获取并创建了一个本地数据库,但模式没有在本地填充;例如,没有创建表、没有设置触发器、没有约束、没有数据等。

这是我的数据库的 heroku pg:info 日志:

=== HEROKU_POSTGRESQL_ORANGE_URL (DATABASE_URL)
Plan:        Hobby-dev
Status:      Available
Connections: 1
PG Version:  9.3.3
Created:     2014-04-02 19:24 UTC
Data Size:   7.4 MB
Tables:      6
Rows:        1376/10000 (In compliance)
Fork/Follow: Unsupported
Rollback:    Unsupported

这是我正在使用的命令:

PGUSER=postgres PGPASSWORD=password heroku pg:pull HEROKU_POSTGRESQL_ORANGE mylocaldb --app myappname

我不知道如何为PGUSERPGPASSWORD 设置环境变量(如果有人能指出我正确的方向,你会得到+1。我读了this question 并回答无济于事)。

mylocaldb已创建,但未填写schema。

这是运行命令后的pg_dump

pg_dump: reading schemas
pg_dump: reading user-defined tables
pg_dump: reading extensions
pg_dump: reading user-defined functions
pg_dump: reading user-defined types
pg_dump: reading procedural languages
pg_dump: reading user-defined aggregate functions
pg_dump: reading user-defined operators
pg_dump: reading user-defined operator classes
pg_dump: reading user-defined operator families
pg_dump: reading user-defined text search parsers
pg_dump: reading user-defined text search templates
pg_dump: reading user-defined text search dictionaries
pg_dump: reading user-defined text search configurations
pg_dump: reading user-defined foreign-data wrappers
pg_dump: reading user-defined foreign servers
pg_dump: reading default privileges
pg_dump: reading user-defined collations
pg_dump: reading user-defined conversions
pg_dump: reading type casts
pg_dump: reading table inheritance information
pg_dump: reading event triggers
pg_dump: finding extension members
pg_dump: finding inheritance relationships
pg_dump: reading column info for interesting tables
pg_dump: finding the columns and types of table "phrases"
pg_dump: finding default expressions of table "phrases"
pg_dump: finding the columns and types of table "users"
pg_dump: finding default expressions of table "users"
pg_dump: finding the columns and types of table "favorite_phrases"
pg_dump: finding the columns and types of table "favorite_users"
pg_dump: finding the columns and types of table "phrasebooks"
pg_dump: finding default expressions of table "phrasebooks"
pg_dump: finding the columns and types of table "phrasebooks_phrases"
pg_dump: flagging inherited columns in subtables
pg_dump: reading indexes
pg_dump: reading indexes for table "phrases"
pg_dump: reading indexes for table "users"
pg_dump: reading indexes for table "favorite_phrases"
pg_dump: reading indexes for table "favorite_users"
pg_dump: reading indexes for table "phrasebooks"
pg_dump: reading indexes for table "phrasebooks_phrases"
pg_dump: reading constraints
pg_dump: reading foreign key constraints for table "phrases"
pg_dump: reading foreign key constraints for table "users"
pg_dump: reading foreign key constraints for table "favorite_phrases"
pg_dump: reading foreign key constraints for table "favorite_users"
pg_dump: reading foreign key constraints for table "phrasebooks"
pg_dump: reading triggers
pg_dump: reading triggers for table "phrases"
pg_dump: reading triggers for table "users"
pg_dump: reading triggers for table "favorite_phrases"
pg_dump: reading triggers for table "favorite_users"
pg_dump: reading triggers for table "phrasebooks"
pg_dump: reading rewrite rules
pg_dump: reading large objects
pg_dump: reading dependency data
pg_dump: saving encoding = UTF8
pg_dump: saving standard_conforming_strings = on
pg_dump: saving database definition
pg_restore: [archiver] did not find magic string in file header
pg_dump: [custom archiver] WARNING: ftell mismatch with expected position -- fte
ll used
pg_dump: [custom archiver] WARNING: ftell mismatch with expected position -- fte
ll used
pg_dump: dumping contents of table favorite_phrases
pg_dump: [custom archiver] WARNING: ftell mismatch with expected position -- fte
ll used
pg_dump: dumping contents of table favorite_users
pg_dump: [custom archiver] WARNING: ftell mismatch with expected position -- fte
ll used
pg_dump: dumping contents of table phrasebooks
pg_dump: [custom archiver] WARNING: ftell mismatch with expected position -- fte
ll used
pg_dump: dumping contents of table phrasebooks_phrases
pg_dump: [custom archiver] WARNING: ftell mismatch with expected position -- fte
ll used
pg_dump: dumping contents of table phrases
pg_dump: [custom archiver] could not write to output file: Invalid argument

我需要在本地进行某种进一步的配置才能使其正常工作吗?如果这很重要,我正在为tsquery 使用自定义停用词字典,该字典尚未在这台机器上本地(尚未)设置...我怀疑这将是pg_dump 中的问题...任何非常感谢您的帮助!

编辑:我刚刚尝试在我的桌面上运行此命令,另一个本地站点已配置了所有内容。没有骨头。我得到完全相同的结果。以下是所述本地机器上which psql 的输出,以防万一:

$ which psql
/c/Program Files/PostgreSQL/9.3/bin/psql

【问题讨论】:

    标签: windows postgresql heroku heroku-toolbelt


    【解决方案1】:

    @will 的答案在常规 Heroku 开发的情况下是完美的,但在 Private Space 的情况下失败。如Heroku Postgres and Heroku Private Spaces :: External connections 所述:

    与我们的爱好、标准和高级层中的 Heroku Postgres 数据库不同,私有数据库不能通过本地计算机访问

    作为一种解决方法,您可以将数据库复制到非私有数据库,然后您可以将数据库转储到本地计算机。

    【讨论】:

      【解决方案2】:

      我编写了pg:pullpg:push 命令。

      pg:pullpg:push 都使用pg_dump 命令并将其直接传递给pg_restore (source code)。不幸的是,截至 2014 年 9 月此答案发布时,Windows 上的 pg:push,pull 存在问题。这些问题并非无法克服,因此,如果您稍后再回答此问题,请检查它是否已修复。

      env 命令 used herehere 我不认为是在 Windows 上,这就是为什么你必须做 PGUSER 和 PGPASSWORD 的东西。然而env 的原因是pg_dump 需要与pg_restore 不同的环境变量。

      我使用了一次a stab at fixing that,通过使用 popen 独立设置命令,然后将它们连接在一起而不是使用管道。但是,我无法让它正常工作,不得不停下来。

      我很乐意查看所有的补丁并修复此问题,只需 @ 在 heroku/heroku 项目的拉取请求中提及我即可。

      抱歉我没能解决这个问题:(

      相反,在解决此问题之前,您可以直接分别使用pg_dumppg_restore 命令。作为一个两步过程,它更麻烦,并且必须查找远程凭据,但它可以完成工作。 gen_pg_*_command 方法中的链接源显示了如何使用pg_dumppg_restore

      【讨论】:

      • 威尔,谢谢你的回答!我会看看直接用命令再试一次。不幸的是,我对 Ruby 不太熟悉……只在大学课程中使用了几周,否则我会尝试修复 Windows。如果/何时进行修复,请回帖:)
      • 已经一年多了,现在修好了吗?
      • 这个问题在 Windows 7 上似乎仍然存在,但直接使用 pg_dump 命令似乎可以工作;不需要使用pg_restore,因为我将所有 SQL 命令转储到纯文本文件中。
      猜你喜欢
      • 2014-10-08
      • 2016-11-27
      • 1970-01-01
      • 2017-01-15
      • 2014-02-08
      • 1970-01-01
      • 2014-08-10
      • 2020-07-05
      • 2017-08-21
      相关资源
      最近更新 更多