Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

クローラーが取得してくるデータの都合上、host_idにはユニーク制約が必要

ついでにインデックスが張られていなかった件にも対応した
  • Loading branch information...
commit 375ffe925dab9187fcec5ba40c06c376e05cb645 1 parent d259382
@yoozoosato yoozoosato authored
View
21 app/db/migrate/20120211072856_add_unique_constraint_to_host_id.rb
@@ -0,0 +1,21 @@
+class AddUniqueConstraintToHostId < ActiveRecord::Migration
+ def up
+ change_column :baseboards, :host_id, :integer, :null => false
+ change_column :bioses, :host_id, :integer, :null => false
+ change_column :processors, :host_id, :integer, :null => false
+
+ add_index :baseboards, :host_id, :unique => true
+ add_index :bioses, :host_id, :unique => true
+ add_index :processors, :host_id, :unique => true
+ end
+
+ def down
+ change_column :baseboards, :host_id, :integer, :null => true
+ change_column :bioses, :host_id, :integer, :null => true
+ change_column :processors, :host_id, :integer, :null => true
+
+ remove_index :baseboards, :host_id
+ remove_index :bioses, :host_id
+ remove_index :processors, :host_id
+ end
+end
View
14 app/db/schema.rb
@@ -11,10 +11,10 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120211055803) do
+ActiveRecord::Schema.define(:version => 20120211072856) do
create_table "baseboards", :force => true do |t|
- t.integer "host_id"
+ t.integer "host_id", :null => false
t.string "baseboard_product_name"
t.string "baseboard_serial_number"
t.string "baseboard_version"
@@ -26,8 +26,10 @@
t.datetime "updated_at", :null => false
end
+ add_index "baseboards", ["host_id"], :name => "index_baseboards_on_host_id", :unique => true
+
create_table "bioses", :force => true do |t|
- t.integer "host_id"
+ t.integer "host_id", :null => false
t.date "bios_release_date"
t.string "bios_vendor"
t.string "bios_version"
@@ -35,6 +37,8 @@
t.datetime "updated_at", :null => false
end
+ add_index "bioses", ["host_id"], :name => "index_bioses_on_host_id", :unique => true
+
create_table "hosts", :force => true do |t|
t.string "ipaddress", :null => false
t.string "name", :null => false
@@ -56,7 +60,7 @@
end
create_table "processors", :force => true do |t|
- t.integer "host_id"
+ t.integer "host_id", :null => false
t.string "processor_family"
t.string "processor_version"
t.string "processor_signature"
@@ -69,4 +73,6 @@
t.datetime "updated_at", :null => false
end
+ add_index "processors", ["host_id"], :name => "index_processors_on_host_id", :unique => true
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.