Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Thinking about Rails upgrading
Search
y-yagi
July 20, 2017
Technology
120
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Thinking about Rails upgrading
y-yagi
July 20, 2017
More Decks by y-yagi
See All by y-yagi
Rails 6.0 part 2
yyagi
0
3.7k
Rails 6.0 part 1
yyagi
0
3.7k
About mruby
yyagi
1
140
Rails 5.2(part1)
yyagi
1
1.7k
Rails 5.2(part2)
yyagi
0
1.8k
Ruby 2.5 on Rails 5.2
yyagi
0
150
Railsコントリビューション
yyagi
0
270
Let's Hanami
yyagi
1
730
Here Comes a Rails 5.1
yyagi
1
1.8k
Other Decks in Technology
See All in Technology
AgentCore Runtime上にAgentic Coding基盤を構築・展開する際の設計ポイントと限界点 / Design considerations and limitations when building an agentic coding platform on AgentCore Runtime
har1101
7
820
Amazon Bedrock Agents ClassicからAmazon Bedrock AgentCoreへ移行した際、ガードレール設定が2箇所に割れた話
matsunobu
0
160
Mastering Agentic Development: Harness Engineering for Effective Coding Agents
konippi
3
630
Lambda MicroVMsは常駐サーバーの代わりに なるか? Kiro Crew を動かして検証してみた / Kiro Crew on Lambda MicroVMs
k_adachi_01
2
340
あなたの知らないAmazon VPC Route Server/Amazon VPC Route Server you don't know about
masakiokuda
0
140
Azure Copilot Resiliency Agentをいろいろ試してみる
tomokusaba
0
130
CI/CDではもう遅い - 人とAIが迂回しないDevSecOps Verify基盤の再設計 -
kintotechdev
1
400
TiDBファミリーにDWHが新登場!! TiDB最新情報 / TiDB update 202609
yoshiakiyamasaki
0
150
プラットフォームを「作る」、 チームに「入り込む」
sansantech
PRO
0
360
ログラスのマルチプロダクトを 支える認証基盤 〜テナントごとに異なる統制とどう向き合うか〜
dada4386
2
190
AI臭い文章とは何なのか
nasuvitz
36
72k
ボードゲームの遊び相手をFoundation Modelsで作る / iOSDC Japan 2026
genda
0
220
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
41
2.7k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Test your architecture with Archunit
thirion
2
2.4k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
290
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
690
The Spectacular Lies of Maps
axbom
PRO
1
1k
Designing Experiences People Love
moore
143
24k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
370
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
510
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6.2k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.7k
The Language of Interfaces
destraynor
162
27k
Transcript
Thinking about Rails upgrading @y-yagi
About • Rails upgradingを行う際にやっていること・考えている事をまとめ た資料です • あくまで個人の感想です
Upgrading Flow 1. Bundle update Rails 2. Run test 3.
Update config 4. Run test again 5. Fix deprecate message 6. Finally run the test again
Upgrading Flow 1. Bundle update Rails 2. Run test 3.
Update config 4. Run test again 5. Fix deprecate message 6. Finally run the test again
Bundle update Rails • 何はともあれまずは “bundle update rails” • しかし依存しているgemでrailsのバージョンロックが入っている事
が多く、まずここで時間がかかる • 片っ端から更新のPRを送る ◦ が、その前に、そもそもそのgem本当に必要か再度考える
Bundle update Rails • そのgem本当に必要ですか? • インストールした際は必要だったとしても、その後要件が変わった りして実は不要になったgemが残ってるかもしれない • 便利かと思っていれてみたが、実はそんなに便利ではなかった(要
件が合わなかった)gemが残ってるかもしれない • Rails本体で同じ機能が提供された事により、不要になった可能性 もある(e.g. quiet_assets)
Let's clean the Gemfile
Bundle update Rails • Railsのアップグレードの際にgemの掃除も行う ◦ 実際のPRアップグレードのPRとは別で投げたりする • Railsのアップグレードで辛い事の多くはgemの更新(個人の感想) なので、今後の事も考えて負担を減らしていく
• 見直しをした結果、本当に必要なgemにだけ更新のPRを送る ◦ それでも多いかもしれないが、そこは頑張る
Bundle update Rails • よく使われているgemであれば、既に誰かがPRを送っている可能 性が高い • 逆にいうと、Railsが正式リリースされても対応のPRが無い・PRが あっても放置されているようなgemは、メンテされてない・使われて いない可能性が高いので、今後の利用を考えた方が良い
Upgrading Flow 1. Bundle update Rails 2. Run test 3.
Update config 4. Run test again 5. Fix deprecate message 6. Finally run the test again
Run test • 最初のテスト実行 • ここで落ちる場合、Railsのバグを踏んだ、private APIを使用してい てそれが壊れた、gemが壊れた、等々色々な要因がありえる • ここは頑張って一つずつ対応していくしか無い
• そもそもテストが無いプロジェクトは、色々頑張っていきましょう
public API / private API • Railsはpublic API(ユーザが使用して良いAPI)とprivate API(ユー ザが使用してはいけないAPI)が明確にわかれている
• public APIはRails API doc にのっているAPI、それ以外は基本 private API • 例えばActive Recordではwhereはpublic APIだが、where!は private API ◦ なのでwhere!は使っては駄目ですよ ◦ Arelも同様
public API / private API • public APIは一つのバージョンアップ(major, minor問わず)で挙動 が変わる事は無い
◦ public APIについては、必ず既存の挙動をdeprecationにしてから変えるようにして る ◦ 一部例外あり
public API / private API • どうしても挙動が変わってしまうAPIについては、A Guide for Upgrading
Ruby on Rails に載る(はず) • それ以外のpublic APIの挙動が変わっていたらそれはバグなの で、issueで報告する
public API / private API • private APIを多用している場合のアップグレードは大変 ◦ そもそもメソッドが無くなっている場合もあったりで、気付くのが大変
• Railsの機能を拡張するgemでprivate APIを使うのは仕方無いが、 普通のRailsアプリではprivate APIを使用しなくてもどうにかなるは ず
public API / private API • どうしてもprivate APIが必要な場合は、その部分だけ切り出して gemにする、他のファイルと混ぜない(モンキーパッチである事が明 確にわかる管理にする)ようにきをつける
• または、private APIをpublic APIにするようRails側にPRを送る ◦ 一旦public APIに出来ればこっちのもん • 最大限private APIがアプリ内で使われるのを避けるようにする
Upgrading Flow 1. Bundle update Rails 2. Run test 3.
Update config 4. Run test again 5. Fix deprecate message 6. Finally run the test again
Update config • テストが通ったら、新しいconfigを適用していく • 新しいconfigについては RailsDiff を見る、手元で元のオプションと 同じオプションを指定してrails newして既存のアプリとのdiffを
とる、等をして確認すると良いと思います
Update config • app:updateは使ってない • app:updateは色々と問題がある(rails newで指定したオプ ションを考慮しない、configのappendが出来ない等) ◦ 多少直したい気持ちはある
◦ Do not generate unused components contents in app:update task
Update config • Rails 5.1以降であれば load_defaults を使えば勝手に Railsオススメのconfigが設定されるので使用する事のオス スメ
Upgrading Flow 1. Bundle update Rails 2. Run test 3.
Update config 4. Run test again 5. Fix deprecate message 6. Finally run the test again
Run test again • 再度テスト実行 • ここエラーになる事はそんなに多くないはず
Upgrading Flow 1. Bundle update Rails 2. Run test 3.
Update config 4. Run test again 5. Fix deprecate message 6. Finally run the test again
Fix deprecate message • deprecateメッセージを片っ端から潰していく • deprecateメッセージに代わりに使うべきメソッド・configが含まれて いる筈なので、基本的にはそれに従う ◦ "without
replacement"なケースもあるが、それで本当に困る事は滅多に無い筈
Fix deprecate message • 対応が広範囲に渡る修正は別PRにする、バックポートしても問題 無い対応は別PRにして古いコードに入れる、等を行う • アップグレードのPRが大きくなり過ぎないよう気をつける ◦ 無理に一つのPRに全部を入れない
• また、既存のコードを壊す可能性がある対応も別PRにする(DB周 りは特に)
Fix deprecate message • Railsのバージョンがrcの場合は少し様子を見る事もある ◦ rcリリース後にdeprecateだったのがdeprecateじゃなくなるケースもたまにあるので ◦ e.g. Remove
implicit coercion deprecation of durations ◦ DHHぱわー(真っ当な意見が多い)
Upgrading Flow 1. Bundle update Rails 2. Run test 3.
Update config 4. Run test again 5. Fix deprecate message 6. Finally run the test again
Finally run the test again • 最後のテスト実行 • ここエラーになるケースはそんなに多くない筈
Finish 後は震えながら本番にリリースするだけ
After release • エラーが置きないか気にするのは当然として、性能劣化もチェック する • 出来ればリリース前にチェック出来ると良い、 • 性能確認する環境が無い場合はリリース後注視する
After release • 性能劣化はちょいちょいおきる • 最近だと ◦ Upgrading from Rails
5.0.0.1 to 5.0.1 increases import from... ◦ 5.0.0 -> 5.0.1 mysql foreign_keys is crazy slow
After release • Rails側でパフォーマンスチェックの為の仕組みが無い ◦ RubyBench - Long Running Ruby
Benchmark とかあるが、公式では無い • これについてはアプリ側で意識するしか現状無い
Conclusion • Rails upgradingを行う際にやっていること・考えている事について お話しました • 最近のRailsは、一つのバージョンアップで挙動が変わらないよう気 をつけています • しかしそれでも、(予想外に)壊れる事は往々にしてあります.
• 早めにアップグレードを試してみて、みんなでバグ踏んでいこうな