Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

impossible to uninstall, the database won't downgrade #53

Closed
hobbes opened this issue Sep 15, 2014 · 5 comments
Closed

impossible to uninstall, the database won't downgrade #53

hobbes opened this issue Sep 15, 2014 · 5 comments
Assignees
Labels
Milestone

Comments

@hobbes
Copy link

hobbes commented Sep 15, 2014

Hi,

while trying to uninstall the plugin as per the docs, I get an error that seems to indicate that the database can't downgrade:

rake --trace redmine:plugins:migrate NAME=recurring_tasks VERSION=0 RAILS_ENV=production
** Invoke redmine:plugins:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute redmine:plugins:migrate
Migrating recurring_tasks (Recurring Tasks (Issues))...
== SetDefaultModifierForExistingMonthlyIssues: reverting =====================
rake aborted!
An error has occurred, this and all later migrations canceled:

ActiveRecord::IrreversibleMigration/usr/local/share/redmine-2.5.0/plugins/recurring_tasks/db/migrate/004_set_default_modifier_for_existing_monthly_issues.rb:21:in `down'
......

I don't understand all of it, but reading the file seems to indicate that the database modifications cannot be reverted. If this plugin is really impossible to remove, it should at the very least say so in the docs, and better print a big fat warning before it attempts to modifiy the database... Is there another way to get back ?

Thanks for your work,

Rémi

@nutso
Copy link
Owner

nutso commented Sep 20, 2014

Hi Rémi,

I just pushed the fix so it does not error out completely when rolling back -- you can either pull from the develop branch, or you can comment out (add a # at the beginning of the line) the following line in db/migrate/004_set_default_modifier_for_existing_monthly_issues.rb and db/migrate/002_standardize_recurrence_units_nonlocalized.rb within the plugin's directory:

raise ActiveRecord::IrreversibleMigration

These migrations are not reversible, but neither do they prevent you from removing the plugin.

@nutso nutso closed this as completed Sep 20, 2014
@nutso nutso self-assigned this Sep 20, 2014
@nutso nutso added the bug label Sep 20, 2014
nutso added a commit that referenced this issue Sep 20, 2014
@hobbes
Copy link
Author

hobbes commented Sep 23, 2014

Hello, now I go further, but still stopped by this:

Migrating recurring_tasks (Recurring Tasks (Issues))...
== AddIntervalModifierField: reverting =======================================
rake aborted!
An error has occurred, this and all later migrations canceled:

ActiveRecord::IrreversibleMigration/var/lib/gems/1.8/gems/activerecord-3.2.17/lib/active_record/migration/command_recorder.rb:42:in inverse' /var/lib/gems/1.8/gems/activerecord-3.2.17/lib/active_record/migration/command_recorder.rb:40:inmap'
/var/lib/gems/1.8/gems/activerecord-3.2.17/lib/active_record/migration/command_recorder.rb:40:in inverse' /var/lib/gems/1.8/gems/activerecord-3.2.17/lib/active_record/migration.rb:401:inmigrate'
/var/lib/gems/1.8/gems/activerecord-3.2.17/lib/active_record/migration.rb:358:in revert' /var/lib/gems/1.8/gems/activerecord-3.2.17/lib/active_record/migration.rb:400:inmigrate'
/var/lib/gems/1.8/gems/activerecord-3.2.17/lib/active_record/migration.rb:399:in migrate' /var/lib/gems/1.8/gems/activerecord-3.2.17/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:inwith_connection'
/var/lib/gems/1.8/gems/activerecord-3.2.17/lib/active_record/migration.rb:389:in migrate' /var/lib/gems/1.8/gems/activerecord-3.2.17/lib/active_record/migration.rb:528:insend'
/var/lib/gems/1.8/gems/activerecord-3.2.17/lib/active_record/migration.rb:528:in migrate' /var/lib/gems/1.8/gems/activerecord-3.2.17/lib/active_record/migration.rb:720:inmigrate'
/var/lib/gems/1.8/gems/activerecord-3.2.17/lib/active_record/migration.rb:775:in call' /var/lib/gems/1.8/gems/activerecord-3.2.17/lib/active_record/migration.rb:775:inddl_transaction'
/var/lib/gems/1.8/gems/activerecord-3.2.17/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in transaction' /var/lib/gems/1.8/gems/activerecord-3.2.17/lib/active_record/transactions.rb:208:intransaction'
/var/lib/gems/1.8/gems/activerecord-3.2.17/lib/active_record/migration.rb:775:in ddl_transaction' /var/lib/gems/1.8/gems/activerecord-3.2.17/lib/active_record/migration.rb:719:inmigrate'
/var/lib/gems/1.8/gems/activerecord-3.2.17/lib/active_record/migration.rb:700:in each' /var/lib/gems/1.8/gems/activerecord-3.2.17/lib/active_record/migration.rb:700:inmigrate'
/var/lib/gems/1.8/gems/activerecord-3.2.17/lib/active_record/migration.rb:574:in down' /var/lib/gems/1.8/gems/activerecord-3.2.17/lib/active_record/migration.rb:555:inmigrate'
Tasks: TOP => redmine:plugins:migrate
(See full trace by running task with --trace)

Thanks,

Rémi

@nutso
Copy link
Owner

nutso commented Nov 21, 2014

Hi Remi,

I'm not seeing any reference to the plugin in the most recent error list. Can you run the migration with the --trace flag and post the results? The current version shouldn't have any issues reverting the migrations.

Do you still have a recurring_tasks table in your database? If not, this particular migration might have failed because the table it is trying to modify has already been dropped.

@quanvn
Copy link

quanvn commented May 16, 2015

I guest the problem is the migration scheme defines change for adding the interval_modifier, and migration cannot remove the column when uninstall. So I modified the file
recurring_tasks\db\migrate\003_add_interval_modifier_field.rb to make it into this:

class AddIntervalModifierField < ActiveRecord::Migration
def self.up
change_table :recurring_tasks do |t|
t.column :interval_modifier, :string
end
end

def self.down
remove_column :recurring_tasks, :interval_modifier
end

end

Then I can uninstall

@nutso nutso mentioned this issue Jun 14, 2015
@nutso nutso added this to the v1.5.0 milestone Jun 14, 2015
@Peneheals
Copy link

I leave this comment for archive purposes (Google, crawl it! :D ):

I wanted to uninstall the plugin (v1.3.0) the usual way (bundle exec rake redmine:plugins NAME=recurring_tasks VERSION=0 RAILS_ENV=production)

I got an error:

Migrating recurring_tasks (Recurring Tasks (Issues))...
==  StandardizeRecurrenceUnitsNonlocalized: reverting =========================
rake aborted!
An error has occurred, all later migrations canceled:

ActiveRecord::IrreversibleMigration/plugins/recurring_tasks/db/migrate/002_standardize_recurrence_units_nonlocalized.rb:28:in 'down'
/home/redmine/.rvm/gems/ruby-1.9.3-p551/gems/activerecord-3.2.19/lib/active_record/migration.rb:410:in 'block (2 levels) in migrate'
/home/redmine/.rvm/gems/ruby-1.9.3-p551/gems/activerecord-3.2.19/lib/active_record/migration.rb:410:in 'block in migrate'
/home/redmine/.rvm/gems/ruby-1.9.3-p551/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in 'with_connection'
/home/redmine/.rvm/gems/ruby-1.9.3-p551/gems/activerecord-3.2.19/lib/active_record/migration.rb:389:in 'migrate'
/home/redmine/.rvm/gems/ruby-1.9.3-p551/gems/activerecord-3.2.19/lib/active_record/migration.rb:528:in 'migrate'
/home/redmine/.rvm/gems/ruby-1.9.3-p551/gems/activerecord-3.2.19/lib/active_record/migration.rb:720:in 'block (2 levels) in migrate'
/home/redmine/.rvm/gems/ruby-1.9.3-p551/gems/activerecord-3.2.19/lib/active_record/migration.rb:777:in 'call'
/home/redmine/.rvm/gems/ruby-1.9.3-p551/gems/activerecord-3.2.19/lib/active_record/migration.rb:777:in 'ddl_transaction'
/home/redmine/.rvm/gems/ruby-1.9.3-p551/gems/activerecord-3.2.19/lib/active_record/migration.rb:719:in 'block in migrate'
/home/redmine/.rvm/gems/ruby-1.9.3-p551/gems/activerecord-3.2.19/lib/active_record/migration.rb:700:in 'each'
/home/redmine/.rvm/gems/ruby-1.9.3-p551/gems/activerecord-3.2.19/lib/active_record/migration.rb:700:in 'migrate'
/home/redmine/.rvm/gems/ruby-1.9.3-p551/gems/activerecord-3.2.19/lib/active_record/migration.rb:574:in 'down'
/home/redmine/.rvm/gems/ruby-1.9.3-p551/gems/activerecord-3.2.19/lib/active_record/migration.rb:555:in 'migrate'
/lib/redmine/plugin.rb:452:in 'migrate_plugin'
/lib/redmine/plugin.rb:424:in 'migrate'
/lib/redmine/plugin.rb:435:in 'migrate'
/lib/tasks/redmine.rake:126:in 'block (3 levels) in <top (required)>'
/lib/tasks/redmine.rake:52:in 'block (2 levels) in <top (required)>'
/home/redmine/.rvm/gems/ruby-1.9.3-p551/bin/ruby_executable_hooks:15:in 'eval'
/home/redmine/.rvm/gems/ruby-1.9.3-p551/bin/ruby_executable_hooks:15:in '<main>'
Tasks: TOP => redmine:plugins:migrate
(See full trace by running task with --trace)

After updating to v1.5.0 (cd plugins/recurring_tasks && git fetch && git merge v1.5.0) I was able to completely remove the plugin without any problem.

So if you can not uninstall, update it and try again :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants