移行として何でも書くことができます。それがポイントです!
Southを取得したら 起動して実行し、python manage.py schemamigration myapp --empty my_custom_migrationと入力します カスタマイズ可能な空白の移行を作成します。
XXXX_my_custom_migration.pyを開きます myapp/migrations/のファイル forwardsにカスタムSQL移行を入力します 方法。たとえば、 db.executeを使用できます。
移行は次のようになります:
class Migration(SchemaMigration):
def forwards(self, orm):
db.execute("CREATE FULLTEXT INDEX foo ON bar (foobar)")
print "Just created a fulltext index..."
print "And calculated {answer}".format(answer=40+2)
def backwards(self, orm):
raise RuntimeError("Cannot reverse this migration.")
# or what have you
$ python manage.py migrate myapp XXXX # or just python manage.py migrate.
"Just created fulltext index...."
"And calculated 42"