Permalink
Browse files

Add missing indices for Tolk tables

  • Loading branch information...
yaroslav authored and dhh committed Apr 9, 2010
1 parent 5ce64cb commit fec78d76325d018462ad096b72452638ce16a3ed
@@ -0,0 +1,13 @@
+class AddMissingIndices < ActiveRecord::Migration
+ def self.up
+ add_index :tolk_locales, :name, :unique => true
+ add_index :tolk_phrases, :key, :unique => true
+ 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
+ end
+end
View
@@ -9,20 +9,24 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20100408174805) do
+ActiveRecord::Schema.define(:version => 20100409194926) do
create_table "tolk_locales", :force => true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end
+ add_index "tolk_locales", ["name"], :name => "index_tolk_locales_on_name", :unique => true
+
create_table "tolk_phrases", :force => true do |t|
t.text "key"
t.datetime "created_at"
t.datetime "updated_at"
end
+ add_index "tolk_phrases", ["key"], :name => "index_tolk_phrases_on_key", :unique => true
+
create_table "tolk_translations", :force => true do |t|
t.integer "phrase_id"
t.integer "locale_id"
@@ -33,4 +37,6 @@
t.text "previous_text"
end
+ add_index "tolk_translations", ["phrase_id", "locale_id"], :name => "index_tolk_translations_on_phrase_id_and_locale_id", :unique => true
+
end
@@ -6,11 +6,15 @@ def self.up
t.datetime :updated_at
end
+ add_index :tolk_locales, :name, :unique => true
+
create_table :tolk_phrases do |t|
t.text :key
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
@@ -21,11 +25,16 @@ 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
drop_table :tolk_locales
end
-end
+end

0 comments on commit fec78d7

Please sign in to comment.