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
wrench - Schema Management Tool for Cloud Spann...
Search
Yuki Ito
February 06, 2020
Technology
2
1.2k
wrench - Schema Management Tool for Cloud Spanner -
Yuki Ito
February 06, 2020
Tweet
Share
More Decks by Yuki Ito
See All by Yuki Ito
Modular Monolith Go Server with GraphQL Federation + gRPC
110y
1
760
Modular Monolith + Go @ newmo
110y
1
850
Go + GraphQL @ newmo
110y
3
630
Architect / Platform Team at KAUCHE
110y
1
510
Cloud Run + Observability / Reliability @ KAUCHE
110y
0
480
Cloud Run CI/CD + QA @ KAUCHE
110y
1
540
Microservices on Cloud Run @ KAUCHE
110y
0
180
KAUCHE Loves Go
110y
0
430
Evolution of Architecture @ Kauche
110y
3
490
Other Decks in Technology
See All in Technology
ハイテク休憩
sat
PRO
2
160
Fanstaの1年を大解剖! 一人SREはどこまでできるのか!?
syossan27
2
170
PHPerのための計算量入門/Complexity101 for PHPer
hanhan1978
5
170
MLOps の現場から
asei
6
650
社内イベント管理システムを1週間でAKSからACAに移行した話し
shingo_kawahara
0
190
ガバメントクラウドのセキュリティ対策事例について
fujisawaryohei
0
550
終了の危機にあった15年続くWebサービスを全力で存続させる - phpcon2024
yositosi
17
13k
DevFest 2024 Incheon / Songdo - Compose UI 조합 심화
wisemuji
0
110
WACATE2024冬セッション資料(ユーザビリティ)
scarletplover
0
210
podman_update_2024-12
orimanabu
1
280
生成AIをより賢く エンジニアのための RAG入門 - Oracle AI Jam Session #20
kutsushitaneko
4
250
1等無人航空機操縦士一発試験 合格までの道のり ドローンミートアップ@大阪 2024/12/18
excdinc
0
160
Featured
See All Featured
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Adopting Sorbet at Scale
ufuk
73
9.1k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
0
98
Unsuck your backbone
ammeep
669
57k
The Invisible Side of Design
smashingmag
298
50k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
48
2.2k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Transcript
wrench - Schema Management Tool for Cloud Spanner - GCPUG
Spanner Day Yuki Ito
Merpay Architect Team Backend Engineer Yuki Ito
wrench ʮGoͷ৽ػೳΛͬͨDBεΩʔϚ ཧπʔϧʯ https://gihyo.jp/magazine/SD/archive/2019/201911
wrench https://github.com/mercari/wrench https://hub.docker.com/r/mercari/wrench
wrench > wrench help Usage: wrench [command] Available Commands: create
drop reset load apply migrate
wrench create > cat ./_examples/schema.sql CREATE TABLE Singers ( SingerID
STRING(36) NOT NULL, FirstName STRING(1024), ) PRIMARY KEY(SingerID); > wrench create --directory ./_examples/
wrench create
wrench drop > wrench drop
wrench reset > wrench reset --directory ./_examples/
wrench load > wrench load --directory ./_examples/ > cat ./_examples/schema.sql
CREATE TABLE Singers ( SingerID STRING(36) NOT NULL, FirstName STRING(1024), ) PRIMARY KEY(SingerID);
wrench apply -ddl > cat ./_examples/ddl.sql ALTER TABLE Singers ADD
COLUMN LastName STRING(1024); > wrench apply --ddl ./_examples/ddl.sql
wrench apply -ddl
wrench apply -dml > cat ./_examples/dml.sql INSERT INTO Singers(SingerID, FirstName)
VALUES("1", "Yuki"); > wrench apply --dml ./_examples/dml.sql
wrench apply -dml
wrench migrate > cat ./_examples/migrations/000001.sql ALTER TABLE Singers ADD COLUMN
LastName STRING(1024); > wrench migrate up --directory ./_examples/ 1/up
wrench migrate
Development DB DB DB Instance
Development CREATE TABLE Singers ( SingerID STRING(36) NOT NULL, FirstName
STRING(1024), ) PRIMARY KEY(SingerID);
Development CREATE TABLE Singers ( SingerID STRING(36) NOT NULL, FirstName
STRING(1024), LastName STRING(1024), ) PRIMARY KEY(SingerID);
Development Apply Migration Load Schema Commit DDL Create DDL File
Write DDL Reset DB NG OK
Development > cat ./_examples/schema.sql CREATE TABLE Singers ( SingerID STRING(36)
NOT NULL, FirstName STRING(1024), ) PRIMARY KEY(SingerID);
Development
Development Apply Migration Load Schema Commit DDL Create DDL File
Write DDL Reset DB NG OK
Development > wrench migrate create --directory ./_examples/ _examples/migrations/000001.sql is created
> ls _examples/migrations/ 000001.sql
Development Apply Migration Load Schema Commit DDL Create DDL File
Write DDL Reset DB NG OK
Development > cat ./_examples/migrations/000001.sql ALTER TABLE Singers ADD COLUMN LastNamo
STRING(1024);
Development Apply Migration Load Schema Commit DDL Create DDL File
Write DDL Reset DB NG OK
Development > wrench migrate up --directory ./_examples/ 1/up
Development
Development typo!!
Development Apply Migration Load Schema Commit DDL Create DDL File
Write DDL Reset DB NG OK
Development > cat ./_examples/schema.sql CREATE TABLE Singers ( SingerID STRING(36)
NOT NULL, FirstName STRING(1024), ) PRIMARY KEY(SingerID); > wrench reset --directory ./_examples/
Development
Development Apply Migration Load Schema Commit DDL Create DDL File
Write DDL Reset DB NG OK
Development > cat ./_examples/migrations/000001.sql ALTER TABLE Singers ADD COLUMN LastName
STRING(1024);
Development Apply Migration Load Schema Commit DDL Create DDL File
Write DDL Reset DB NG OK
Development > wrench migrate up --directory ./_examples/ 1/up
Development
Development
Development Apply Migration Load Schema Commit DDL Create DDL File
Write DDL Reset DB NG OK
Development > wrench load --directory ./_examples/ > cat ./_examples/schema.sql CREATE
TABLE SchemaMigrations ( Version INT64 NOT NULL, Dirty BOOL NOT NULL, ) PRIMARY KEY(Version); CREATE TABLE Singers ( SingerID STRING(36) NOT NULL, FirstName STRING(1024), LastName STRING(1024), ) PRIMARY KEY(SingerID);
Development > wrench load --directory ./_examples/ > cat ./_examples/schema.sql CREATE
TABLE SchemaMigrations ( Version INT64 NOT NULL, Dirty BOOL NOT NULL, ) PRIMARY KEY(Version); CREATE TABLE Singers ( SingerID STRING(36) NOT NULL, FirstName STRING(1024), LastName STRING(1024), ) PRIMARY KEY(SingerID);
Development > wrench load --directory ./_examples/ > cat ./_examples/schema.sql CREATE
TABLE SchemaMigrations ( Version INT64 NOT NULL, Dirty BOOL NOT NULL, ) PRIMARY KEY(Version); CREATE TABLE Singers ( SingerID STRING(36) NOT NULL, FirstName STRING(1024), LastName STRING(1024), ) PRIMARY KEY(SingerID);
Development
Development Apply Migration Load Schema Commit DDL Create DDL File
Write DDL Reset DB NG OK
Development DB DB DB Instance
Deployment Create Tag Cloud Build Hook GCR Cloud Spanner GKE
Watch Push Migrate Deploy
Deployment Create Tag Cloud Build Hook GCR Cloud Spanner GKE
Watch Push Migrate Deploy
Deployment Migration Deployment Pipeline Cloud Spanner GKE
Deployment Migration Deployment Pipeline Cloud Spanner GKE
Deployment GKE Cloud Spanner Fetch Job Manifest ᶅ Exec `wrench
migrate` ᶄ Run Migration Job
Deployment GKE Cloud Spanner Fetch Job Manifest ᶅ Exec `wrench
migrate` ᶄ Run Migration Job
Deployment --- apiVersion: batch/v1 kind: Job metadata: name: db-migration spec:
template: spec: containers: - command: - /db/migrate.sh env: - name: SPANNER_INSTANCE_ID value: xxx - name: SPANNER_DATABASE_ID value: xxx - name: GCP_PROJECT_ID value: xxx - name: GOOGLE_APPLICATION_CREDENTIALS value: xxx image: gcr.io/xxxx…
Deployment GKE Cloud Spanner Fetch Job Manifest ᶅ Exec `wrench
migrate` ᶄ Run Migration Job
Deployment GKE Cloud Spanner Fetch Job Manifest ᶅ Exec `wrench
migrate` ᶄ Run Migration Job
Deployment wrench migrate up --directory /db
Deployment GKE Cloud Spanner Fetch Job Manifest ᶅ Exec `wrench
migrate` ᶄ Run Migration Job
Deployment Migration Deployment Pipeline Cloud Spanner GKE
Deployment Migration Deployment Pipeline Cloud Spanner GKE
Deployment GKE ᶄ Apply Deployment Manifest (Deploy New Container) ᶃ
Fetch Deployment Manifest
Deployment Create Tag Cloud Build Hook GCR Cloud Spanner GKE
Watch Push Migrate Deploy
Merpay Tech Fest 2020 https://events.merpay.com/techfest-2020