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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
Odyssey Design
rkendrick25
PRO
2
810
The agentic SEO stack - context over prompts
schlessera
0
940
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
330
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
410
Agile that works and the tools we love
rasmusluckow
331
22k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.6k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
390
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
430
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
2k
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͢Δੈք