Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure uploaded file paths and improve instructions for migrating to S3 #2365

Merged
merged 18 commits into from
Sep 25, 2020

Conversation

jhanggi
Copy link
Contributor

@jhanggi jhanggi commented Jul 31, 2020

Release Notes

Tech task: Update the file paths for uploaded files and improve instructions and helper rake takes to aid in migrating to S3.

Breaking changes

The setting for where uploaded files are stored locally has changed from public/files to public/system/:class. You either need to change it back to its previous value or run the rake task as part of your deployment (CHANGELOG.md).

In addition, if you are using S3 already, the path for the keys should now just be paperclip.aws_access_key and paperclip.aws_secret_access_key.

Notes

We'll need to update the access keys for NU, but their file paths in S3 already have the :class interpolation variable, so nothing should need to move for them.

paperclip:
storage: filesystem
url: ":rails_relative_url_root/:attachment/:id_partition/:style/:safe_filename"
path: ":rails_root/public/:attachment/:id_partition/:style/:safe_filename"
url: ":rails_relative_url_root/system/:class/:attachment/:id_partition/:style/:safe_filename"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could see an argument that we shouldn't change the default and just make the changes downstream, but I don't like where it's currently stored.

NU is already using the class-prefixed paths on S3.

@jhanggi jhanggi changed the title [WIP] Improve instructions and helpers for migrating to S3 Improve instructions and helpers for migrating to S3 Aug 3, 2020
@jhanggi jhanggi requested a review from giladshanan August 18, 2020 20:50
Base automatically changed from docker_updates to master August 18, 2020 21:46
@jhanggi jhanggi changed the title Improve instructions and helpers for migrating to S3 Restructure uploaded file paths and improve instructions for migrating to S3 Aug 18, 2020
@jhanggi jhanggi marked this pull request as ready for review August 21, 2020 23:07
@jhanggi jhanggi requested a review from a team as a code owner August 21, 2020 23:07
end
end
def move_record(new_class, old_record)
new_record = new_class.find(old_record.id)
Copy link
Collaborator

@giladshanan giladshanan Sep 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth adding a guard clause here to do some logging and skip any invalid old_records? I don't expect there to be any invalid records but since we're saving with validate: false I thought it might make sense to check.

Copy link
Collaborator

@giladshanan giladshanan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small non-blocking comment. Looks good! The branch just needs to be brought up to date.

@jhanggi jhanggi merged commit 655b325 into master Sep 25, 2020
@jhanggi jhanggi deleted the migrate_to_s3 branch September 25, 2020 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants