diff --git a/activestorage/db/update_migrate/20191206030411_create_active_storage_variant_records.rb b/activestorage/db/update_migrate/20191206030411_create_active_storage_variant_records.rb index 804ae76f6f..f4948e87a0 100644 --- a/activestorage/db/update_migrate/20191206030411_create_active_storage_variant_records.rb +++ b/activestorage/db/update_migrate/20191206030411_create_active_storage_variant_records.rb @@ -1,12 +1,14 @@ class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0] def change - # Use Active Record's configured type for primary key - create_table :active_storage_variant_records, id: primary_key_type do |t| - t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type - t.string :variation_digest, null: false + unless table_exists?(:active_storage_variant_records) + # Use Active Record's configured type for primary key + create_table :active_storage_variant_records, id: primary_key_type do |t| + 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.foreign_key :active_storage_blobs, column: :blob_id + 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 + end end end