Error message showed when tying to run generated migration for active_storage

Hi all,

after running rails active_storage:install and then issuing rails db:migrate, I get this error message:

== 20211031114839 AddServiceNameToActiveStorageBlobs: migrating ===============
-- column_exists?("active_storage_blobs", :service_name)
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::UndefinedTable: ERROR:  relation "active_storage_blobs" does not exist
LINE 8:  WHERE a.attrelid = '"active_storage_blobs"'::regclass

Note the single and double quote in the (generated?) SQL.

This is the (generated) migration:

# This migration comes from active_storage (originally 20190112182829)
class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0]
  def up
    unless column_exists?('active_storage_blobs', :service_name)
      add_column :active_storage_blobs, :service_name, :string

      if configured_service =
        ActiveStorage::Blob.unscoped.update_all(service_name: configured_service)

      change_column :active_storage_blobs, :service_name, :string, null: false

  def down
    remove_column :active_storage_blobs, :service_name

For reference rails about yields these versions & db info:

> rails about
About your application's environment
Rails version   
Ruby version              ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-darwin20]
RubyGems version          3.2.29
Rack version              2.2.3
Environment               development
Database adapter          postgresql

Am I doing it wrong? If so what?

I solved the problem the hard way by moving to asdf and reinstalling all the gems etc.

However, I still wonder what caused this behaviour…