Skip to content

List columns within the method for a migration#11377

Merged
Gargron merged 1 commit intomastodon:masterfrom
zunda:fix-nomethoderror-in-migration
Jul 23, 2019
Merged

List columns within the method for a migration#11377
Gargron merged 1 commit intomastodon:masterfrom
zunda:fix-nomethoderror-in-migration

Conversation

@zunda
Copy link
Copy Markdown
Contributor

@zunda zunda commented Jul 22, 2019

I tried creating a new server after a while and saw the exception below while running rake db:migrate for the first time. This change is to avoid this exception.

NoMethodError: undefined method `perform' for nil:NilClass
.../vendor/bundle/ruby/2.6.0/gems/strong_migrations-0.4.1/lib/strong_migrations/migration.rb:14:in `method_missing'
.../vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.3/lib/active_record/migration.rb:604:in `method_missing'
.../db/migrate/20170918125918_ids_to_bigints.rb:69:in `<class:IdsToBigints>'
.../db/migrate/20170918125918_ids_to_bigints.rb:3:in `<top (required)>'

To avoid the exception:

NoMethodError: undefined method `perform' for nil:NilClass
.../vendor/bundle/ruby/2.6.0/gems/strong_migrations-0.4.1/lib/strong_migrations/migration.rb:14:in `method_missing'
.../vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.3/lib/active_record/migration.rb:604:in `method_missing'
.../db/migrate/20170918125918_ids_to_bigints.rb:69:in `<class:IdsToBigints>'
.../db/migrate/20170918125918_ids_to_bigints.rb:3:in `<top (required)>'
@ClearlyClaire
Copy link
Copy Markdown
Contributor

It looks ok to me, but I'm not sure how that's changing anything?

@zunda
Copy link
Copy Markdown
Contributor Author

zunda commented Jul 23, 2019

It seems to me that the exception is raised at migration.rb:14. in the definition of method_missing(method, *args) method:

      @checker.perform(method, *args) do

before the instance variable @checker is initialized. While I haven't fully followed it, it seems to me happening when table_exists?(:deprecated_preview_cards) is evaluated while the file is being loaded.

This change is to defer the evaluation until when up or down method is called so that @checker will have been initialized.

@Gargron Gargron merged commit cd68714 into mastodon:master Jul 23, 2019
hiyuki2578 pushed a commit to ProjectMyosotis/mastodon that referenced this pull request Oct 2, 2019
To avoid the exception:

NoMethodError: undefined method `perform' for nil:NilClass
.../vendor/bundle/ruby/2.6.0/gems/strong_migrations-0.4.1/lib/strong_migrations/migration.rb:14:in `method_missing'
.../vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.3/lib/active_record/migration.rb:604:in `method_missing'
.../db/migrate/20170918125918_ids_to_bigints.rb:69:in `<class:IdsToBigints>'
.../db/migrate/20170918125918_ids_to_bigints.rb:3:in `<top (required)>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants