alexbevi / redmine_knowledgebase

A knowledgebase plugin for Redmine
453 stars 197 forks source link

redmine_knowledgebase and redmine_re ... table conflict .. ratings ... #242

Closed eskuai closed 10 years ago

eskuai commented 10 years ago

Hello,

When I am trying to install and i got the following error :+1:

---- begin copy & paste --- AddRedmineUserAsResponsibleToArtifactProperties: migrating ============== -- add_column(:re_artifact_properties, "responsible_id", :integer)

0.0748s

  • remove_column(:re_artifact_properties, :responsibles) -> 0.0769s AddRedmineUserAsResponsibleToArtifactProperties: migrated (0.1528s) ===== CreateReUseCases: migrating ============================================= -- create_table(:re_use_cases) -> 0.0394s CreateReUseCases: migrated (0.0395s) ==================================== CreateReUseCaseSteps: migrating ========================================= -- create_table(:re_use_case_steps) -> 0.0375s CreateReUseCaseSteps: migrated (0.0376s) ================================ CreateReUseCaseStepExpansions: migrating ================================ -- create_table(:re_use_case_step_expansions) -> 0.0393s CreateReUseCaseStepExpansions: migrated (0.0394s) ======================= CreateRatings: migrating ================================================ -- create_table(:ratings) rake aborted! An error has occurred, all later migrations canceled:

Mysql2::Error: Table 'ratings' already exists: CREATE TABLE ratings (id int(11) DEFAULT NULL auto_increment PRIMARY KEY, user_id varchar(255), re_artifact_properties_id varchar(255), value int(11)) ENGINE=InnoDB/usr/local/rvm/gems/ruby-1.9.3-p545/gems/activerecord-3.2.17/lib/active_record/connection_adapt ers/abstract_mysql_adapter.rb:245:in query' /usr/local/rvm/gems/ruby-1.9.3-p545/gems/activerecord-3.2.17/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:inblock in execute' /usr/local/rvm/gems/ruby-1.9.3-p545/gems/activerecord-3.2.17/lib/active_record/connection_adapters/abstract_adapter.rb:280:in block in log' /usr/local/rvm/gems/ruby-1.9.3-p545/gems/activesupport-3.2.17/lib/active_support/notifications/instrumenter.rb:20:ininstrument' /usr/local/rvm/gems/ruby-1.9.3-p545/gems/activerecord-3.2.17/lib/active_record/connection_adapters/abstract_adapter.rb:275:in log' /usr/local/rvm/gems/ruby-1.9.3-p545/gems/activerecord-3.2.17/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:inexecute' /usr/local/rvm/gems/ruby-1.9.3-p545/gems/activerecord-3.2.17/lib/active_record/connection_adapters/mysql2_adapter.rb:213:in execute' /usr/local/rvm/gems/ruby-1.9.3-p545/gems/activerecord-3.2.17/lib/active_record/connection_adapters/abstract/schema_statements.rb:170:increate_table' /usr/local/rvm/gems/ruby-1.9.3-p545/gems/activerecord-3.2.17/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:434:in create_table' /usr/local/rvm/gems/ruby-1.9.3-p545/gems/activerecord-3.2.17/lib/active_record/migration.rb:466:inblock in method_missing' /usr/local/rvm/gems/ruby-1.9.3-p545/gems/activerecord-3.2.17/lib/active_record/migration.rb:438:in block in say_with_time' /usr/local/rvm/gems/ruby-1.9.3-p545/gems/activerecord-3.2.17/lib/active_record/migration.rb:438:insay_with_time' ---- end copy & paste ---

What is happen?

Ok, two tables are using same name ... but differents plugins ... redmine-re and knowledgebase plugins are in conflict...

Because, if i do ...

root@darkstar:/var/www/redmine/plugins# find . -name "*.rb" | xargs grep -i "ratings"

shows ./redmine_knowledgebase/lib/acts_as_rated.rb got a table "rating".

Is there a "easy way" to change the name of the table "ratings" , and change it to "kratings" ... for exam,ple

How can i change "sql" creating process, and the rb files to create and use this table with another name?

Any way to do this? avoid tables name from differents plugins conflict?

Thank you

alexbevi commented 10 years ago

There generally isn't an "easy" way to do this, and table collisions are sadly a common issue with Redmine plugins.

You could try the following for now though:

  1. edit db/migrate/20100317201659_add_ratings_to_articles.rb
class AddRatingsToArticles < ActiveRecord::Migration
  require 'acts_as_rated'

  def self.up
    # change this entry
    ActiveRecord::Base.create_ratings_table :table_name => "kb_ratings", :with_rater => false
  end

  def self.down
    # change this entry
    ActiveRecord::Base.drop_ratings_table :table_name => "kb_ratings"
  end
end
  1. edit ```
class KbArticle < ActiveRecord::Base
  unloadable

  # ...
  # update this entry
  acts_as_rated :rating_class => "KbRating", :no_rater => true
  #...
end

This is completely untested and i'm doing this from memory, but it might work ...

eskuai commented 10 years ago

Thank you Tested and it works perfect ... i got not problems trying to install redmine_re ...