@@ -1,17 +1,22 | |||
|
1 | 1 | class ChangeRepositoriesToFullSti < ActiveRecord::Migration |
|
2 | 2 | def up |
|
3 | Repository.connection.select_rows("SELECT id, type FROM #{Repository.table_name}").each do |repository_id, repository_type| | |
|
3 | Repository.connection. | |
|
4 | select_rows("SELECT id, type FROM #{Repository.table_name}"). | |
|
5 | each do |repository_id, repository_type| | |
|
4 | 6 | unless repository_type =~ /^Repository::/ |
|
5 |
Repository. |
|
|
7 | Repository.where(["id = ?", repository_id]). | |
|
8 | update_all(["type = ?", "Repository::#{repository_type}"]) | |
|
6 | 9 | end |
|
7 | 10 | end |
|
8 | 11 | end |
|
9 | 12 | |
|
10 | 13 | def down |
|
11 | Repository.connection.select_rows("SELECT id, type FROM #{Repository.table_name}").each do |repository_id, repository_type| | |
|
14 | Repository.connection. | |
|
15 | select_rows("SELECT id, type FROM #{Repository.table_name}"). | |
|
16 | each do |repository_id, repository_type| | |
|
12 | 17 | if repository_type =~ /^Repository::(.+)$/ |
|
13 |
Repository.update_all |
|
|
18 | Repository.where(["id = ?", repository_id]).update_all(["type = ?", $1]) | |
|
14 | 19 | end |
|
15 | 20 | end |
|
16 | 21 | end |
|
17 | 22 | end |
General Comments 0
You need to be logged in to leave comments.
Login now