Skip to content

Commit

Permalink
Condition the add missing indices migration to handle MySQL limitatio…
Browse files Browse the repository at this point in the history
…ns with TEXT/BLOB columns.
  • Loading branch information
Craig Davey committed Apr 14, 2010
1 parent 51e0a97 commit 88802ba
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion db/migrate/20100409194926_add_missing_indices.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
class AddMissingIndices < ActiveRecord::Migration
def self.up
add_index :tolk_locales, :name, :unique => true
add_index :tolk_phrases, :key, :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

Expand Down

0 comments on commit 88802ba

Please sign in to comment.