Add type column to zip_exports for STI [SCI-3368]

This commit is contained in:
Oleksii Kriuchykhin 2019-05-20 16:35:24 +02:00
parent 36243ff04c
commit d3f29d5d72
4 changed files with 24 additions and 19 deletions

View file

@ -7,21 +7,6 @@ require 'csv'
class TeamZipExport < ZipExport
include StringUtility
# Override path only for S3
if ENV['PAPERCLIP_STORAGE'] == 's3'
s3_path =
if ENV['S3_SUBFOLDER']
"/#{ENV['S3_SUBFOLDER']}/zip_exports/:attachment/"\
":id_partition/:hash/:style/:filename"
else
'/zip_exports/:attachment/:id_partition/:hash/:style/:filename'
end
has_attached_file :zip_file, path: s3_path
validates_attachment :zip_file,
content_type: { content_type: 'application/zip' }
end
def generate_exportable_zip(user, data, type, options = {})
@user = user
zip_input_dir = FileUtils.mkdir_p(

View file

@ -20,7 +20,22 @@ require 'csv'
class ZipExport < ApplicationRecord
belongs_to :user, optional: true
# Override path only for S3
if ENV['PAPERCLIP_STORAGE'] == 's3'
s3_path =
if ENV['S3_SUBFOLDER']
"/#{ENV['S3_SUBFOLDER']}/zip_exports/:attachment/"\
":id_partition/:hash/:style/:filename"
else
'/zip_exports/:attachment/:id_partition/:hash/:style/:filename'
end
has_attached_file :zip_file, path: s3_path
else
has_attached_file :zip_file
end
validates_attachment :zip_file,
content_type: { content_type: 'application/zip' }

View file

@ -0,0 +1,5 @@
class AddTypeToZipExports < ActiveRecord::Migration[5.1]
def change
add_column :zip_exports, :type, :string
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20190424113216) do
ActiveRecord::Schema.define(version: 20190520135317) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -926,6 +926,7 @@ ActiveRecord::Schema.define(version: 20190424113216) do
t.string "zip_file_content_type"
t.integer "zip_file_file_size"
t.datetime "zip_file_updated_at"
t.string "type"
t.index ["user_id"], name: "index_zip_exports_on_user_id"
end
@ -1086,5 +1087,4 @@ ActiveRecord::Schema.define(version: 20190424113216) do
FROM (teams
JOIN user_teams ON ((teams.id = user_teams.team_id)));
SQL
end