为什么我不能在Windows中迁移我的postgres数据库?

问题描述 投票:0回答:1

我将我的数据库从sqlite切换到postgres,以便在heroku上进行部署。当我这样做并尝试运行heroku运行rake db:migrate -a我看到了这个错误:ActiveRecord :: StatementInvalid:PG :: DatatypeMismatch:错误:列“pay_date”无法自动转换为输入日期提示:您可能需要指定“USING pay_date :: date”。 :ALTER TABLE“recurring_payments”ALTER COLUMN“pay_date”TYPE日期所以我创建了一个迁移来解决这个问题,但是当我运行rake db:migrate来运行迁移时,我看到了这个错误:

PG::ConnectionBad: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

但是,当我检查我的服务时,我发现它正在运行,并且它被配置为侦听端口5432.还有什么可能导致此问题?

另外,如果我将此行添加到database.yml:

  host: localhost 

错误更改为:

PG::ConnectionBad: could not translate host name "localhost" to address: Name or service not known 

也许这更有希望?

ruby-on-rails windows postgresql
1个回答
0
投票

你似乎有很多问题:

默认情况下,Rails使用Unix套接字连接到PostgreSQL。因此原始的错误消息。

添加host密钥将Rails转换为TCP / IP连接,这是您在Windows中所需的。

现在您似乎还有另一个问题:localhost无法解析为IP地址,这表明您的Windows机器上存在与Rails或PostgreSQL无关的常规配置问题。

检查您的hosts文件是否搞砸了,或者您的(个人)防火墙是否阻止了Rails或PostgreSQL。尝试运行ping localhost

如果一切都失败了,请尝试使用host: 127.0.0.1

© www.soinside.com 2019 - 2024. All rights reserved.