Move `migrate!` method/logic into CarrierWave and ensure data integrity
Currently, we've pulled a lot of CarrierWave classes/logic for the migrate!
method. Also, we manually update file_store
out of CarrierWave routine. This gains the complexity of the whole migration processes and risks user data by human errors.
We can contain the whole logic in CarrierWave.
In addition, we can check if the uploaded data is truly same with the source by sending checksum to OS.
Proposal
- Move
migrate!
method into CarrierWave withfile_store
updates - Enable
validates_integrity_of
validator - Send
content-md5
header when putting object to ObjectStorage (AWS/GCS) - If no ETag value returned, raise
CarrierWave::IntegrityError
and surface the error to the comsumer (i.e. GitLab-rails)
Benefit
- Mitigating the whole complexity
- Maintainable and scalable approach
- Resilient
- Tested/Reviewed by contributors and CarrierWave users