2008-03-12 23:28:49 +03:00
|
|
|
class ChangeChangesetsRevisionToString < ActiveRecord::Migration
|
|
|
|
def self.up
|
2013-01-06 18:46:51 +04:00
|
|
|
# Some backends (eg. SQLServer 2012) do not support changing the type
|
|
|
|
# of an indexed column so the index needs to be dropped first
|
|
|
|
# BUT this index is renamed with some backends (at least SQLite3) for
|
|
|
|
# some (unknown) reasons, thus we check for the other name as well
|
|
|
|
# so we don't end up with 2 identical indexes
|
|
|
|
if index_exists? :changesets, [:repository_id, :revision], :name => :changesets_repos_rev
|
|
|
|
remove_index :changesets, :name => :changesets_repos_rev
|
|
|
|
end
|
|
|
|
if index_exists? :changesets, [:repository_id, :revision], :name => :altered_changesets_repos_rev
|
|
|
|
remove_index :changesets, :name => :altered_changesets_repos_rev
|
|
|
|
end
|
|
|
|
|
2008-03-12 23:28:49 +03:00
|
|
|
change_column :changesets, :revision, :string, :null => false
|
2013-01-06 18:46:51 +04:00
|
|
|
|
2013-01-03 15:19:08 +04:00
|
|
|
add_index :changesets, [:repository_id, :revision], :unique => true, :name => :changesets_repos_rev
|
2008-03-12 23:28:49 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.down
|
2013-01-06 18:46:51 +04:00
|
|
|
if index_exists? :changesets, :changesets_repos_rev
|
|
|
|
remove_index :changesets, :name => :changesets_repos_rev
|
|
|
|
end
|
|
|
|
if index_exists? :changesets, [:repository_id, :revision], :name => :altered_changesets_repos_rev
|
|
|
|
remove_index :changesets, :name => :altered_changesets_repos_rev
|
|
|
|
end
|
|
|
|
|
2008-03-12 23:28:49 +03:00
|
|
|
change_column :changesets, :revision, :integer, :null => false
|
2013-01-06 18:46:51 +04:00
|
|
|
|
2013-01-03 15:19:08 +04:00
|
|
|
add_index :changesets, [:repository_id, :revision], :unique => true, :name => :changesets_repos_rev
|
2008-03-12 23:28:49 +03:00
|
|
|
end
|
|
|
|
end
|