... 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 ... goes here class Migration ( migrations . Migration ): dependencies = [ # Dependencies to other migrations ] operations = [ migrations . RunPython ( ... 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 ): de ... ... auto-created many-to-many tables when changing Meta.db_table ( #23630 ). Fixed a migration crash when adding an explicit id field to a model on SQLite ( #23702 ). Added a warning for duplicate models when a module ... ( #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 ... n locale to Monday. Added support for transactional spatial metadata initialization on SpatiaLite 4.1+ ( #23152 ). Fixed a migration crash that prevented changing a nullable field with a default to non-nullable with the same default ( #23738 ). Fixed a mi ... ... うコマンドを、いくつか挙げておきましょう。 migrate は、マイグレーションを適用したり、適用をキャンセルするのに使います。 makemigrations は、モデルに対して行った変更をもとに、新しいマイグレーションを作成します。 sqlmigrate は、マイグレーションに対応する SQL ... 文を表示します。 showmigrations は、プロジェクトのマイグレーションとそのステータスをリストします。 マイグレーションというのは、データベーススキーマに対す ... るバージョン管理システムのようなものです。 makemigrations はモデルの変更点を1つのマイグレーションファイルにパッケージングし(コミットのようなものです)、 migrate はその変更点をデータ ... ... operation rename ManyToManyField tables ( #24135 ). Fixed a migration crash on MySQL when migrating from a OneToOneField to a ForeignKey ( #24163 ). Prevented the static.serve view from produc ... ... 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 ve ... rsion of the MySQLdb DB API driver as it does not support fractional seconds ( #24584 ). Fixed a migration crash when altering ManyToManyField s ( #24513 ). Fixed a crash with QuerySet.update() on foreign keys to one-to-one field ... xed JavaScript path of contrib.admin 's related field widget when using alternate static file storages ( #24655 ). Fixed a migration crash when adding new relations to models ( #24573 ). Fixed a migration crash when applying migrations with model managers ... ... as Google Chrome ignore control characters at the start of a URL in an anchor href . バグ修正 Fixed renaming of classes in migrations where renaming a subclass would cause incorrect state to be recorded for objects that referenced the superclass ( #24354 ... ). Stopped writing migration files in dry run mode when merging migration conflicts. When makemigrations --merge is called with verbosity=3 the migrati ... ... 事もできます。 もし独自の Operation オブジェクトを定義する空のマイグレーションファイルが必要であれば、 python manage.py makemigrations --empty yourappname を実行してください。ただし、手動でのスキーマ変更オペレーションの追加はマイグレーションの自動検出機構を ... 混乱させ、 makemigrations が正しい結果を出力しなくなる可能性があることに十分注意してください。 Django が提供するコア機能は全て django.db.migrations ... 's default value is permanent and should be baked into the project state ( True ), or if it is temporary and just for this migration ( False ) - usually because the migration is adding a non-nullable field to a table and needs a default value to put into ... ... etups ( #24298 ). Fixed a regression that prevented custom fields inheriting from ManyToManyField from being recognized in migrations ( #24236 ). Fixed crash in contrib.sites migrations when a default database isn't used ( #24332 ). Added the ability to s ... ... rashed if a queryset contained an aggregation over a Subquery() ( #31109 ). Fixed a regression in Django 3.0 that caused a migration crash on PostgreSQL 10+ when adding a foreign key and changing data in the same migration ( #31106 ). Fixed a regression i ... ... ョンを含むマイグレーションを追加してください。たとえば: from django.contrib.postgres.operations import HStoreExtension class Migration ( migrations . Migration ): ... operations = [ HStoreExtension (), ... ] オペレーションは、拡張機能がすでに存在する場合は追 ... べ替えるための照合順序を作成するには、次のようにします: from django.contrib.postgres.operations import CreateCollation class Migration ( migrations . Migration ): ... operations = [ CreateCollation ( "case_insensitive" , provider = "icu" , locale = "und-u-k ... キュメント を参照してください。 注釈 CONCURRENTLY オプションはトランザクション内でサポートされていません (詳細は non-atomic migration を参照してください)。 検証を強制しない制約を追加する PostgreSQL は NOT VALID オプションを ADD CONSTRAINT 文でサポートしてお ... 2026年10月08日