如何找到开发数据库的名称? (PostgreSQL的/ Rails)的

时间:2020-12-11 07:33:22

I am tweaking a bash script I found somewhere for downloading the contents of your database on Heroku and the importing them into your development environment.

我正在调整一个bash脚本,我找到了在Heroku上下载数据库内容并将它们导入开发环境的地方。

#!/bin/bash
heroku pgbackups:capture --expire --app testivate
file_path="db_$(date +%Y_%m_%d-%H_%M_%S).dump"
curl `heroku pgbackups:url --app testivate` > $file_path
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U steven -d DATABASENAME $file_path

My question is, is there a command I can run to find the name of my development database?

我的问题是,是否有一个命令我可以运行以找到我的开发数据库的名称?

In /config/database.yml I have:

在/config/database.yml我有:

development:
  adapter: postgresql
  database: db/testivate_development
  pool: 5
  username: steven
  password: <redacted>
  host: localhost

So as my name I've tried "steven", "db/testivate_development" and "testivate_development", but all give "database does not exist" errors.

所以我的名字我尝试过“史蒂文”,“db / testivate_development”和“testivate_development”,但都给出了“数据库不存在”的错误。

2 个解决方案

#1


0  

Might I suggest you use the pg:transfer heroku client plugin. https://github.com/ddollar/heroku-pg-transfer

我建议你使用pg:transfer heroku客户端插件。 https://github.com/ddollar/heroku-pg-transfer

This lets you do:

这可以让你做到:

heroku pg:transfer --from VIOLET 

In your project folder you have a .env file which contains

在项目文件夹中,您有一个包含的.env文件

DATABASE_URL=postgres://127.0.0.1/development_db_name

it wraps up the capture, restore for you. VIOLET is the name of the DB url on Heroku (From heroku config. The rest should be self explanatory.

它包裹了捕获,为你恢复。 VIOLET是Heroku上的DB url的名称(来自heroku配置。其余的应该是自我解释的。

#2


0  

https://devcenter.heroku.com/articles/heroku-postgresql

https://devcenter.heroku.com/articles/heroku-postgresql

There's documentation on this page that shows how to find out this information. Heroku doesn't use your db name from the config file, it creates its own name and password which is basically random strings.

此页面上的文档显示了如何查找此信息。 Heroku不使用配置文件中的db名称,它会创建自己的名称和密码,这基本上是随机字符串。

#1


0  

Might I suggest you use the pg:transfer heroku client plugin. https://github.com/ddollar/heroku-pg-transfer

我建议你使用pg:transfer heroku客户端插件。 https://github.com/ddollar/heroku-pg-transfer

This lets you do:

这可以让你做到:

heroku pg:transfer --from VIOLET 

In your project folder you have a .env file which contains

在项目文件夹中,您有一个包含的.env文件

DATABASE_URL=postgres://127.0.0.1/development_db_name

it wraps up the capture, restore for you. VIOLET is the name of the DB url on Heroku (From heroku config. The rest should be self explanatory.

它包裹了捕获,为你恢复。 VIOLET是Heroku上的DB url的名称(来自heroku配置。其余的应该是自我解释的。

#2


0  

https://devcenter.heroku.com/articles/heroku-postgresql

https://devcenter.heroku.com/articles/heroku-postgresql

There's documentation on this page that shows how to find out this information. Heroku doesn't use your db name from the config file, it creates its own name and password which is basically random strings.

此页面上的文档显示了如何查找此信息。 Heroku不使用配置文件中的db名称,它会创建自己的名称和密码,这基本上是随机字符串。