Merge pull request #2150 from okriuchykhin/ok_SCI_3949_v2

Rename prepared statement for experiment files migration [SCI-3949]
This commit is contained in:
Alex Kriuchykhin 2019-10-09 17:06:55 +02:00 committed by GitHub
commit e6e94d5784
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,14 +8,14 @@ class ConvertExperimentsToActiveStorage < ActiveRecord::Migration[5.2]
MODELS = [Experiment].freeze
def up
ActiveRecord::Base.connection.raw_connection.prepare('active_storage_blob_statement', <<-SQL)
ActiveRecord::Base.connection.raw_connection.prepare('active_storage_exp_blob_statement', <<-SQL)
INSERT INTO active_storage_blobs (
key, filename, content_type, metadata, byte_size, checksum, created_at
) VALUES ($1, $2, $3, '{}', $4, $5, $6)
RETURNING id;
SQL
ActiveRecord::Base.connection.raw_connection.prepare('active_storage_attachment_statement', <<-SQL)
ActiveRecord::Base.connection.raw_connection.prepare('active_storage_exp_attachment_statement', <<-SQL)
INSERT INTO active_storage_attachments (
name, record_type, record_id, blob_id, created_at
) VALUES ($1, $2, $3, $4, $5)
@ -36,7 +36,7 @@ class ConvertExperimentsToActiveStorage < ActiveRecord::Migration[5.2]
next if instance.__send__("#{attachment}_file_name").blank?
res = ActiveRecord::Base.connection.raw_connection.exec_prepared(
'active_storage_blob_statement', [
'active_storage_exp_blob_statement', [
key(instance, attachment),
instance.__send__("#{attachment}_file_name"),
instance.__send__("#{attachment}_content_type"),
@ -47,7 +47,7 @@ class ConvertExperimentsToActiveStorage < ActiveRecord::Migration[5.2]
)
ActiveRecord::Base.connection.raw_connection.exec_prepared(
'active_storage_attachment_statement', [
'active_storage_exp_attachment_statement', [
attachment,
model.name,
instance.id,