Node.js 如何使用.sh文件配置heroku psql数据库?

Node.js 如何使用.sh文件配置heroku psql数据库?,node.js,heroku,psql,heroku-postgres,Node.js,Heroku,Psql,Heroku Postgres,我在heroku上托管了一个web应用程序,我正在尝试使用离线测试中使用的相同脚本设置数据库,但在heroku上,我不确定如何运行.sh脚本: dropdb -U node_user mydb createdb -U node_user mydb psql -U node_user mydb < ./bin/sql/firsttable.sql psql -U node_user mydb < ./bin/sql/secondtable.sql psql -U node_user

我在heroku上托管了一个web应用程序,我正在尝试使用离线测试中使用的相同脚本设置数据库,但在heroku上,我不确定如何运行.sh脚本:

dropdb -U node_user mydb
createdb -U node_user mydb

psql -U node_user mydb < ./bin/sql/firsttable.sql
psql -U node_user mydb < ./bin/sql/secondtable.sql
psql -U node_user mydb < ./bin/sql/thridtable.sql

如何在heroku的psql上运行.sh脚本,以便创建所有表?

通过连接到heroku上的DB,使用本地psql从您的计算机上运行它们

为此,您只需要凭据,您可以通过以下方式获得凭据:

$ heroku pg:credentials:url
请注意,您将无法使用
dropdb
createdb
在Heroku上删除和创建数据库

对于SQL文件,可以按如下方式运行它们:

$ psql $(heroku pg:credentials:url | grep 'postgres://') -f local_file.sql

…但您将无法
dropdb
createdb
。如果需要,请改用。
$ psql $(heroku pg:credentials:url | grep 'postgres://') -f local_file.sql