Edge Rails, Rails

[Edge Rails] Migrationの新しい採番方法:UTC-based Migration Versioning

2008/04/12

Rails の migration は、データベースの履歴管理が簡単にできますが、migration が頻繁に起きる開発では、バージョン番号(002_create_users.rb の 002とか)がかぶってしまう場合があります。

これを解決するために、よりユニークなUTC(協定世界時)ベースの採番が採用されたようです。バージョン番号は下記のようになります。

> script/generate migration one
     create  db/migrate/20080402122512_one.rb

また、以前まではバージョン番号での切り戻しが可能でしたが、今回の機能追加で個別のテーブルを作成したり、削除したりできます。
使い方は下記の通り、作成時には rake db:migrate:up VERSION=utcの番号、削除時は rake db:migrate:down VERSION=utcの番号 で行います。

> rake db:migrate:up VERSION=20080402122523
== 20080402122523 Two: migrating ==============================================
-- create_table(:two)
  -> 0.0122s
== 20080402122523 Two: migrated (0.0124s) =====================================

番号指定が微妙に面倒かも。。


related posts


tags

,


have your say

Add your comment below, or trackback from your own site. Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

:

:


« [Edge Rails] Gemの管理を行う: Gem Dependencies
» WordPress2.5へアップデート + テンプレート変更