Permalink
Browse files

Dont add index for a TEXT column

  • Loading branch information...
1 parent 3b87a73 commit e0c7296bd844c391cd6037a424ab6e89e1672759 @lifo lifo committed May 8, 2010
@@ -1,13 +1,6 @@
class AddMissingIndices < ActiveRecord::Migration
def self.up
add_index :tolk_locales, :name, :unique => true
- if connection.class.name == "ActiveRecord::ConnectionAdapters::MysqlAdapter"
- # Manually create an index on the first 512 bytes because MySQL can’t
- # build an unbound index on TEXT/BLOB columns.
- execute "CREATE INDEX `index_tolk_phrases_on_key` ON `tolk_phrases` (`key`(512))"
- else
- add_index :tolk_phrases, :key, :unique => true
- end
add_index :tolk_translations, [:phrase_id, :locale_id], :unique => true
end
@@ -13,8 +13,6 @@ def self.up
t.datetime :created_at
t.datetime :updated_at
end
-
- add_index :tolk_phrases, :key, :unique => true
create_table :tolk_translations do |t|
t.integer :phrase_id
@@ -25,14 +23,15 @@ def self.up
t.datetime :created_at
t.datetime :updated_at
end
-
+
add_index :tolk_translations, [:phrase_id, :locale_id], :unique => true
end
def self.down
remove_index :tolk_translations, :column => [:phrase_id, :locale_id]
remove_index :tolk_phrases, :column => :key
remove_index :tolk_locales, :column => :name
+
drop_table :tolk_translations
drop_table :tolk_phrases
@ZenCocoon

ZenCocoon May 9, 2010

I think you might want to remove this one as well as the index is no more created.

drop_table :tolk_locales

1 comment on commit e0c7296

elzj commented on e0c7296 May 8, 2010

You might want to take the remove_index lines out for tolk_phrases too.

Please sign in to comment.