3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Heroku Postgres を PhpStormのDatabaseで確認する

Last updated at Posted at 2016-03-08

Database接続情報を確認する

$ heroku config
=== sampleApp Config Vars
DATABASE_URL:         postgres://{USERNAME}:{PASSWORD}@{HOST}:{PORT}/{DATABASE}

メモ帳とかにコピペしておくと良い。
分解するのが面倒ならparse_urlで処理することも出来る。

php -r "var_dump(parse_url('postgres://{USERNAME}:{PASSWORD}@{HOST}:{PORT}/{DATABASE}'));"

設定をPhpStormにねじ込む

データベースの設定情報が確認できたら設定をPhpStormへ

Databaseのパネルの「+」から「Data Source」->「PostgresSQL」を選択し、

GeneralのタブにてHost User Password Database を入力する。

Advanced のタブを選択して

ssl の欄に true
sslfactory の欄に org.postgresql.ssl.NonValidatingFactory をセット

General に戻って Test Connection をクリックし、接続が成功している化確認する。

public以外のデータベースも見たい

Heroku Connect 使用時など、public以外のデータベースも見たい場合には、Schemasのタブを選択して、

必要なデータベースをにチェックマークを入れると良いです。

もっと気軽に使いたい

JDBC URL形式に変換すると PHPStormでの取り込みが楽だったりします。

変換用のツールを作りました。

postgresのURLを一番上のフィールドに追加するとjdbc URLが生成サれるので、

あとはPHPStormのDatabaseから + ボタン -> [Datasource From URL]を選択すればOKです。

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?