Skip to content

Error uninstalling plugin (indicator_right field remains installed) #27

@johnjeffersoncm

Description

@johnjeffersoncm

Description

The Plugin is uninstalled, but the indicator_right custom field remains active on the projects screen (http://redmine:3000/projects/projectname/settings)

image

Log

root@f8cd075557aa:/usr/src/redmine# bundle exec rake db:migrate RAILS_ENV=production && bundle exec rake redmine:plugins:migrate RAILS_ENV=production
W, [2024-04-12T00:11:21.904302 #32] WARN -- : Creating scope :system. Overwriting existing method Enumeration.system.
W, [2024-04-12T00:11:28.147593 #32] WARN -- : Creating scope :sorted. Overwriting existing method User.sorted.
W, [2024-04-12T00:11:31.909098 #32] WARN -- : Creating scope :visible. Overwriting existing method Principal.visible.
W, [2024-04-12T00:13:06.936815 #39] WARN -- : Creating scope :system. Overwriting existing method Enumeration.system.
W, [2024-04-12T00:13:11.919038 #39] WARN -- : Creating scope :sorted. Overwriting existing method User.sorted.
W, [2024-04-12T00:13:15.516745 #39] WARN -- : Creating scope :visible. Overwriting existing method Principal.visible.
root@f8cd075557aa:/usr/src/redmine# bundle exec rake redmine:plugins:migrate NAME=redmine_indicator VERSION=0 RAILS_ENV=production
W, [2024-04-12T11:29:15.065099 #78] WARN -- : Creating scope :system. Overwriting existing method Enumeration.system.
W, [2024-04-12T11:29:17.323129 #78] WARN -- : Creating scope :sorted. Overwriting existing method User.sorted.
W, [2024-04-12T11:29:18.813650 #78] WARN -- : Creating scope :visible. Overwriting existing method Principal.visible.
I, [2024-04-12T11:29:28.920507 #78] INFO -- : Migrating to IndicatorProjectSttingsAdd (20200519)
== 20200519 IndicatorProjectSttingsAdd: reverting =============================
-- remove_column(:projects, :indicator_left_top, :text)
-> 0.1543s
-- remove_column(:projects, :indicator_left_bottom, :text)
-> 0.1119s
-- remove_column(:projects, :indicator_right, :text)
-> 0.1204s
== 20200519 IndicatorProjectSttingsAdd: reverted (0.5533s) ====================

I, [2024-04-12T11:29:29.537270 #78] INFO -- : Migrating to IndicatorCustomFields (20191221)
== 20191221 IndicatorCustomFields: reverting ==================================
rake aborted!
StandardError: An error has occurred, all later migrations canceled:

undefined method `delete' for nil:NilClass

  ProjectCustomField.find_by_name('indicator_left_right').delete unless ProjectCustomField.find_by_name('indicator_right').nil?
                                                         ^^^^^^^

/usr/src/redmine/plugins/redmine_indicator/db/migrate/20191221_indicator_custom_fields.rb:31:in down' /usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:836:in down'
/usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:870:in public_send' /usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:870:in exec_migration'
/usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:851:in block (2 levels) in migrate' /usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:850:in block in migrate'
/usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:462:in with_connection' /usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:849:in migrate'
/usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1037:in migrate' /usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1329:in block in execute_migration_in_transaction'
/usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1382:in ddl_transaction' /usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1328:in execute_migration_in_transaction'
/usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1302:in each' /usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1302:in migrate_without_lock'
/usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1251:in block in migrate' /usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1401:in block in with_advisory_lock'
/usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1416:in block in with_advisory_lock_connection' /usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:462:in with_connection'
/usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1416:in with_advisory_lock_connection' /usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1397:in with_advisory_lock'
/usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1251:in migrate' /usr/src/redmine/lib/redmine/plugin.rb:478:in down'
/usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1065:in migrate' /usr/src/redmine/lib/redmine/plugin.rb:500:in migrate_plugin'
/usr/src/redmine/lib/redmine/plugin.rb:441:in migrate' /usr/src/redmine/lib/redmine/plugin.rb:452:in migrate'
/usr/src/redmine/lib/tasks/redmine.rake:151:in block (3 levels) in <top (required)>' /usr/local/bin/bundle:25:in load'
/usr/local/bin/bundle:25:in `

'

Caused by:
NoMethodError: undefined method `delete' for nil:NilClass

  ProjectCustomField.find_by_name('indicator_left_right').delete unless ProjectCustomField.find_by_name('indicator_right').nil?
                                                         ^^^^^^^

/usr/src/redmine/plugins/redmine_indicator/db/migrate/20191221_indicator_custom_fields.rb:31:in down' /usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:836:in down'
/usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:870:in public_send' /usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:870:in exec_migration'
/usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:851:in block (2 levels) in migrate' /usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:850:in block in migrate'
/usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:462:in with_connection' /usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:849:in migrate'
/usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1037:in migrate' /usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1329:in block in execute_migration_in_transaction'
/usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1382:in ddl_transaction' /usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1328:in execute_migration_in_transaction'
/usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1302:in each' /usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1302:in migrate_without_lock'
/usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1251:in block in migrate' /usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1401:in block in with_advisory_lock'
/usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1416:in block in with_advisory_lock_connection' /usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:462:in with_connection'
/usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1416:in with_advisory_lock_connection' /usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1397:in with_advisory_lock'
/usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1251:in migrate' /usr/src/redmine/lib/redmine/plugin.rb:478:in down'
/usr/local/bundle/gems/activerecord-6.1.7.2/lib/active_record/migration.rb:1065:in migrate' /usr/src/redmine/lib/redmine/plugin.rb:500:in migrate_plugin'
/usr/src/redmine/lib/redmine/plugin.rb:441:in migrate' /usr/src/redmine/lib/redmine/plugin.rb:452:in migrate'
/usr/src/redmine/lib/tasks/redmine.rake:151:in block (3 levels) in <top (required)>' /usr/local/bin/bundle:25:in load'
/usr/local/bin/bundle:25:in `

'
Tasks: TOP => redmine:plugins:migrate
(See full trace by running task with --trace)
root@f8cd075557aa:/usr/src/redmine#

chatgpt review:

It seems like there's an error occurring during a migration process in Redmine related to a plugin called "redmine_indicator." The error specifically states:

undefined method `delete' for nil:NilClass

This error is happening in the migration file 20191221_indicator_custom_fields.rb at line 31. The code snippet causing the issue is:

ProjectCustomField.find_by_name('indicator_left_right').delete unless ProjectCustomField.find_by_name('indicator_right').nil?

It's trying to delete a ProjectCustomField instance, but it seems like find_by_name('indicator_left_right') is returning nil, meaning it couldn't find a custom field with that name. As a result, it's trying to call delete on nil, which causes the error.

To resolve this issue, you'll need to ensure that the custom field with the name 'indicator_left_right' exists before attempting to delete it. You may need to check your database to see if the custom field exists with that name or if there's any issue with the migration script itself. Once you identify the problem, you can adjust the migration script accordingly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions