diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-01-06 14:46:51 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-01-06 14:46:51 +0000 |
commit | cc47ccb1c2a5c40cde304f1b1358c1f9ee06301b (patch) | |
tree | d68b23b967ae2f4472a442aff6c849fb2e4a249b /db | |
parent | 98c8212d71b4923e1d242c47bf30aace880927c5 (diff) | |
download | redmine-cc47ccb1c2a5c40cde304f1b1358c1f9ee06301b.tar.gz redmine-cc47ccb1c2a5c40cde304f1b1358c1f9ee06301b.zip |
Check if index exists before removing it (#12713).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11137 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/091_change_changesets_revision_to_string.rb | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/db/migrate/091_change_changesets_revision_to_string.rb b/db/migrate/091_change_changesets_revision_to_string.rb index 6e451efbb..64988069d 100644 --- a/db/migrate/091_change_changesets_revision_to_string.rb +++ b/db/migrate/091_change_changesets_revision_to_string.rb @@ -1,13 +1,32 @@ class ChangeChangesetsRevisionToString < ActiveRecord::Migration def self.up - remove_index :changesets, :name => :changesets_repos_rev + # 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 + change_column :changesets, :revision, :string, :null => false + add_index :changesets, [:repository_id, :revision], :unique => true, :name => :changesets_repos_rev end def self.down - remove_index :changesets, :name => :changesets_repos_rev + 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 + change_column :changesets, :revision, :integer, :null => false + add_index :changesets, [:repository_id, :revision], :unique => true, :name => :changesets_repos_rev end end |