1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #16258 from mattwarrenrnp/master

adding indexes on tables in migration scripts [ci skip]
This commit is contained in:
Yves Senn 2014-07-25 11:26:04 +02:00
commit 38c2fec014

View file

@ -105,7 +105,7 @@ class CreateOrders < ActiveRecord::Migration
end
create_table :orders do |t|
t.belongs_to :customer
t.belongs_to :customer, index: true
t.datetime :order_date
t.timestamps
end
@ -136,7 +136,7 @@ class CreateSuppliers < ActiveRecord::Migration
end
create_table :accounts do |t|
t.belongs_to :supplier
t.belongs_to :supplier, index: true
t.string :account_number
t.timestamps
end
@ -169,7 +169,7 @@ class CreateCustomers < ActiveRecord::Migration
end
create_table :orders do |t|
t.belongs_to :customer
t.belongs_to :customer, index:true
t.datetime :order_date
t.timestamps
end
@ -216,8 +216,8 @@ class CreateAppointments < ActiveRecord::Migration
end
create_table :appointments do |t|
t.belongs_to :physician
t.belongs_to :patient
t.belongs_to :physician, index: true
t.belongs_to :patient, index: true
t.datetime :appointment_date
t.timestamps
end
@ -295,13 +295,13 @@ class CreateAccountHistories < ActiveRecord::Migration
end
create_table :accounts do |t|
t.belongs_to :supplier
t.belongs_to :supplier, index: true
t.string :account_number
t.timestamps
end
create_table :account_histories do |t|
t.belongs_to :account
t.belongs_to :account, index: true
t.integer :credit_rating
t.timestamps
end
@ -341,8 +341,8 @@ class CreateAssembliesAndParts < ActiveRecord::Migration
end
create_table :assemblies_parts, id: false do |t|
t.belongs_to :assembly
t.belongs_to :part
t.belongs_to :assembly, index: true
t.belongs_to :part, index: true
end
end
end
@ -379,6 +379,8 @@ class CreateSuppliers < ActiveRecord::Migration
t.string :account_number
t.timestamps
end
add_index :accounts, :supplier_id
end
end
```
@ -455,6 +457,8 @@ class CreatePictures < ActiveRecord::Migration
t.string :imageable_type
t.timestamps
end
add_index :pictures, :imageable_id
end
end
```
@ -466,7 +470,7 @@ class CreatePictures < ActiveRecord::Migration
def change
create_table :pictures do |t|
t.string :name
t.references :imageable, polymorphic: true
t.references :imageable, polymorphic: true, index: true
t.timestamps
end
end
@ -496,7 +500,7 @@ In your migrations/schema, you will add a references column to the model itself.
class CreateEmployees < ActiveRecord::Migration
def change
create_table :employees do |t|
t.references :manager
t.references :manager, index: true
t.timestamps
end
end
@ -561,6 +565,8 @@ class CreateOrders < ActiveRecord::Migration
t.string :order_number
t.integer :customer_id
end
add_index :orders, :customer_id
end
end
```
@ -594,6 +600,9 @@ class CreateAssembliesPartsJoinTable < ActiveRecord::Migration
t.integer :assembly_id
t.integer :part_id
end
add_index :assemblies_parts, :assembly_id
add_index :assemblies_parts, :part_id
end
end
```