aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/db
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-08-13 13:31:37 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-08-13 13:40:39 +0900
commit4966b36d4c6850722d9526dda9110df6c5656a26 (patch)
treeaed3078981aec5d372dfb12b4966828c6493d970 /activestorage/db
parente3962308e7947f3d99c70c192e2d1356d3420e1e (diff)
downloadrails-4966b36d4c6850722d9526dda9110df6c5656a26.tar.gz
rails-4966b36d4c6850722d9526dda9110df6c5656a26.tar.bz2
rails-4966b36d4c6850722d9526dda9110df6c5656a26.zip
Use `references` to respect primary key type in active storage tables
If created active storage tables by mysql2 or postgresql adapters, a primary key is defined as a bigint. It should be used `references` to the reference columns to respect primary key type.
Diffstat (limited to 'activestorage/db')
-rw-r--r--activestorage/db/migrate/20170806125915_create_active_storage_tables.rb8
1 files changed, 3 insertions, 5 deletions
diff --git a/activestorage/db/migrate/20170806125915_create_active_storage_tables.rb b/activestorage/db/migrate/20170806125915_create_active_storage_tables.rb
index 2c7e3c5bc6..8dc000821b 100644
--- a/activestorage/db/migrate/20170806125915_create_active_storage_tables.rb
+++ b/activestorage/db/migrate/20170806125915_create_active_storage_tables.rb
@@ -13,14 +13,12 @@ class CreateActiveStorageTables < ActiveRecord::Migration[5.1]
end
create_table :active_storage_attachments do |t|
- t.string :name, null: false
- t.string :record_type, null: false
- t.integer :record_id, null: false
- t.integer :blob_id, null: false
+ t.string :name, null: false
+ t.references :record, null: false, polymorphic: true, index: false
+ t.references :blob, null: false
t.datetime :created_at, null: false
- t.index :blob_id
t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true
end
end