mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Update 20191206030411_create_active_storage_variant_records.rb
In the cast of bootstrapping a project for the first time without active storage, when running `rails app:update` this migration would result in trying to create the table twice.
This commit is contained in:
parent
c32234c25b
commit
6ed63abecd
1 changed files with 8 additions and 6 deletions
|
@ -1,12 +1,14 @@
|
||||||
class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0]
|
class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0]
|
||||||
def change
|
def change
|
||||||
# Use Active Record's configured type for primary key
|
unless table_exists?(:active_storage_variant_records)
|
||||||
create_table :active_storage_variant_records, id: primary_key_type do |t|
|
# Use Active Record's configured type for primary key
|
||||||
t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type
|
create_table :active_storage_variant_records, id: primary_key_type do |t|
|
||||||
t.string :variation_digest, null: false
|
t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type
|
||||||
|
t.string :variation_digest, null: false
|
||||||
|
|
||||||
t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true
|
t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true
|
||||||
t.foreign_key :active_storage_blobs, column: :blob_id
|
t.foreign_key :active_storage_blobs, column: :blob_id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue