giddie / redmine_default_assign

Redmine ticket #482:Default assignment setting -- converted to a plugin and then extended.
Other
34 stars 26 forks source link

undefined method `default_assignee_id' #27

Closed Circuitsoft closed 6 years ago

Circuitsoft commented 8 years ago
ActionView::Template::Error (undefined method `default_assignee_id' for #<Project:0x0000000465e060>):
    25: <% @project.custom_field_values.each do |value| %>
    26:   <p><%= custom_field_tag_with_label :project, value %></p>
    27: <% end %>
    28: <%= call_hook(:view_projects_form, :project => @project, :form => f) %>
    29: </div>
    30: 
    31: <% if @project.new_record? %>

redmine 3.0~20140825-5 from Debian Jessie

# rake --trace redmine:plugins:migrate RAILS_ENV=production
** Invoke redmine:plugins:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute redmine:plugins:migrate
Migrating redmine_default_assign (Default Assign plugin)...
Migrating redmine_pretend (Redmine Pretend plugin)...
** Invoke db:schema:dump (first_time)
** Invoke environment 
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:schema:dump
giddie commented 8 years ago

I assume that if you check the projects table, there is in fact no default_assignee_id column? Has the plugin ever been installed before for this database?

Circuitsoft commented 8 years ago

Correct, that column is missing. The plugin has not been installed before on this database. I've run redmine:plugins:migrate, but I still don't see the column showing up.

Circuitsoft commented 8 years ago

After manually adding the field as an integer, I now see a new dropdown on the project settings page, called "translation missing: en.field_default_assignee". Clearly something is not running in the installation process.

giddie commented 8 years ago

What do you see when you go to list the plugins in Redmine settings? What version number for this plugin does it report? What happens when you click through to the settings page for the plugin?

Circuitsoft commented 8 years ago

Default Assign plugin Plugin implementing Douglas Campos' ticket-482 code as a plugin. It has since been extended to offer other features as well. Robert Chady / Paul Dann 0.6 Configure

Clicking Configure gives me a 404 error.

giddie commented 8 years ago

And what version of Redmine are you using?

tcx9871 commented 8 years ago

I have exactly same problem.

Redmine 2.5.2.devel

Environment: Redmine version 2.5.2.devel Ruby version 2.1.5-p273 (2014-11-13) [x86_64-linux-gnu] Rails version 4.1.8 Environment production Database adapter Mysql2 SCM: Darcs 2.8.5 Mercurial 3.1.2 Cvs 1.12.13 Bazaar 2.7.0 Git 2.1.4 Filesystem
Redmine plugins: redmine_default_assign 0.6

giddie commented 8 years ago

OK, I've found and fixed the issue. Can you check that commit 835dee40712b8358668dcbd3498d871a4d340d8a has solved the problem?

tcx9871 commented 8 years ago

Unfortunately it does not ...

┌─[root @ redmine]─[/usr/share/redmine]─[614]─[10:47] └─[$]› rake redmine:plugins:migrate RAILS_ENV=production --trace * Invoke redmine:plugins:migrate (first_time) * Invoke environment (first_time) * Execute environment * Execute redmine:plugins:migrate Migrating redmine_default_assign (Default Assign plugin)... Migrating toggl (Toggl plugin)... * Invoke db:schema:dump (first_time) * Invoke environment * Invoke db:load_config (first_time) * Execute db:load_config \ Execute db:schema:dump

mysql> desc projects; +-----------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(255) | NO | | | | | description | text | YES | | NULL | | | homepage | varchar(255) | YES | | | | | is_public | tinyint(1) | NO | | 1 | | | parent_id | int(11) | YES | | NULL | | | created_on | datetime | YES | | NULL | | | updated_on | datetime | YES | | NULL | | | identifier | varchar(255) | YES | | NULL | | | status | int(11) | NO | | 1 | | | lft | int(11) | YES | MUL | NULL | | | rgt | int(11) | YES | MUL | NULL | | | inherit_members | tinyint(1) | NO | | 0 | | +-----------------+--------------+------+-----+---------+----------------+ 13 rows in set (0.00 sec)

tcx9871 commented 8 years ago

... and it seems that it may be a broader problem - I have excatly same problem with another plugin (toggl), and I've found this https://www.redmine.org/boards/2/topics/38958 which describes same situation ...

giddie commented 8 years ago

Yeah, it's to do with the way plugin migrations are named. Would you be able to provide me with a pastebin/gist of your schema_migrations table?

