Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
How to migrate to Active Storage without losing your mind
Search
Colleen
May 02, 2019
Technology
0
2.2k
How to migrate to Active Storage without losing your mind
A talk on migrating from paperclip to active storage, common pitfalls, and lessons learned.
Colleen
May 02, 2019
Tweet
Share
More Decks by Colleen
See All by Colleen
Rekindling a love of creation with Ruby and the Raspberry pi
colleen711
0
190
Other Decks in Technology
See All in Technology
DMM.com アルファ室採用案内資料
hsugita
1
160
MapLibreとAmazon Location Service
dayjournal
1
160
Databricks における 『MLOps』
databricksjapan
2
170
Cypress or Playwright?
rainerhahnekamp
0
110
20240418_Google ColabにLLMが搭載されたようなのでPython x データ分析の勉強方法を考えてみる
doradora09
0
140
APIファーストなプロダクトマネジメントの実践 〜SaaSus Platformでの例〜 / "Practicing API-First Product Management - An Example with SaaSus Platform
oztick139
0
110
プロトタイピングによる不確実性の低減 / Reducing Uncertainty through Prototyping
ohbarye
5
390
今年のRubyKaigiはProfiler Year🤘
osyoyu
0
170
オーナーシップを持つ領域を明確にする
konifar
13
3.2k
Google Cloud Next '24 Recap(Cloud Run/k8s)
mokocm
0
240
Azure犬駆動開発の記録/GlobalAzureFukuoka2024_20240420
nina01
1
220
「スニダン」開発組織の構造に込めた意図 ~組織作りはパッションや政治ではない!~
rinchsan
3
570
Featured
See All Featured
Raft: Consensus for Rubyists
vanstee
132
6.3k
How GitHub (no longer) Works
holman
304
140k
10 Git Anti Patterns You Should be Aware of
lemiorhan
648
58k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
21
1.6k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
187
16k
Designing Experiences People Love
moore
136
23k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
17
1.4k
Fashionably flexible responsive web design (full day workshop)
malarkey
398
65k
Building a Modern Day E-commerce SEO Strategy
aleyda
17
6.4k
KATA
mclloyd
15
12k
The Cost Of JavaScript in 2023
addyosmani
16
3.9k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
227
16k
Transcript
Bitmapped Designs Colleen Schnettler Bitmapped Designs LLC www.bitmappeddesigns.com Bitmapped Designs
How to Migrate To Active Storage Without losing your mind
@leenyburger Bitmapped Designs www.bitmappeddesigns.com A story… Fun Startup Rails Developer
Migrate to Active Storage Start of a beautiful contract relationship!
@leenyburger Bitmapped Designs www.bitmappeddesigns.com What is Active Storage? Active Storage
is an easy way to attach files to Active Record objects and store those files in cloud based storage. S3 User Avatar
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Why Active Storage? Paperclip is deprecated
No additional migrations Built in solution for handing file uploads to cloud storage Supports: Amazon S3, Google Cloud Storage, Microsoft Azure
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Active Storage Documents Install Active Storage
Step 1: Step 4: Configure Cloud Storage Step 2: Add an attachment to a model Step 3:
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Implementing Active Storage in a new
application is EASY
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Migrating to Active Storage is hard.
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Why? Active Storage is fundamentally different
from paperclip. Paperclip works by attaching file data to the model Avatar added to User table Avatar User (Ernie)
@leenyburger Bitmapped Designs www.bitmappeddesigns.com User table schema is changed ernie-avatar.jpg
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Active Storage is different Active Storage
creates 2 new tables 1. Active Storage Attachments 2. Active Storage Blobs
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Active Storage Documents Install Active Storage
Step 1: Step 4: Configure Cloud Storage Step 2: Add an attachment to a model Step 3:
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Create Active Storage Tables
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Configure Cloud Storage
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Configure Cloud Storage
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Active Storage Documents Install Active Storage
Step 1: Step 4: Configure Cloud Storage Step 2: Move avatar data from User table to Active Storage Tables Step 3:
@leenyburger Bitmapped Designs www.bitmappeddesigns.com A rake task!
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Map attachment data FROM the Users
table TO Active Storage Tables Users Table Active Storage Attachments Active Storage Blobs
@leenyburger Bitmapped Designs www.bitmappeddesigns.com User table schema is changed ernie-avatar.jpg
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Map attachment data FROM the Users
table TO Active Storage Tables Users Table Active Storage Attachments Active Storage Blobs
But Wait?!
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Active Storage Attachments Table
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Active Storage Attachments Table
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Active Storage Attachments Table
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Active Storage BLOBS Table
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Active Storage BLOBS Table
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Active Storage BLOBS Table
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Active Storage BLOBS Table
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Table mapping
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Table mapping
@leenyburger Bitmapped Designs www.bitmappeddesigns.com A rake task!
Step 1 Reference the Paperclip “Migration" Guide
Step 2
@leenyburger Bitmapped Designs www.bitmappeddesigns.com User table schema is changed ernie-avatar.jpg
Step 2
Step 3 user
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Two deploys required!
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Two deploys? Rake task needs: 1.
user.avatar relaSonship defined by paperclip 2. AcSve storage tables
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Two deploys? AcUve Storage needs: 1.
Data in the acSve storage tables
Step 3
Key and Checksum ∑
Step 3
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Run Rake Task Records created? AcSveStorage::Blob.count
AcSveStorage::AWachment.count
What we’ve done 2. Configured AcSve Storage Cloud Storage 1.
Created the AcSve Storage Tables 3. WriWen a rake task to create User Avatar records in the AWachments and Blobs tables 4. Confirmed records were created in the AcSve Storage Tables
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Make and checkout a new branch
No really. Do it.
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Deploy Deploy with paperclip, rake task,
and active storage tables Deploy with Active Storage models/views S3 dev_bucket 1. Run rake task
Update Views, Models, Controllers and Tests Models: Views:
@leenyburger Bitmapped Designs www.bitmappeddesigns.com What are variants? No image processing!
Paperclip Active Storage
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Too early to the party? 6
To save the day!
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Deploy Deploy with paperclip, rake task,
and active storage tables Deploy with Active Storage models/views S3 dev_bucket
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Active Storage Documents Install Active Storage
Step 1: Step 4: Configure Cloud Storage Step 2: Move avatar data from User table to Active Storage Tables Step 3:
@leenyburger Bitmapped Designs www.bitmappeddesigns.com Congrats!