1

I want to load schema from structure.sql file to my Heroku database. On my localhost machine I do as follows and all works just fine, all tables are created:

C:\> psql -U postgres -a -d MyApp_development -f C:\MyApp\db\structure.sql

I pass a local file name as -f option: -f C:\MyApp\db\structure.sql

When I do the same on Heroku, it complains that the app is not found. I think that it doesn't understand -f option. It cannot find file C:\MyApp\db\structure.sql on its server.

So how do I need to provide correct path relative to Heroku? structure.sql has to be located here on Heroku:

MyApp\db\structure.sql

So I need to do something like this:

heroku pg:psql -U ... -a -d MyHerokuDB -f MyHerokuAppRoot\db\structure.sql

What is MyHerokuAppRoot? What with may substitute it?

4

1 回答 1

1

我找到了解决方案。我认为问题在于 Postgresql 仅将正斜杠 (/) 作为目录分隔符。因此,当我提供 Windows 样式路径时,它不起作用。

我做了如下。我先连接到数据库:

C:\MyApp>heroku pg:psql DATABASE

然后我运行了这个命令:

d17q2hrd89o9cu=> \i C:/MyApp/db/structure.sql

并且本地structure.sql文件中提到的所有表都是在 Heroku 主机上创建的。

于 2013-06-19T11:12:30.040 回答