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
FluentMigratorでDBマイグレーション
Search
thinkAmi
February 21, 2015
Programming
2.3k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
FluentMigratorでDBマイグレーション
2015/2/21に開かれた、めとべや東京 #7 でのLTスライドです。
thinkAmi
February 21, 2015
More Decks by thinkAmi
See All by thinkAmi
知ろう!使おう!HDF5ファイル!/pycon-jp-2019-talk
thinkami
5
11k
Djangoでのメール送信 - 設定からテストまで/djangocongress-jp-2019-talk
thinkami
1
13k
Django・WSGIミドルウェア入門/django-congress-jp-2018-talk
thinkami
4
5.6k
自分のための機械学習をしてみた話
thinkami
0
690
Xamarinで作るAndroid Wearアプリ
thinkami
1
2.8k
デプロイボタンを使ってみた
thinkami
0
1.1k
Vagrant + Berkshelf でお手軽写経環境構築
thinkami
1
1.4k
Twilio入門
thinkami
0
1.7k
おひとりさま環境でのChef-solo使用例
thinkami
2
1.5k
Other Decks in Programming
See All in Programming
Family mrubyの進捗
kishima
1
130
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
240
SREの越境 / SRE Collaboration
y0hgi
2
280
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
5
4.5k
大喜利で理解するLLM as a Judge / Understanding LLM-as-a-Judge through Ogiri
rockname
0
160
setup-vp GitLab対応の裏側
naokihaba
0
120
JRuby: Past, Present, and Future
headius
0
190
アクセシビリティから考える情報設計
high_g_engineer
0
390
[GoCon2026] When Goroutines Are Not Enough: Runtime Locality in High-Throughput Go
takehaya
6
2.4k
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
360
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
9
5k
App Intentsのビルドプロセスを支える技術
kntkymt
0
430
Featured
See All Featured
Faster Mobile Websites
deanohume
310
32k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
410
Git: the NoSQL Database
bkeepers
PRO
432
67k
Making Projects Easy
brettharned
120
6.8k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
46k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
203
76k
The SEO Collaboration Effect
kristinabergwall1
1
570
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
2.9k
Testing 201, or: Great Expectations
jmmastey
46
8.3k
Exploring anti-patterns in Rails
aemeredith
4
510
Transcript
FluentMigratorで DBマイグレーション @thinkAmi めとべや東京 #7 2015.2.21
自己紹介 • 長野県から来ました • アカウント – thinkAmi • Twitter •
Hatena • GitHub • C#(WPF)とかMS AccessとかRubyとか
自己紹介 • りんご食べあるき – 現在57種類くらい • 今日はピンクレディを食べました • Twitter +
Heroku + C#(Ruby)で記録・公開 » http://ringo-tabetter-cs.herokuapp.com/
長野県のコミュニティ • NSEG (#nseg) – 長野県とコンピューターをテーマに毎月開催 • 本日、ギークラボ長野でOpenDataハッカソン中 • Google
Developer Group 信州 • 3/14 AndroidWearイベント » IT勉強会スタンプラリー参加 • Azure しなの (3/28 Hokuriku.NETと合同勉強会) • JAWS-UG 長野支部 » 他のコミュニティ > https://github.com/nseg- jp/w/wiki/NSEG以外の長野のIT勉強会
本題 • FluentMigratorでDBマイグレーション • クライアントアプリの裏側ということで...
定義 • DBマイグレーションとは – DBのテーブルスキーマの更新などを管理・実 行できるようにすること – 他にもありますが、今回は上記の定義です
本題 • データベースの管理にて – 最初のうち • CUIでDDLやDMLを実行 • GUIでポチポチ –
次第に忘れ去られ... • どの順番でどのDDLやDMLを実行する? • 何でこんなスキーマにしたんだっけ? » ツライ – DBマイグレーションをしたい...
Entity Framework • Code First Migrations – MS Accessで試したが使えず... •
EFがOLEDB接続をサポートしていないため » http://stackoverflow.com/a/11197393
FluentMigrator • DBマイグレーションフレームワーク – C#で、DDLやDMLを書く • DBに依存せず、スキーマの変更を記述可能 • Gitなどで、バージョン管理可能 •
リポジトリ(GitHub) – https://github.com/schambers/fluentmigrator • 830starほど • Apache 2 License
動作RDBMS • SQL Server • SQL Server Compact Edition •
PostgreSQL • MySQL • Oracle • SQLite • Jet (MS Access, ACEも動作) » https://github.com/schambers/fluentmigrator /wiki/Fluent-Interface
実行方法 • コマンドライン • NAnt • MSBuild • Rake –
Ruby + Albacore gem が必要 » https://github.com/schambers/fluentmigrator /wiki/Migration-Runners
インストール • NuGetでインストール – 本体 • PM> Install-Package FluentMigrator –
コマンドラインランナーを使う場合 • PM> Install-Package FluentMigrator.Tools
マイグレーションファイル • コード
マイグレーションの実行 • 実行 .\Migrate.exe --assembly=FluentMigrationTest.exe --provider=jet --connection="Provider=Microsoft.ACE.OLEDB.12.0;DataSo urce=D:\db\targetdb.accdb" --verbose=True --task=migrate
実行結果の表示 CREATE TABLE [hoge] ([id] COUNTER NOT NULL, [content] VARCHAR(255),
CONSTRAINT [PK_hoge] PRIMARY KEY ([id]))
MS Accessの結果 • DDLが実行されている
マイグレーション(DDL) • CREATE TABLE Create.Table("hoge") .WithColumn("id") .AsInt32() .PrimaryKey().Identity() .WithColumn("content") .AsString().Nullable();
マイグレーション(DDL) • ALTER TABLE Alter.Table("hoge") .AddColumn("fuga") .AsString().Nullable() .AlterColumn("content") .AsString().NotNullable();
マイグレーション(DDL) • CREATE INDEX Create.Index("idx") .OnTable("hoge") .OnColumn("content");
マイグレーション(DDL) • RENAME COLUMN Rename.Column("fuga") .OnTable("hoge") .To("piyo");
マイグレーション(DML) • INSERT Insert.IntoTable("hoge") .Row(new { content = "added" });
• UPDATE Update.Table("hoge") .Set(new { content = "updated" }) .Where(new { id = 1 });
ランナーのオプション – assembly » 対象のマイグレーションが含まれるexe/dll – provider » 対象のRDBMS –
connection (接続文字列) – task » Migration, Rollback(全件, 1件, 指定ver etc) – verbose » Trueでマイグレーションの詳細を表示
クラウド(Paas)での実行 • Azure Websites – 管理画面(Kudu)のConsoleにて • Heroku – Third-Party
Buildpacksでビルド • Monoでのビルド – friism/heroku-buildpack-mono – heroku/dotnet-buildpack (ASP.NET 5用?) – One-Off Dynos でHeroku Postgresへ実行 • heroku run bash 後
まとめ • FluentMigratorを使えば、EFを使えない 環境でもDBマイグレーション可能 • 他のDBマイグレーションツールがあれば 知りたいです!
参考文献など • 参考文献 – FluentMigrator公式Wikiが一番参考になります • https://github.com/schambers/fluentmigrator/wiki • スライドまわり –
プレゼンツール • Rabbit (Ruby製) – http://rabbit-shocker.org/ja/ – スライドテンプレート • 交差点の真ん中で様のパワーポイント用自作デザインテンプレート – http://sagittarius.dip.jp/toshi/template.php – フォント • フォントな様のやさしさゴシックボールド – http://www.fontna.com/blog/736/