.. _what-are-migrations: マイグレーションとは? ====================== .. What are migrations? ==================== .. For the uninitiated, migrations (also known as 'schema evolution' or 'mutations') are a way of changing your database schema from one version into another. Django by itself can only do this by adding new models, but nearly all projects will find themselves changing other aspects of models - be it adding a new field to a model, or changing a database column to have null=True. 耳慣れない人にのために説明すると、マイグレーション(または 'schema evolution=スキーマ進化' や 'mutations=突然変異' とも呼ばれます)とは、 データベーススキーマを、あるバージョンから別のバージョンへ変更する方法です。 Django 自体では、新しいモデルの追加にしか対応していませんが、Django 以外のほぼ全てのプロジェクトは、 そのほかのモデルの変更処理にも対応しています(モデルに新しいフィールドを追加した場合や、 データベースのカラムに null=True を追加するように変更した場合など)。 .. South, and other solutions, provide a way of getting round this by giving you the tools to easily and predictably upgrade your database schema. You write migrations, which tell South how to upgrade from one version to the next, and by stringing these migrations together you can move forwards (or backwards) through the history of your database schema. South や他の似たようなアプリケーションでは、データベーススキーマを簡単に、 かつ予測どおりに更新するツールを提供することによって、マイグレーションの機能を実現しています。 特定バージョンから次のバージョンに、どのように更新すべきかを South に教えるために、マイグレーションを用意します。 これらのマイグレーションを一続きにすることで、データベーススキーマの履歴を前後に辿ることが可能です。 .. In South, the migrations also form the way of creating your database initially - the first migration simply migrates from an empty schema to your first tables. This way, running through all the migrations brings your database up-to-date with the most current version of the app, and if you already have an older version, you simply need to run through the ones that appeared since last time. South では、マイグレーションはデータベースを初めから生成する手段でもあります。 一番初めのマイグレーションは、単純に空のスキーマから最初の状態のテーブルにマイグレートします。 同様に、全マイグレーションを通して実行すると、アプリケーションの最新バージョンのデータベースにすることができます。 また古いバージョンのデータベースがあるならば、単に前回作成されたマイグレーションを実行するだけでいいのです。 .. Running through the :ref:`tutorial ` will give you a good idea of how migrations work and how they're useful to you, with some solid examples. :ref:`チュートリアル ` を一通りやってみることで、 その充実したいくつかの例から、マイグレーションがどのように動作するのか、 そしてそれがどの位あなたの役に立つものなのかを理解できると思います。