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.3k
wrench - Schema Management Tool for Cloud Spanner -
Yuki Ito
February 06, 2020
Tweet
Share
More Decks by Yuki Ito
See All by Yuki Ito
newmo の創業を支える Software Architecture と Platform Engineering
110y
5
2.7k
Modular Monolith Go Server with GraphQL Federation + gRPC
110y
1
980
Modular Monolith + Go @ newmo
110y
1
1.1k
Go + GraphQL @ newmo
110y
3
780
Architect / Platform Team at KAUCHE
110y
1
580
Cloud Run + Observability / Reliability @ KAUCHE
110y
0
560
Cloud Run CI/CD + QA @ KAUCHE
110y
1
590
Microservices on Cloud Run @ KAUCHE
110y
0
230
KAUCHE Loves Go
110y
0
470
Other Decks in Technology
See All in Technology
Amazon ECS & AWS Fargate 運用アーキテクチャ2025 / Amazon ECS and AWS Fargate Ops Architecture 2025
iselegant
13
4.3k
Oracle Audit Vault and Database Firewall 20 概要
oracle4engineer
PRO
2
1.6k
菸酒生在 LINE Taiwan 的後端雙刀流
line_developers_tw
PRO
0
1.1k
知識を整理して未来を作る 〜SKDとAI協業への助走〜
yosh1995
0
140
TerraformをSaaSで使うとAzureの運用がこんなに楽ちん!HCP Terraformって何?
mnakabayashi
0
300
成立するElixirの再束縛(再代入)可という選択
kubell_hr
0
840
初めてのAzure FunctionsをClaude Codeで作ってみた / My first Azure Functions using Claude Code
hideakiaoyagi
1
180
Agentic Workflowという選択肢を考える
tkikuchi1002
1
360
2年でここまで成長!AWSで育てたAI Slack botの軌跡
iwamot
PRO
2
140
ユーザーのプロフィールデータを活用した推薦精度向上の取り組み
yudai00
0
470
AWS CDK 実践的アプローチ N選 / aws-cdk-practical-approaches
gotok365
4
470
OAuth/OpenID Connectで実現するMCPのセキュアなアクセス管理
kuralab
5
840
Featured
See All Featured
Balancing Empowerment & Direction
lara
1
340
How STYLIGHT went responsive
nonsquared
100
5.6k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.4k
Designing Experiences People Love
moore
142
24k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
32
5.9k
Become a Pro
speakerdeck
PRO
28
5.4k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
228
22k
Designing for Performance
lara
609
69k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
The Invisible Side of Design
smashingmag
299
51k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
8
660
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