diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2012-03-05 03:55:03 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2012-03-05 03:55:03 +0000 |
commit | ee54720556c883ca11386d54c30e4f1fb0a290d5 (patch) | |
tree | 76e87610547ac72e4d8381ba6e380e90bc61fb4e /db/migrate | |
parent | 865c2b02e5c0a5cb1c00cfd0c564bef055294c28 (diff) | |
download | redmine-ee54720556c883ca11386d54c30e4f1fb0a290d5.tar.gz redmine-ee54720556c883ca11386d54c30e4f1fb0a290d5.zip |
set svn:eol-style native db/migrate/*.rb
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9100 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'db/migrate')
-rw-r--r-- | db/migrate/20111201201315_add_unique_index_to_issue_relations.rb | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/db/migrate/20111201201315_add_unique_index_to_issue_relations.rb b/db/migrate/20111201201315_add_unique_index_to_issue_relations.rb index 2ee9adb03..c27158c13 100644 --- a/db/migrate/20111201201315_add_unique_index_to_issue_relations.rb +++ b/db/migrate/20111201201315_add_unique_index_to_issue_relations.rb @@ -1,16 +1,16 @@ -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
+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 |