From 69c8231b49a8179697070d528d36811dc2f335e6 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 19 Dec 2012 12:08:27 +0200 Subject: [PATCH] index for commit_id. Schema rebuiled. Non rollback migration exception added --- ...64840_move_noteable_commit_to_own_field.rb | 3 +-- .../20121219095402_indices_for_notes.rb | 6 +++++ db/schema.rb | 24 ++++++++++--------- 3 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 db/migrate/20121219095402_indices_for_notes.rb diff --git a/db/migrate/20121218164840_move_noteable_commit_to_own_field.rb b/db/migrate/20121218164840_move_noteable_commit_to_own_field.rb index 59faabba093d..6f2da4136a3c 100644 --- a/db/migrate/20121218164840_move_noteable_commit_to_own_field.rb +++ b/db/migrate/20121218164840_move_noteable_commit_to_own_field.rb @@ -15,7 +15,6 @@ def up end def down - remove_column :notes, :commit_id - remove_column :notes, :new_noteable_id + raise ActiveRecord::IrreversibleMigration end end diff --git a/db/migrate/20121219095402_indices_for_notes.rb b/db/migrate/20121219095402_indices_for_notes.rb new file mode 100644 index 000000000000..4c5d041ce815 --- /dev/null +++ b/db/migrate/20121219095402_indices_for_notes.rb @@ -0,0 +1,6 @@ +class IndicesForNotes < ActiveRecord::Migration + def change + add_index :notes, :commit_id + add_index :notes, [:project_id, :noteable_type] + end +end diff --git a/db/schema.rb b/db/schema.rb index e4a1ec4da976..7de5593285a5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20121218164840) do +ActiveRecord::Schema.define(:version => 20121219095402) do create_table "events", :force => true do |t| t.string "target_type" @@ -69,19 +69,19 @@ add_index "keys", ["user_id"], :name => "index_keys_on_user_id" create_table "merge_requests", :force => true do |t| - t.string "target_branch", :null => false - t.string "source_branch", :null => false - t.integer "project_id", :null => false + t.string "target_branch", :null => false + t.string "source_branch", :null => false + t.integer "project_id", :null => false t.integer "author_id" t.integer "assignee_id" t.string "title" - t.boolean "closed", :default => false, :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.text "st_commits" - t.text "st_diffs" - t.boolean "merged", :default => false, :null => false - t.integer "state", :default => 1, :null => false + t.boolean "closed", :default => false, :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.text "st_commits", :limit => 2147483647 + t.text "st_diffs", :limit => 2147483647 + t.boolean "merged", :default => false, :null => false + t.integer "state", :default => 1, :null => false t.integer "milestone_id" end @@ -135,8 +135,10 @@ t.integer "noteable_id" end + add_index "notes", ["commit_id"], :name => "index_notes_on_commit_id" add_index "notes", ["created_at"], :name => "index_notes_on_created_at" add_index "notes", ["noteable_type"], :name => "index_notes_on_noteable_type" + add_index "notes", ["project_id", "noteable_type"], :name => "index_notes_on_project_id_and_noteable_type" add_index "notes", ["project_id"], :name => "index_notes_on_project_id" create_table "projects", :force => true do |t|