tcx9871 commented 8 years ago

I've migrated this redmine instalation (it's database) from redmine version 1.4.4 to (this) version 2.5.2.devel (from Debian Jessie) ...

tcx9871 commented 8 years ago

this

mysql> select * from schema_migrations where version like '%-redmine_default_assign'; +---------------------------------------+ | version | +---------------------------------------+ | 20090508035844-redmine_default_assign | +---------------------------------------+ 1 row in set (0.01 sec)

is still there ...

tcx9871 commented 8 years ago

http://pastebin.com/dzpUypxT ... it's a bit mess ...

giddie commented 8 years ago

Huh; and you're sure you checked out that commit correctly? It really should have removed the old migration entry...

tcx9871 commented 8 years ago

┌─[root @ redmine]─[/usr/share/redmine/lib/plugins/redmine_default_assign]─[623]─[11:08] └─[$]› git status On branch master Your branch is up-to-date with 'origin/master'. nothing to commit, working directory clean

┌─[root @ redmine]─[/usr/share/redmine/lib/plugins/redmine_default_assign]─[624]─[11:08] └─[$]› git log | head -10 commit 835dee40712b8358668dcbd3498d871a4d340d8a Author: Paul Gideon Dann pdgiddie@gmail.com Date: Tue Jan 12 09:40:41 2016 +0000

Fix issue caused by change in migration naming scheme

commit 78202cf1d5938ee8381a0b527ee718209a327306 Merge: edb2ff1 67a4d42 Author: Paul Gideon Dann pdgiddie@gmail.com Date: Mon Nov 23 09:38:45 2015 +0000

┌─[root @ redmine]─[/usr/share/redmine/lib/plugins/redmine_default_assign]─[625]─[11:08] └─[$]› cat ./db/migrate/001_add_default_assignee_to_project.rb class AddDefaultAssigneeToProject < ActiveRecord::Migration def self.up

Work around migration name change (Github issue #27)

old_num = '20090508035844'
num_deleted =
  ::ActiveRecord::Base.connection.delete(<<-SQL.squish)
    delete from schema_migrations
    where version = '#{old_num}-redmine_default_assign'
  SQL
return  if num_deleted > 0
add_column :projects, :default_assignee_id, :integer

end

def self.down remove_column :projects, :default_assignee_id end end

┌─[root @ redmine]─[/usr/share/redmine/lib/plugins/redmine_default_assign]─[626]─[11:09] └─[$]›

giddie commented 8 years ago

OK, I'm working with Redmine 3.1.0. Is it viable for you to upgrade?

tcx9871 commented 8 years ago

Not likely ... :|

giddie commented 8 years ago

OK, your best course of action might be to manually remove that migration entry in the schema_migrations table, then run plugin migrations again.

tcx9871 commented 8 years ago

Just did that ... did not help, table projects without any modification, table schema_migrations without any new entry ...

giddie commented 8 years ago

That's pretty weird. As far as I can tell, the Redmine code in that version should be picking up the migration and applying it. Can you see anything here that might explain why it's not applying the migration from the plugin?

https://github.com/redmine/redmine/blob/2.5.2/lib/redmine/plugin.rb

ghost commented 6 years ago

Hi, on 3.4.3 version I tried this plugin. First of all I downloaded this plugin as ZIP and the name of the folder was redmine_default_assign-master Putting this folder in redmine's plugins folder, it DOESN'T migrate correctly!

Renaming the plugin folder and removing -master, i.e. redmine_default_assign the migration works succesfully.

Here the success migration. I hope this helps you:

root# rake redmine:plugins:migrate RAILS_ENV=production Migrating redmine_agile (Redmine Agile plugin (Light version))... Migrating redmine_auto_assign_group (Redmine Auto Assign Group Plugin)... Migrating redmine_default_assign (Default Assign plugin)... == 1 AddDefaultAssigneeToProject: migrating =================================== -- add_column(:projects, :default_assignee_id, :integer) -> 0.0015s == 1 AddDefaultAssigneeToProject: migrated (0.0026s) ==========================

Migrating redmine_editauthor (Redmine Edit Issue Author)... Migrating redmine_git_remote (Redmine Git Remote)... Migrating redmine_openid_connect (Redmine Openid Connect plugin)...

giddie commented 6 years ago

Thanks for bringing that to my attention. I actually don't have any control over those zip files, as they're generated automatically by Github. But I'll add a step to the instructions in the Readme.