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.

091_change_changesets_revision_to_string.rb 1.4KB

1234567891011121314151617181920212223242526272829303132
  1. class ChangeChangesetsRevisionToString < ActiveRecord::Migration[4.2]
  2. def self.up
  3. # Some backends (eg. SQLServer 2012) do not support changing the type
  4. # of an indexed column so the index needs to be dropped first
  5. # BUT this index is renamed with some backends (at least SQLite3) for
  6. # some (unknown) reasons, thus we check for the other name as well
  7. # so we don't end up with 2 identical indexes
  8. if index_exists? :changesets, [:repository_id, :revision], :name => :changesets_repos_rev
  9. remove_index :changesets, :name => :changesets_repos_rev
  10. end
  11. if index_exists? :changesets, [:repository_id, :revision], :name => :altered_changesets_repos_rev
  12. remove_index :changesets, :name => :altered_changesets_repos_rev
  13. end
  14. change_column :changesets, :revision, :string, :null => false
  15. add_index :changesets, [:repository_id, :revision], :unique => true, :name => :changesets_repos_rev
  16. end
  17. def self.down
  18. if index_exists? :changesets, :changesets_repos_rev
  19. remove_index :changesets, :name => :changesets_repos_rev
  20. end
  21. if index_exists? :changesets, [:repository_id, :revision], :name => :altered_changesets_repos_rev
  22. remove_index :changesets, :name => :altered_changesets_repos_rev
  23. end
  24. change_column :changesets, :revision, :integer, :null => false
  25. add_index :changesets, [:repository_id, :revision], :unique => true, :name => :changesets_repos_rev
  26. end
  27. end