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
Migration checker as a CI
Search
Shimpei Otsubo
July 05, 2018
380
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Migration checker as a CI
Shimpei Otsubo
July 05, 2018
More Decks by Shimpei Otsubo
See All by Shimpei Otsubo
Copy Kubernetes Clusters Really Fast
potsbo
3
5.3k
Go と Wantedly の関係 / How Wantedly uses Go
potsbo
1
940
Deploy Flow at Wantedly
potsbo
2
1.1k
Wrap every method with just one line
potsbo
1
5.7k
Zero yen Keyboard
potsbo
6
3.4k
Kube - The core tool at Wantedly
potsbo
1
8.5k
k8s - Kubernetes 8 Factors
potsbo
12
11k
コンテンツ作成に集中するためのプレゼンテーション Tips / Presentation with Confidence
potsbo
7
42k
ConfigMap vs Secret #k8sjp
potsbo
1
1.5k
Featured
See All Featured
Color Theory Basics | Prateek | Gurzu
gurzu
1
480
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.4k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
390
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
470
The Curious Case for Waylosing
cassininazir
1
560
Exploring anti-patterns in Rails
aemeredith
4
520
Into the Great Unknown - MozCon
thekraken
41
2.8k
brightonSEO & MeasureFest 2025 - Winning Strategies for Black Friday CRO & PPC - Christian Goodrich
cargoodrich
3
860
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
450
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
760
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
550
Designing Powerful Visuals for Engaging Learning
tmiket
1
600
Transcript
©2018 Wantedly, Inc. Migration checker as a CI ΦϨΦϨCIͷ࡞Γํ දࢀಓ.rb
#36 5.Jul.2018 - Shimpei Otsubo - @potsbo
©2018 Wantedly, Inc. 3BJMTͷNJHSBUJPOΕͰࢮ͵
©2018 Wantedly, Inc. खಈEFQMPZ͍ͯ͠Δ ECNJHSBUFEFQMPZ͢Δਓ͕Δ (JU)VCΛத৺ʹͨ͠։ൃ 8BOUFEMZͷSBJMT։ൃࣄ
©2018 Wantedly, Inc. ࣗಈNJHSBUJPOͰ͖ͳ͍ͱ͢Δ ͤΊͯࣗಈͰQFOEJOH͕͋Δ͔Γ͍ͨʂʂ NJHSBUJPOΕΔ͕͋Δ 13NFSHFલʹඞͣNJHSBUJPO͢Δੈք
©2018 Wantedly, Inc. push CI? ? pending... success!!!
©2018 Wantedly, Inc. push migration checking CI? ? pending... success!!!
migration? ready!!
©2018 Wantedly, Inc. push Third Party migration checking CI? pending...
success!!! migration? ready!! Bad ֎෦ʹ%#ΛҰ෦ͰFYQPTFͨ͘͠ͳ͍ $*͕٧·Γ͘͢ͳΔ
©2018 Wantedly, Inc. First Party migration checking CI? Good CI
push pending... success!!! migration? ready!! ֎෦ʹ%#ΛFYQPTF͠ͳͯ͘ྑ͍ ΞϓϦέʔγϣϯςετΛॏ͘͠ͳ͍
©2018 Wantedly, Inc.
©2018 Wantedly, Inc. NAME = 'wantedly/migration-checker' post '/builds' do params
= JSON.parse request.body.read repo = params['repository']['full_name'] hash = params['head'] Octokit.create_status(repo, hash, :pending, context: NAME) state = :success desc = "Database is ready" unless SchemaMigration.pending_versions(user, repo, hash).empty? state = :failure description = "Pending migration exists: #{pendings.join(' ')}" end Octokit.create_status(repo, hash, state, context: NAME, description: desc) 'ok' end ©2018 Wantedly, Inc. IUUQTPDUPLJUHJUIVCJPPDUPLJUSC0DUPLJU$MJFOU4UBUVTFTIUNM
©2018 Wantedly, Inc. PATH = 'db/migrate' class SchemaMigration < ActiveRecord::Base
def self.pending_versions(repo, ref) versions = Octokit.contents(slug, path: PATH, ref: ref). map { |c| c.name.split('_')[0] } key = "#{repo.upcase}_DATABASE_URL" ActiveRecord::Base.establish_connection(ENV[key]) migrated = SchemaMigration.pluck(:version) ActiveRecord::Base.connection.close versions - migrated end end ©2018 Wantedly, Inc. database=# \d schema_migrations Table "public.schema_migrations" Column | Type | Modifiers ---------+-------------------+----------- version | character varying | not null
©2018 Wantedly, Inc. ೝূ RVFVF͢Δ QJOHड ࣗಈXFCIPPLઃఆ ઃఆGJMF ΦϚέଞʹΒͳ͍ͱ͍͚ͳ͍͜ͱ
©2018 Wantedly, Inc. 13NFSHFલʹඞͣNJHSBUJPO͢Δੈք