You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20120422150750_change_repositories_to_full_sti.rb 664B

1234567891011121314151617
  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. def down
  10. Repository.connection.select_rows("SELECT id, type FROM #{Repository.table_name}").each do |repository_id, repository_type|
  11. if repository_type =~ /^Repository::(.+)$/
  12. Repository.update_all ["type = ?", $1], ["id = ?", repository_id]
  13. end
  14. end
  15. end
  16. end