... on 操作の中で、 schema_editor.connection.alias 属性を見て、データベース接続のエイリアスを確認します: from django.db import migrations def forwards ( apps , schema_editor ): if schema_editor . connection . alias != "default" : return # Your migration code g ... oes here class Migration ( migrations . Migration ): dependencies = [ # Dependencies to other migrations ] operations = [ migrations . RunPython ( forwards ), ] ... turn db == hints [ "target_db" ] return True これをマイグレーションに利用するには、次のようにします: from django.db import migrations def forwards ( apps , schema_editor ): # Your migration code goes here ... class Migration ( migrations . Migration ): dep ... ... うコマンドを、いくつか挙げておきましょう。 migrate は、マイグレーションを適用したり、適用をキャンセルするのに使います。 makemigrations は、モデルに対して行った変更をもとに、新しいマイグレーションを作成します。 sqlmigrate は、マイグレーションに対応する SQL 文 ... を表示します。 showmigrations は、プロジェクトのマイグレーションとそのステータスをリストします。 マイグレーションというのは、データベーススキーマに対する ... バージョン管理システムのようなものです。 makemigrations はモデルの変更点を1つのマイグレーションファイルにパッケージングし(コミットのようなものです)、 migrate はその変更点をデータ ... ... out first creating the contenttypes table ( #22411 ). Modified migrations dependency algorithm to avoid possible infinite recursion. Fixed a UnicodeDecodeError when the flush error message contain ... ed Unicode characters ( #22882 ). Reinstated missing CHECK SQL clauses which were omitted on some backends when not using migrations ( #23416 ). Fixed serialization of type objects in migrations ( #22951 ). Allowed inline and hidden references to admin fi ... during application loading ( #22920 ). Empty index_together or unique_together model options no longer results in infinite migrations ( #23452 ). Fixed crash in contrib.sitemaps if lastmod returned a date rather than a datetime ( #23403 ). Allowed migratio ... ... ( #23717 ). Added GeoDjango compatibility with mysqlclient database driver. Fixed MySQL 5.6+ crash with GeometryField s in migrations ( #23719 ). Fixed a migration crash when removing a field that is referenced in AlterIndexTogether or AlterUniqueTogether ... ld s with blank=True on PostGIS ( #23731 ). Allowed usage of DateTimeField() as Transform.output_field ( #23420 ). Fixed a migration serializing bug involving float("nan") and float("inf") ( #23770 ). Fixed a regression where custom form fields having a qu ... None ( #23761 ). Fixed a migration crash when a field is renamed that is part of an index_together ( #23859 ). Fixed squashmigrations to respect the --no-optimize parameter ( #23799 ). Made RenameModel reversible ( #22248 ) Avoided unnecessary rollbacks of ... ... is both a foreign and primary key ( #24951 ). Fixed AssertionError in some complex queries ( #24525 ). Fixed a migrations crash with GenericForeignKey ( #25040 ). Made translation.override() clear the overridden language when a translation isn' ... ion for options of non- argparse management commands ( #25372 ). Alphabetized ordering of imports in from django.db import migrations, models statement in newly created migrations ( #25384 ). Fixed migrations crash on MySQL when adding a text or a blob fie ... ... 事もできます。 もし独自の Operation オブジェクトを定義する空のマイグレーションファイルが必要であれば、 python manage.py makemigrations --empty yourappname を実行してください。ただし、手動でのスキーマ変更オペレーションの追加はマイグレーションの自動検出機構を ... 混乱させ、 makemigrations が正しい結果を出力しなくなる可能性があることに十分注意してください。 Django が提供するコア機能は全て django.db.migrations. ... 能性があります。これを避けるには、以下の手順を実行する必要があります。 デフォルト値なしで nullable フィールドを追加し、 makemigrations コマンドを実行します。これで AddField オペレーションを持つマイグレーションが生成されるはずです。 デフォルト値をフィールドに ... ... anslation functions check_for_language() and get_language_bidi() when translations are deactivated ( #24569 ). Fixed squashmigrations command when using SeparateDatabaseAndState ( #24278 ). Stripped microseconds from datetime values when using an older ver ... ( #24655 ). Fixed a migration crash when adding new relations to models ( #24573 ). Fixed a migration crash when applying migrations with model managers on Python 3 that were generated on Python 2 ( #24701 ). Restored the ability to use iterators as query ... any-to-many relation ( #24725 ). Removed flushing of the test database with test --keepdb , which prevented apps with data migrations from using the option ( #24729 ). Fixed makemessages crash in some locales ( #23271 ). Fixed help text positioning of cont ... ... bshell is wrapped with rlwrap , if available. rlwrap provides a command history and editing of keyboard input. The new makemigrations --no-header option avoids writing header comments in generated migration file(s). This option is also available for squash ... ew migrate --plan option prints the list of migration operations that will be performed. NoneType can now be serialized in migrations. You can now register custom serializers for migrations. モデル Added support for PostgreSQL operator classes ( Index.opcl ... b" ] django.contrib.gis Support for GDAL 1.9 and 1.10 is dropped. TransactionTestCase serialized data loading Initial data migrations are now loaded in TransactionTestCase at the end of the test, after the database flush. In older versions, this data was l ... ... ent commands that have the --noinput option now also take --no-input as an alias for that option. マイグレーション Initial migrations are now marked with an initial = True class attribute which allows migrate --fake-initial to more easily detect initial mi ... nd LazyObject instances. When supplying None as a value in MIGRATION_MODULES , Django will consider the app an app without migrations. When applying migrations, the "Rendering model states" step that's displayed when running migrate with verbosity 2 or hig ... her now computes only the states for the migrations that have already been applied. The model states for migrations being applied are generated on demand, drastically reducin ... ... policy , Django 1.6 will continue to receive security support until the release of Django 1.8. Django 1.7 の新機能 Schema migrations Django now has built-in support for schema migrations. It allows models to be updated, changed, and deleted by creating mi ... gration files that represent the model changes and which can be run on any development, staging or production database. Migrations are covered in their own documentation , but a few of the key features are: syncdb has been deprecated and replaced by mig ... rate . Don't worry - calls to syncdb will still work as before. A new makemigrations command provides an easy way to autodetect changes to your models and make migrations for them. django.db.models.signals.p ... 2026年10月08日