2012-04-25 21:17:49 +04:00
|
|
|
class ChangeRepositoriesToFullSti < ActiveRecord::Migration
|
|
|
|
def up
|
2014-01-17 05:41:06 +04:00
|
|
|
Repository.connection.
|
|
|
|
select_rows("SELECT id, type FROM #{Repository.table_name}").
|
|
|
|
each do |repository_id, repository_type|
|
2012-04-25 21:17:49 +04:00
|
|
|
unless repository_type =~ /^Repository::/
|
2014-01-17 05:41:06 +04:00
|
|
|
Repository.where(["id = ?", repository_id]).
|
|
|
|
update_all(["type = ?", "Repository::#{repository_type}"])
|
2012-04-25 21:17:49 +04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
2014-01-17 05:41:06 +04:00
|
|
|
Repository.connection.
|
|
|
|
select_rows("SELECT id, type FROM #{Repository.table_name}").
|
|
|
|
each do |repository_id, repository_type|
|
2012-04-25 21:17:49 +04:00
|
|
|
if repository_type =~ /^Repository::(.+)$/
|
2014-01-17 05:41:06 +04:00
|
|
|
Repository.where(["id = ?", repository_id]).update_all(["type = ?", $1])
|
2012-04-25 21:17:49 +04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|