0
0

More than 1 year has passed since last update.

Heroku CI で Postgres のセットアップに失敗するようになった

Posted at

2022年8月からHerokuCIでのテスト実行時にデータベースのセットアップに失敗するようになった。

環境

  • Rails 6.0
  • Postgres (Heroku Postgres)

事象

heroku_ext schema とは・・。

rake aborted!
ActiveRecord::StatementInvalid: PG::RaiseException: ERROR:  Extensions can only be created on heroku_ext schema

原因

2022年8月1日から、新しく作られる全ての Heroku Postgres データベースでは heroku_ext schema がインストールされる、というようなことが書いてある。
https://devcenter.heroku.com/changelog-items/2446

対処法

ひとまず schema.rb の先頭を以下のように変更したところ失敗しなくなった。
この方法がなぜ有効なのかは調査中。

ActiveRecord::Schema.define(version: 2022_07_29_062012) do

  # These are extensions that must be enabled in order to support this database
-  enable_extension "plpgsql"
+  connection.execute('CREATE EXTENSION IF NOT EXISTS "plpgsql" WITH SCHEMA "heroku_ext"')
  ...
end

補足

  • Heroku ReviewApps でも発生するらしい
0
0
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
0
0