alphanodes / additionals

Redmine plugin for easy customization of settings, text and content display by using personal or role-based dashboards (drag&drop), providing wiki macros and act as library for other plugins.
https://www.redmine.org/plugins/additionals
GNU General Public License v2.0
131 stars 43 forks source link

Upgrade complains that index "index_dashboards_on_name" already exists #87

Closed Stevehans closed 3 years ago

Stevehans commented 3 years ago

Looks like it needs to check whether it exists before an attempt to create.

Dropping the index then fails on the table already existing.

Problem is, I'm running this as a docker image and the clean build reinstalls all the plugins, and the failure stops the build.

Not sure whether this is something that needs to go in db/migrate or whether this is an issue with redmine and migration in general?

Caused by:
ArgumentError: Index name 'index_dashboards_on_name' on table 'dashboards' already exists
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:1160:in `add_index_options'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/mysql/schema_creation.rb:67:in `index_in_create'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:51:in `block in visit_TableDefinition'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:51:in `map'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:51:in `visit_TableDefinition'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:16:in `accept'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:311:in `create_table'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:871:in `block in method_missing'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:840:in `block in say_with_time'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:840:in `say_with_time'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:860:in `method_missing'
/usr/src/redmine/plugins/additionals/db/migrate/003_create_dashboards.rb:3:in `change'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:814:in `exec_migration'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:798:in `block (2 levels) in migrate'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:797:in `block in migrate'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `with_connection'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:796:in `migrate'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:977:in `migrate'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1292:in `block in execute_migration_in_transaction'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1345:in `ddl_transaction'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1291:in `execute_migration_in_transaction'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1263:in `block in migrate_without_lock'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1262:in `each'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1262:in `migrate_without_lock'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1210:in `block in migrate'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1363:in `with_advisory_lock'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1210:in `migrate'
/usr/src/redmine/lib/redmine/plugin.rb:510:in `up'
/usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1011:in `migrate'
/usr/src/redmine/lib/redmine/plugin.rb:542:in `migrate_plugin'
/usr/src/redmine/lib/redmine/plugin.rb:483:in `migrate'
/usr/src/redmine/lib/redmine/plugin.rb:494:in `migrate'
/usr/src/redmine/lib/tasks/redmine.rake:135:in `block (3 levels) in <top (required)>'
/usr/local/bundle/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
Tasks: TOP => redmine:plugins:migrate
(See full trace by running task with --trace)
Stevehans commented 3 years ago

Just realised the issue, explanation here as a clue to anybody havng a search with similar issue.

I had pulled back a v3 database over a v4 database, so the schema_migrations table said it was v3, but as it had previously been v4 the dashboards table existed, this is what was causing the issue.

Bottom line, if you restore an earlier database you must drop and recreate the schema as you need the schema to be consistent with the schema_migrations table