Commit 8914d5ed494ef209b724e142a404920a43cc6e8f

Authored by Vasiliy Ermolovich
1 parent 3a92292d
Exists in master and in 1 other branch production

use ruby hash rockets in migrations

closes #235
db/migrate/20120530005915_rename_klass_to_error_class.rb
1 class RenameKlassToErrorClass < Mongoid::Migration 1 class RenameKlassToErrorClass < Mongoid::Migration
2 def self.up 2 def self.up
3 [Problem, Err, Notice].each do |model| 3 [Problem, Err, Notice].each do |model|
4 - model.collection.update({}, {'$rename' => {'klass' => 'error_class'}}, multi: true, safe: true) 4 + model.collection.update({}, {'$rename' => {'klass' => 'error_class'}}, :multi => true, :safe => true)
5 end 5 end
6 end 6 end
7 7
8 def self.down 8 def self.down
9 [Problem, Err, Notice].each do |model| 9 [Problem, Err, Notice].each do |model|
10 - model.collection.update({}, {'$rename' => {'error_class' => 'klass'}}, multi: true, safe: true) 10 + model.collection.update({}, {'$rename' => {'error_class' => 'klass'}}, :multi => true, :safe => true)
11 end 11 end
12 end 12 end
13 end 13 end
db/migrate/20120603112130_change_github_url_to_github_repo.rb
1 class ChangeGithubUrlToGithubRepo < Mongoid::Migration 1 class ChangeGithubUrlToGithubRepo < Mongoid::Migration
2 def self.up 2 def self.up
3 - App.collection.update({}, {'$rename' => {'github_url' => 'github_repo'}}, multi: true, safe: true) 3 + App.collection.update({}, {'$rename' => {'github_url' => 'github_repo'}}, :multi => true, :safe => true)
4 App.all.each do |app| 4 App.all.each do |app|
5 app.send :normalize_github_repo 5 app.send :normalize_github_repo
6 app.save 6 app.save
@@ -8,7 +8,7 @@ class ChangeGithubUrlToGithubRepo &lt; Mongoid::Migration @@ -8,7 +8,7 @@ class ChangeGithubUrlToGithubRepo &lt; Mongoid::Migration
8 end 8 end
9 9
10 def self.down 10 def self.down
11 - App.collection.update({}, {'$rename' => {'github_repo' => 'github_url'}}, multi: true, safe: true) 11 + App.collection.update({}, {'$rename' => {'github_repo' => 'github_url'}}, :multi => true, :safe => true)
12 App.all.each do |app| 12 App.all.each do |app|
13 unless app.github_repo.include?("github.com") 13 unless app.github_repo.include?("github.com")
14 app.update_attribute :github_url, "https://github.com/" << app.github_url 14 app.update_attribute :github_url, "https://github.com/" << app.github_url