Commit 427f1e59 authored by Micaël Bergeron's avatar Micaël Bergeron

making the migrate reversible

parent 77f06178
......@@ -12,6 +12,8 @@ class Appearance < ActiveRecord::Base
mount_uploader :logo, AttachmentUploader
mount_uploader :header_logo, AttachmentUploader
has_many :uploads, as: :model, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
CACHE_KEY = 'current_appearance'.freeze
after_commit :flush_redis_cache
......
......@@ -8,8 +8,13 @@ class AddUploaderIndexToUploads < ActiveRecord::Migration
disable_ddl_transaction!
def change
def up
remove_concurrent_index :uploads, :path
add_concurrent_index :uploads, [:uploader, :path], using: :btree
add_concurrent_index :uploads, [:uploader, :path], using: :btree
end
def down
remove_concurrent_index :uploads, [:uploader, :path]
add_concurrent_index :uploads, :path, using: :btree
end
end
......@@ -7,13 +7,9 @@ describe RecordsUploads do
storage_options Gitlab.config.uploads
storage :file
def model
FactoryBot.build_stubbed(:user)
end
end
RecordsUploadsExampleUploader.new
RecordsUploadsExampleUploader.new(build_stubbed(:user))
end
def upload_fixture(filename)
......@@ -56,7 +52,7 @@ describe RecordsUploads do
expect(upload.path).to eq uploader.upload_path
expect(upload.model_id).to eq uploader.model.id
expect(upload.model_type).to eq uploader.model.class.to_s
expect(upload.uploader).to eq uploader.class
expect(upload.uploader).to eq uploader.class.to_s
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment