Working with schema migrations in Active Record

11 Jun 23

Working with the schema migrations can be a pain sometimes.

This snippet can be pasted into a rails console (or defined in an initializer in dev environments).

class SchemaMigration < ActiveRecord::Base; self.primary_key = :version; end

It defines a SchemaMigration model inline so you can work with them directly in Rails.