Patch #9510 ยป r7760.patch
db/migrate/003_issue_add_note.rb | ||
---|---|---|
7 | 7 |
end |
8 | 8 | |
9 | 9 |
def self.down |
10 |
Permission.find(:first, :conditions => ["controller=? and action=?", 'issues', 'add_note']).destroy
|
|
10 |
Permission.find(:first, :conditions => ["controller = ? AND action = ?", 'issues', 'add_note']).destroy
|
|
11 | 11 |
end |
12 | 12 |
end |
db/migrate/004_export_pdf.rb | ||
---|---|---|
8 | 8 |
end |
9 | 9 | |
10 | 10 |
def self.down |
11 |
Permission.find(:first, :conditions => ["controller=? and action=?", 'projects', 'export_issues_pdf']).destroy
|
|
12 |
Permission.find(:first, :conditions => ["controller=? and action=?", 'issues', 'export_pdf']).destroy
|
|
11 |
Permission.find(:first, :conditions => ["controller = ? AND action = ?", 'projects', 'export_issues_pdf']).destroy
|
|
12 |
Permission.find(:first, :conditions => ["controller = ? AND action = ?", 'issues', 'export_pdf']).destroy
|
|
13 | 13 |
end |
14 | 14 |
end |
db/migrate/006_calendar_and_activity.rb | ||
---|---|---|
9 | 9 |
end |
10 | 10 | |
11 | 11 |
def self.down |
12 |
Permission.find(:first, :conditions => ["controller=? and action=?", 'projects', 'activity']).destroy
|
|
13 |
Permission.find(:first, :conditions => ["controller=? and action=?", 'projects', 'calendar']).destroy
|
|
14 |
Permission.find(:first, :conditions => ["controller=? and action=?", 'projects', 'gantt']).destroy
|
|
12 |
Permission.find(:first, :conditions => ["controller = ? AND action = ?", 'projects', 'activity']).destroy
|
|
13 |
Permission.find(:first, :conditions => ["controller = ? AND action = ?", 'projects', 'calendar']).destroy
|
|
14 |
Permission.find(:first, :conditions => ["controller = ? AND action = ?", 'projects', 'gantt']).destroy
|
|
15 | 15 |
end |
16 | 16 |
end |
db/migrate/007_create_journals.rb | ||
---|---|---|
13 | 13 |
t.column "notes", :text |
14 | 14 |
t.column "created_on", :datetime, :null => false |
15 | 15 |
end |
16 | ||
16 | 17 |
create_table :journal_details, :force => true do |t| |
17 | 18 |
t.column "journal_id", :integer, :default => 0, :null => false |
18 | 19 |
t.column "property", :string, :limit => 30, :default => "", :null => false |
... | ... | |
28 | 29 |
Permission.create :controller => "issues", :action => "history", :description => "label_history", :sort => 1006, :is_public => true, :mail_option => 0, :mail_enabled => 0 |
29 | 30 | |
30 | 31 |
# data migration |
31 |
IssueHistory.find(:all, :include => :issue).each {|h|
|
|
32 |
IssueHistory.find(:all, :include => :issue).each do |h|
|
|
32 | 33 |
j = Journal.new(:journalized => h.issue, :user_id => h.author_id, :notes => h.notes, :created_on => h.created_on) |
33 | 34 |
j.details << JournalDetail.new(:property => 'attr', :prop_key => 'status_id', :value => h.status_id) |
34 | 35 |
j.save |
... | ... | |
32 | 33 |
j = Journal.new(:journalized => h.issue, :user_id => h.author_id, :notes => h.notes, :created_on => h.created_on) |
33 | 34 |
j.details << JournalDetail.new(:property => 'attr', :prop_key => 'status_id', :value => h.status_id) |
34 | 35 |
j.save |
35 |
}
|
|
36 |
end
|
|
36 | 37 | |
37 | 38 |
drop_table :issue_histories |
38 | 39 |
end |
... | ... | |
51 | 52 | |
52 | 53 |
add_index "issue_histories", ["issue_id"], :name => "issue_histories_issue_id" |
53 | 54 | |
54 |
Permission.find(:first, :conditions => ["controller=? and action=?", 'issues', 'history']).destroy
|
|
55 |
Permission.find(:first, :conditions => ["controller = ? AND action = ?", 'issues', 'history']).destroy
|
|
55 | 56 |
end |
56 | 57 |
end |
db/migrate/012_add_comments_permissions.rb | ||
---|---|---|
8 | 8 |
end |
9 | 9 | |
10 | 10 |
def self.down |
11 |
Permission.find(:first, :conditions => ["controller=? and action=?", 'news', 'add_comment']).destroy
|
|
12 |
Permission.find(:first, :conditions => ["controller=? and action=?", 'news', 'destroy_comment']).destroy
|
|
11 |
Permission.find(:first, :conditions => ["controller = ? AND action = ?", 'news', 'add_comment']).destroy
|
|
12 |
Permission.find(:first, :conditions => ["controller = ? AND action = ?", 'news', 'destroy_comment']).destroy
|
|
13 | 13 |
end |
14 | 14 |
end |
db/migrate/014_add_queries_permissions.rb | ||
---|---|---|
7 | 7 |
end |
8 | 8 | |
9 | 9 |
def self.down |
10 |
Permission.find(:first, :conditions => ["controller=? and action=?", 'projects', 'add_query']).destroy
|
|
10 |
Permission.find(:first, :conditions => ["controller = ? AND action = ?", 'projects', 'add_query']).destroy
|
|
11 | 11 |
end |
12 | 12 |
end |
db/migrate/016_add_repositories_permissions.rb | ||
---|---|---|
12 | 12 |
end |
13 | 13 | |
14 | 14 |
def self.down |
15 |
Permission.find(:first, :conditions => ["controller=? and action=?", 'repositories', 'show']).destroy
|
|
16 |
Permission.find(:first, :conditions => ["controller=? and action=?", 'repositories', 'browse']).destroy
|
|
17 |
Permission.find(:first, :conditions => ["controller=? and action=?", 'repositories', 'entry']).destroy
|
|
18 |
Permission.find(:first, :conditions => ["controller=? and action=?", 'repositories', 'revisions']).destroy
|
|
19 |
Permission.find(:first, :conditions => ["controller=? and action=?", 'repositories', 'revision']).destroy
|
|
20 |
Permission.find(:first, :conditions => ["controller=? and action=?", 'repositories', 'diff']).destroy
|
|
15 |
Permission.find(:first, :conditions => ["controller = ? AND action = ?", 'repositories', 'show']).destroy
|
|
16 |
Permission.find(:first, :conditions => ["controller = ? AND action = ?", 'repositories', 'browse']).destroy
|
|
17 |
Permission.find(:first, :conditions => ["controller = ? AND action = ?", 'repositories', 'entry']).destroy
|
|
18 |
Permission.find(:first, :conditions => ["controller = ? AND action = ?", 'repositories', 'revisions']).destroy
|
|
19 |
Permission.find(:first, :conditions => ["controller = ? AND action = ?", 'repositories', 'revision']).destroy
|
|
20 |
Permission.find(:first, :conditions => ["controller = ? and action = ?", 'repositories', 'diff']).destroy
|
|
21 | 21 |
end |
22 | 22 |
end |
db/migrate/019_add_issue_status_position.rb | ||
---|---|---|
1 | 1 |
class AddIssueStatusPosition < ActiveRecord::Migration |
2 | 2 |
def self.up |
3 | 3 |
add_column :issue_statuses, :position, :integer, :default => 1 |
4 |
IssueStatus.find(:all).each_with_index {|status, i| status.update_attribute(:position, i+1)}
|
|
4 |
IssueStatus.find(:all).each_with_index { |status, i| status.update_attribute(:position, i + 1) }
|
|
5 | 5 |
end |
6 | 6 | |
7 | 7 |
def self.down |
db/migrate/020_add_role_position.rb | ||
---|---|---|
1 | 1 |
class AddRolePosition < ActiveRecord::Migration |
2 | 2 |
def self.up |
3 | 3 |
add_column :roles, :position, :integer, :default => 1 |
4 |
Role.find(:all).each_with_index {|role, i| role.update_attribute(:position, i+1)}
|
|
4 |
Role.find(:all).each_with_index { |role, i| role.update_attribute(:position, i + 1) }
|
|
5 | 5 |
end |
6 | 6 | |
7 | 7 |
def self.down |
db/migrate/021_add_tracker_position.rb | ||
---|---|---|
1 | 1 |
class AddTrackerPosition < ActiveRecord::Migration |
2 | 2 |
def self.up |
3 | 3 |
add_column :trackers, :position, :integer, :default => 1 |
4 |
Tracker.find(:all).each_with_index {|tracker, i| tracker.update_attribute(:position, i+1)}
|
|
4 |
Tracker.find(:all).each_with_index { |tracker, i| tracker.update_attribute(:position, i + 1) }
|
|
5 | 5 |
end |
6 | 6 | |
7 | 7 |
def self.down |
db/migrate/024_add_roadmap_permission.rb | ||
---|---|---|
7 | 7 |
end |
8 | 8 | |
9 | 9 |
def self.down |
10 |
Permission.find(:first, :conditions => ["controller=? and action=?", 'projects', 'roadmap']).destroy
|
|
10 |
Permission.find(:first, :conditions => ["controller = ? AND action = ?", 'projects', 'roadmap']).destroy
|
|
11 | 11 |
end |
12 | 12 |
end |
db/migrate/041_rename_comment_to_comments.rb | ||
---|---|---|
1 | 1 |
class RenameCommentToComments < ActiveRecord::Migration |
2 | 2 |
def self.up |
3 |
rename_column(:comments, :comment, :comments) if ActiveRecord::Base.connection.columns(Comment.table_name).detect{|c| c.name == "comment"}
|
|
4 |
rename_column(:wiki_contents, :comment, :comments) if ActiveRecord::Base.connection.columns(WikiContent.table_name).detect{|c| c.name == "comment"}
|
|
5 |
rename_column(:wiki_content_versions, :comment, :comments) if ActiveRecord::Base.connection.columns(WikiContent.versioned_table_name).detect{|c| c.name == "comment"}
|
|
6 |
rename_column(:time_entries, :comment, :comments) if ActiveRecord::Base.connection.columns(TimeEntry.table_name).detect{|c| c.name == "comment"}
|
|
7 |
rename_column(:changesets, :comment, :comments) if ActiveRecord::Base.connection.columns(Changeset.table_name).detect{|c| c.name == "comment"}
|
|
3 |
rename_column(:comments, :comment, :comments) if ActiveRecord::Base.connection.columns(Comment.table_name).detect{ |c| c.name == "comment" }
|
|
4 |
rename_column(:wiki_contents, :comment, :comments) if ActiveRecord::Base.connection.columns(WikiContent.table_name).detect{ |c| c.name == "comment" }
|
|
5 |
rename_column(:wiki_content_versions, :comment, :comments) if ActiveRecord::Base.connection.columns(WikiContent.versioned_table_name).detect{ |c| c.name == "comment" }
|
|
6 |
rename_column(:time_entries, :comment, :comments) if ActiveRecord::Base.connection.columns(TimeEntry.table_name).detect{ |c| c.name == "comment" }
|
|
7 |
rename_column(:changesets, :comment, :comments) if ActiveRecord::Base.connection.columns(Changeset.table_name).detect{ |c| c.name == "comment" }
|
|
8 | 8 |
end |
9 | 9 | |
10 | 10 |
def self.down |
db/migrate/078_add_custom_fields_position.rb | ||
---|---|---|
1 | 1 |
class AddCustomFieldsPosition < ActiveRecord::Migration |
2 | 2 |
def self.up |
3 | 3 |
add_column(:custom_fields, :position, :integer, :default => 1) |
4 |
CustomField.find(:all).group_by(&:type).each do |t, fields|
|
|
4 |
CustomField.find(:all).group_by(&:type).each do |t, fields| |
|
5 | 5 |
fields.each_with_index do |field, i| |
6 | 6 |
# do not call model callbacks |
... | ... | |
5 | 5 |
fields.each_with_index do |field, i| |
6 | 6 |
# do not call model callbacks |
7 |
CustomField.update_all "position = #{i+1}", {:id => field.id}
|
|
7 |
CustomField.update_all "position = #{i + 1}", { :id => field.id }
|
|
8 | 8 |
end |
9 | 9 |
end |
10 | 10 |
end |
db/migrate/20101104182107_add_unique_index_on_members.rb | ||
---|---|---|
3 | 3 |
# Clean and reassign MemberRole rows if needed |
4 | 4 |
MemberRole.delete_all("member_id NOT IN (SELECT id FROM #{Member.table_name})") |
5 | 5 |
MemberRole.update_all("member_id =" + |
6 |
" (SELECT min(m2.id) FROM #{Member.table_name} m1, #{Member.table_name} m2" +
|
|
6 |
" (SELECT MIN(m2.id) FROM #{Member.table_name} m1, #{Member.table_name} m2" +
|
|
7 | 7 |
" WHERE m1.user_id = m2.user_id AND m1.project_id = m2.project_id" + |
8 | 8 |
" AND m1.id = #{MemberRole.table_name}.member_id)") |
9 | 9 |
# Remove duplicates |
10 | 10 |
Member.connection.select_values("SELECT m.id FROM #{Member.table_name} m" + |
... | ... | |
7 | 7 |
" WHERE m1.user_id = m2.user_id AND m1.project_id = m2.project_id" + |
8 | 8 |
" AND m1.id = #{MemberRole.table_name}.member_id)") |
9 | 9 |
# Remove duplicates |
10 | 10 |
Member.connection.select_values("SELECT m.id FROM #{Member.table_name} m" + |
11 |
" WHERE m.id > (SELECT min(m1.id) FROM #{Member.table_name} m1 WHERE m1.user_id = m.user_id AND m1.project_id = m.project_id)").each do |i|
|
|
11 |
" WHERE m.id > (SELECT MIN(m1.id) FROM #{Member.table_name} m1 WHERE m1.user_id = m.user_id AND m1.project_id = m.project_id)").each do |i|
|
|
12 | 12 |
Member.delete_all(["id = ?", i]) |
13 | 13 |
end |
14 | 14 |
db/migrate/20110223180953_salt_user_passwords.rb | ||
---|---|---|
1 | 1 |
class SaltUserPasswords < ActiveRecord::Migration |
2 |
|
|
3 | 2 |
def self.up |
4 | 3 |
say_with_time "Salting user passwords, this may take some time..." do |
5 | 4 |
User.salt_unsalted_passwords! |
db/migrate/20110228000100_copy_repositories_log_encoding.rb | ||
---|---|---|
5 | 5 |
Repository.find(:all).each do |repo| |
6 | 6 |
scm = repo.scm_name |
7 | 7 |
case scm |
8 |
when 'Subversion', 'Mercurial', 'Git', 'Filesystem'
|
|
9 |
repo.update_attribute(:log_encoding, nil)
|
|
10 |
else
|
|
11 |
repo.update_attribute(:log_encoding, encoding)
|
|
8 |
when 'Subversion', 'Mercurial', 'Git', 'Filesystem'
|
|
9 |
repo.update_attribute(:log_encoding, nil) |
|
10 |
else |
|
11 |
repo.update_attribute(:log_encoding, encoding) |
|
12 | 12 |
end |
13 | 13 |
end |
14 | 14 |
end |