mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Use if_not_exists
instead of table_exists?
This commit is contained in:
parent
6172f541d8
commit
8b6342e341
1 changed files with 6 additions and 8 deletions
|
@ -1,8 +1,7 @@
|
||||||
class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0]
|
class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0]
|
||||||
def change
|
def change
|
||||||
unless table_exists?(:active_storage_variant_records)
|
|
||||||
# Use Active Record's configured type for primary key
|
# Use Active Record's configured type for primary key
|
||||||
create_table :active_storage_variant_records, id: primary_key_type do |t|
|
create_table :active_storage_variant_records, id: primary_key_type, if_not_exists: true do |t|
|
||||||
t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type
|
t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type
|
||||||
t.string :variation_digest, null: false
|
t.string :variation_digest, null: false
|
||||||
|
|
||||||
|
@ -10,7 +9,6 @@ class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0]
|
||||||
t.foreign_key :active_storage_blobs, column: :blob_id
|
t.foreign_key :active_storage_blobs, column: :blob_id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
def primary_key_type
|
def primary_key_type
|
||||||
|
|
Loading…
Reference in a new issue