Why am I getting ExclusiveLock errors during a rails migration on postgres

Viewed 2266

getting error when trying to run a migration

WARNING: you don't own a lock of type ExclusiveLock rake aborted! StandardError: An error has occurred, this and all later migrations canceled:

the migration looks something like

def up
    ActiveRecord::Base.establish_connection
    ActiveRecord::Base.connection.execute(
      File.read(File.expand_path('setup.sql'))
    )

    change_column :staff_members, :id, :integer, auto_increment: true
end 

The sql file branches into different databases, and this particular table needs to redefine its id column that's all.

2 Answers

The solution I discovered was to manually close the connection ActiveRecord::Base.connection.close

Related