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
Managing Database Migrations in Go Backend Systems
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Kazuhiko Yamashita
September 16, 2025
Programming
600
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Managing Database Migrations in Go Backend Systems
https://pepabo.connpass.com/event/363869/
ペパボ & GO 〜 夏のGo祭り2025、あの夏〜でお話しました。
Kazuhiko Yamashita
September 16, 2025
More Decks by Kazuhiko Yamashita
See All by Kazuhiko Yamashita
タクシーアプリ『GO』の バックエンド開発のおける AI利活用と若者のすべて
pyama86
3
2.7k
継続的な負荷検証を目指して
pyama86
3
1.9k
成長期における、 ユーザー領域の複雑さと 整備の進め方
pyama86
1
830
Stay Hacker 〜九州で生まれ、Perlに出会い、コミュニティで育つ〜
pyama86
2
6.7k
新しい職場の CI が 20 分かかっていたらあなたならどうする?
pyama86
2
1.6k
事業を差別化する技術を生み出す技術
pyama86
4
2.4k
Re:Define 可用性を支える モニタリング、パフォーマンス最適化、そしてセキュリティ
pyama86
9
11k
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
6
2.2k
Tuning GraphQL on Rails
pyama86
2
2.9k
Other Decks in Programming
See All in Programming
なぜCTOを降りてFDEを選んだのか?〜なぜプロダクト企業がFDEで顧客の現場に踏み込むのか〜
gonta
1
170
難しいけど、読めた。- OSSの入口に立った話。
sts11142
0
150
RAG の “R” を Swift で覗いてみる 〜「意味から探す」検索の仕組み〜
nao_randd
0
120
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
3.6k
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
34
16k
Are APIs Still Relevant in the AI Era?
soyuka
0
440
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
910
setup-vp GitLab対応の裏側
naokihaba
0
160
Workers Cache を知る
syumai
0
350
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
450
Domain-Driven Transformation
hschwentner
2
2.3k
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
390
Featured
See All Featured
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
520
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
540
Skip the Path - Find Your Career Trail
mkilby
1
250
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
320
A better future with KSS
kneath
240
18k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.7k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
720
YesSQL, Process and Tooling at Scale
rocio
174
15k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
1
620
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
For a Future-Friendly Web
brad_frost
184
10k
Transcript
Managing Database Migrations in Go Backend Systems 2025.09.16 P山@GO株式会社
© GO Inc. 2 GO株式会社 山下 和彦 所属 開発本部 ソフトウェア開発統括部
バックエンド開発部 バックエンド1グループ @pyama86
© GO Inc. 3 旧来のバックエンドチームのDBマイグレーション 1. sqldefを利用しているリポジトリに変更内容をPR 2. レビュー後マージ 3.
開発環境は即時PR作成者が適用 4. 週に1回リリース担当のチームが変更を本番に適用
© GO Inc. 4 sqldef k0kubunさんが開発したSQLで冪等にDBスキーマ管理が できるソフトウェア CREATE TABLE offices
( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100) NOT NULL, address VARCHAR(255), city VARCHAR(100), phone VARCHAR(50), created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); ALTER TABLE `offices` ADD COLUMN `city` VARCHAR(100)
© GO Inc. 5 十分に解決されていないこと 1. sqldefを利用しているリポジトリに変更内容をPR 2. レビュー後マージ 3.
開発環境は即時PR作成者が適用 4. 週に1回リリース担当のチームが変更を本番に適用
© GO Inc. 6 開発環境は即時PR作成者が適用 手順がそれなりにあり、トイルになっていた 1. bastionサーバにログイン(堅牢なログイン=手間) 2. 作業が重複しないように部全体に周知
3. 開発環境とQA環境へsqldefを実行
© GO Inc. 7 十分に解決されていないこと 1. sqldefを利用しているリポジトリに変更内容をPR 2. レビュー後マージ 3.
開発環境は即時PR作成者が適用 4. 週に1回リリース担当のチームが変更を本番に適用
© GO Inc. 8 週に1回リリース担当のチームが変更を本番に適用 変更を行いたい人と作業者が異なるのとMySQLの特性 1. MySQLのレプリケーションは ALTERで詰まる※ 2.
変更対象のテーブルの 件数が多い=ALTERが長期化する 3. 作業者がテーブルの行数を 確認する必要がある ※INSTANT DDLであれば高速に完了します
© GO Inc. 9 pt-online-schema-change(pt-osc) https://martin-son.github.io/Martin-IT-Blog/mysql/3rd%20party%20tool/pt-osc/2022/08/20/pt-osc-%EC%84%A4%EC%B9%98- %EB%B0%8F-%EC%82%AC%EC%9A%A9%EB%B2%95.htmlより引用 ALTERによるレプリケーション遅延をコントロールして スキーマ・マイグレーションを行うソフトウェア
© GO Inc. 10 運用課題を解決するalterguard作った 1. sqldefのDryRunの結果を食わせると、テーブルの行数に 応じてALTER実行するか、pt-oscするか自動で決定して実行 2. DryRunやSlack通知を備えており、自動化に特化
3. テーブルのリネームやクリーンアップも対応 a. リネーム時に新旧のテーブル行数を精査 b. 成功時のクリーンアップだけじゃなく、失敗時の クリーンアップも対応 https://github.com/pyama86/alterguard/
© GO Inc. 11 alterguardの実行風景 Slack通知でオペレーション 内容がわかるし、 かかった時間や行数も 通知することで影響がわかる
© GO Inc. 12 現在のバックエンドチームのDBマイグレーション 1. sqldefを利用しているリポジトリに変更内容をPR 2. レビュー後マージ 3.
GitHub Actionsから開発環境、QA環境に自動適用 4. 週に1回リリース担当がGitHub Actionsをキック a. 本番はDryRunの後にActionsのApproveも必須
© GO Inc. 13 残っている課題 1. pt-oscは銀の弾丸ではなく、メタデータロックを 取るのと、コピー時にレコードをロックするため、 状況によってはオンライン処理のトランザクションが 失敗したりする
2. 交通インフラは高い可用性が求められるため、タクシーの 注文に重要なテーブルは深夜に適用している →運用枯れてきたら深夜に自動実行するかも?
© GO Inc. 14 最後に 1. トイルをなくすために、ソフトウェア作った 2. pt-osc便利だけど、それでも様々あるね 3.
GO、ベンチャーから会社の規模が大きくなるタイミングで 必要になる、仕組みで解決する仕事がたくさんある
© GO Inc. 日本のモビリティ、ほんとに良くしたいし、最近はそういう意識でデススト やってます 15 私たちと一緒に 未来を作っていきませんか?