diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-07-26 08:30:19 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-07-26 08:30:19 +0000 |
commit | 2bc5b60f9de7c533b33348213f6ddac37dc9cdb3 (patch) | |
tree | 803c2d2ece43283b231b59ede3636c9fc2d3828a /db/migrate | |
parent | fdecb2a17b450c4524856b0286c2ec27ef113ea6 (diff) | |
download | redmine-2bc5b60f9de7c533b33348213f6ddac37dc9cdb3.tar.gz redmine-2bc5b60f9de7c533b33348213f6ddac37dc9cdb3.zip |
Makes new issue initial status settable in workflow (#5816).
git-svn-id: http://svn.redmine.org/redmine/trunk@14458 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'db/migrate')
-rw-r--r-- | db/migrate/20150725112753_insert_allowed_statuses_for_new_issues.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/db/migrate/20150725112753_insert_allowed_statuses_for_new_issues.rb b/db/migrate/20150725112753_insert_allowed_statuses_for_new_issues.rb new file mode 100644 index 000000000..dec3bdda1 --- /dev/null +++ b/db/migrate/20150725112753_insert_allowed_statuses_for_new_issues.rb @@ -0,0 +1,23 @@ +class InsertAllowedStatusesForNewIssues < ActiveRecord::Migration + def self.up + # Adds the default status for all trackers and roles + sql = "INSERT INTO #{WorkflowTransition.table_name} (tracker_id, old_status_id, new_status_id, role_id, type)" + + " SELECT t.id, 0, t.default_status_id, r.id, 'WorkflowTransition'" + + " FROM #{Tracker.table_name} t, #{Role.table_name} r" + WorkflowTransition.connection.execute(sql) + + # Adds other statuses that are reachable with one transition + # to preserve previous behaviour as default + sql = "INSERT INTO #{WorkflowTransition.table_name} (tracker_id, old_status_id, new_status_id, role_id, type)" + + " SELECT t.id, 0, w.new_status_id, w.role_id, 'WorkflowTransition'" + + " FROM #{Tracker.table_name} t" + + " JOIN #{IssueStatus.table_name} s on s.id = t.default_status_id" + + " JOIN #{WorkflowTransition.table_name} w on w.tracker_id = t.id and w.old_status_id = s.id and w.type = 'WorkflowTransition'" + + " WHERE w.new_status_id <> t.default_status_id" + WorkflowTransition.connection.execute(sql) + end + + def self.down + WorkflowTransition.where(:old_status_id => 0).delete_all + end +end |