To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / db / migrate / 20120422150750_change_repositories_to_full_sti.rb @ 1298:4f746d8966dd
History | View | Annotate | Download (664 Bytes)
| 1 |
class ChangeRepositoriesToFullSti < ActiveRecord::Migration |
|---|---|
| 2 |
def up |
| 3 |
Repository.connection.select_rows("SELECT id, type FROM #{Repository.table_name}").each do |repository_id, repository_type| |
| 4 |
unless repository_type =~ /^Repository::/ |
| 5 |
Repository.update_all ["type = ?", "Repository::#{repository_type}"], ["id = ?", repository_id] |
| 6 |
end
|
| 7 |
end
|
| 8 |
end
|
| 9 |
|
| 10 |
def down |
| 11 |
Repository.connection.select_rows("SELECT id, type FROM #{Repository.table_name}").each do |repository_id, repository_type| |
| 12 |
if repository_type =~ /^Repository::(.+)$/ |
| 13 |
Repository.update_all ["type = ?", $1], ["id = ?", repository_id] |
| 14 |
end
|
| 15 |
end
|
| 16 |
end
|
| 17 |
end
|