diff .svn/pristine/27/27ce56818e709e285d3d63b2d5d116ba119243bf.svn-base @ 1298:4f746d8966dd redmine_2.3_integration

Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author Chris Cannam
date Fri, 14 Jun 2013 09:28:30 +0100
parents 622f24f53b42
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.svn/pristine/27/27ce56818e709e285d3d63b2d5d116ba119243bf.svn-base	Fri Jun 14 09:28:30 2013 +0100
@@ -0,0 +1,32 @@
+class ChangeChangesetsRevisionToString < ActiveRecord::Migration
+  def self.up
+    # 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
+    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