Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Commit

Permalink
adding indexes to foreign keys
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanb committed Oct 19, 2008
1 parent c05ca4d commit dd1ac27
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
23 changes: 23 additions & 0 deletions db/migrate/20081019160922_add_indexes.rb
@@ -0,0 +1,23 @@
class AddIndexes < ActiveRecord::Migration
def self.up
add_index :users, :openid_url
add_index :projects, :user_id
add_index :projects, :token
add_index :color_swatches, :palette_id
add_index :activities, :user_id
%w[code_snippets palettes links notes photos screenshots activities].each do |table|
add_index table, :project_id
end
end

def self.down
remove_index :users, :openid_url
remove_index :projects, :user_id
remove_index :projects, :token
remove_index :color_swatches, :palette_id
remove_index :activities, :user_id
%w[code_snippets palettes links notes photos screenshots activities].each do |table|
remove_index table, :project_id
end
end
end
24 changes: 23 additions & 1 deletion db/schema.rb
Expand Up @@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20081018215938) do
ActiveRecord::Schema.define(:version => 20081019160922) do

create_table "activities", :force => true do |t|
t.string "message"
Expand All @@ -19,6 +19,9 @@
t.datetime "updated_at"
end

add_index "activities", ["project_id"], :name => "index_activities_on_project_id"
add_index "activities", ["user_id"], :name => "index_activities_on_user_id"

create_table "code_snippets", :force => true do |t|
t.integer "project_id"
t.string "name"
Expand All @@ -28,13 +31,17 @@
t.datetime "updated_at"
end

add_index "code_snippets", ["project_id"], :name => "index_code_snippets_on_project_id"

create_table "color_swatches", :force => true do |t|
t.integer "palette_id"
t.string "hex"
t.datetime "created_at"
t.datetime "updated_at"
end

add_index "color_swatches", ["palette_id"], :name => "index_color_swatches_on_palette_id"

create_table "links", :force => true do |t|
t.string "name"
t.integer "project_id"
Expand All @@ -44,6 +51,8 @@
t.datetime "updated_at"
end

add_index "links", ["project_id"], :name => "index_links_on_project_id"

create_table "notes", :force => true do |t|
t.string "name"
t.text "content"
Expand All @@ -52,6 +61,8 @@
t.datetime "updated_at"
end

add_index "notes", ["project_id"], :name => "index_notes_on_project_id"

create_table "open_id_authentication_associations", :force => true do |t|
t.integer "issued"
t.integer "lifetime"
Expand All @@ -74,6 +85,8 @@
t.datetime "updated_at"
end

add_index "palettes", ["project_id"], :name => "index_palettes_on_project_id"

create_table "photos", :force => true do |t|
t.string "name"
t.integer "project_id"
Expand All @@ -85,6 +98,8 @@
t.datetime "image_updated_at"
end

add_index "photos", ["project_id"], :name => "index_photos_on_project_id"

create_table "projects", :force => true do |t|
t.string "name"
t.text "description"
Expand All @@ -95,6 +110,9 @@
t.string "token"
end

add_index "projects", ["token"], :name => "index_projects_on_token"
add_index "projects", ["user_id"], :name => "index_projects_on_user_id"

create_table "screenshots", :force => true do |t|
t.string "name"
t.integer "project_id"
Expand All @@ -103,6 +121,8 @@
t.datetime "updated_at"
end

add_index "screenshots", ["project_id"], :name => "index_screenshots_on_project_id"

create_table "users", :force => true do |t|
t.string "username"
t.string "email"
Expand All @@ -113,4 +133,6 @@
t.string "openid_url"
end

add_index "users", ["openid_url"], :name => "index_users_on_openid_url"

end

0 comments on commit dd1ac27

Please sign in to comment.