jesseduffield / lazy_migrate

A little terminal UI for managing schema migrations in rails

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't launch with latest Rails version

sowenjub opened this issue · comments

Hey Jesse, I tried running LazyMigration.run with rails 6.0.3.2 and I hit this error:

ArgumentError: wrong number of arguments
from ~.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.2/lib/active_record/migration.rb:1028:in `initialize'

I assume it comes from this line:

@context = T.let(ActiveRecord::MigrationContext.new(Rails.root.join('db', 'migrate')), ActiveRecord::MigrationContext)

And is a consequence of this change rails/rails@7cc27d7#diff-8d3c44120f7b67ff79e2fbe6a40d0ad6R1018

Same issue with Rails6

Interesting, I'll take a look

Any update ? ;)

I got this monkey patch

LazyMigrate::NewMigratorAdapter.class_eval do
  def initialize
    # TODO: consider making this a method rather than an instance variable
    # considering how cheap it is to obtain
    @context = ActiveRecord::MigrationContext.new(Rails.root.join('db', 'migrate'), ActiveRecord::SchemaMigration)
  end
end

Tested on rails 6.0.3.4

Full initializer content for lazy_migrate:

# frozen_string_literal: true

require "sane_patch"
require "lazy_migrate"

SanePatch.patch("lazy_migrate", "0.2.0") do
  LazyMigrate::NewMigratorAdapter.class_eval do
    def initialize
      # TODO: consider making this a method rather than an instance variable
      # considering how cheap it is to obtain
      @context = ActiveRecord::MigrationContext.new(Rails.root.join('db', 'migrate'), ActiveRecord::SchemaMigration)
    end
  end
end

Maybe we should consider #3 sooner since rails 6.1 is on RC already?

ezoic increase your site revenue