LoginSignup
33
27

More than 5 years have passed since last update.

HerokuのPostgreSQLのTimezoneの変更方法

Posted at

事前準備

  • 操作端末にHerokuToolbeltがインストール済みであること。
  • 同様にpostgresがインストールされpsqlコマンドにPATHが通っていること

接続してみる

以下のコマンドを実行し、接続を確認する

heroku pg:psql --app your_database_name HEROKU_POSTGRESQL_TEAL

現状を確認

以下のコマンドを実行し、Timezoneがずれていることを確認する

> select current_timestamp;

Timezoneを変更

以下のコマンドを実行し、Timezoneを修正する

> alter database your_database_name set timezone = 'Asia/Tokyo';

一旦接続の解除

以下のコマンドで一旦接続を解除する

> \q

再度HerokuのPostgreSQLへ接続

heroku pg:psql --app your_database_name HEROKU_POSTGRESQL_TEAL

変更の適用の確認

再度以下のコマンドを実行し、Timezoneが期待通りであることを確認する。

> select current_timestamp;

以上です。

33
27
1

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
33
27