view .svn/pristine/b2/b2da07c5b59f5a76f7942979d584cb5b875f39ed.svn-base @ 1516:b450a9d58aed redmine-2.4

Update to Redmine SVN revision 13356 on 2.4-stable branch
author Chris Cannam
date Tue, 09 Sep 2014 09:28:31 +0100
parents 038ba2d95de8
children
line wrap: on
line source
class AddUniqueIndexToIssueRelations < ActiveRecord::Migration
  def self.up

    # Remove duplicates
    IssueRelation.connection.select_values("SELECT r.id FROM #{IssueRelation.table_name} r" +
      " WHERE r.id > (SELECT min(r1.id) FROM #{IssueRelation.table_name} r1 WHERE r1.issue_from_id = r.issue_from_id AND r1.issue_to_id = r.issue_to_id)").each do |i|
        IssueRelation.delete_all(["id = ?", i])
    end

    add_index :issue_relations, [:issue_from_id, :issue_to_id], :unique => true
  end

  def self.down
    remove_index :issue_relations, :column => [:issue_from_id, :issue_to_id]
  end
end