... 適用をキャンセルするのに使います。 makemigrations は、モデルに対して行った変更をもとに、新しいマイグレーションを作成します。 sqlmigrate は、マイグレーションに対応する SQL 文を表示します。 showmigrations は、プロジェクトのマイグレーションとそのステータスをリス ... igrations --name オプションが使えます。 $ python manage.py makemigrations --name changed_my_model your_app_label Executing sqlmigrate The sqlmigrate command takes migration names and returns the SQL they would run. It doesn't actually run the migration on ... s. To inspect the SQL of the initial migration that created the tables for the books models above, run: $ python manage.py sqlmigrate books 0001 You should see something similar to the following (we've reformatted it for readability): BEGIN ; -- -- Create ... ... 検出器に新しいモデルが作成されたことを伝えながら、既存のテーブル名を新しいテーブル名に変更します。既存のテーブル名と制約名は sqlmigrate または dbshell で確認できます。新しいテーブル名は中間モデルの _meta.db_table プロパティで確認できます。新しい through モデ ... l" ), ] operations = [ migrations . SeparateDatabaseAndState ( database_operations = [ # Old table name from checking with sqlmigrate, new table # name from AuthorBook._meta.db_table. migrations . RunSQL ( sql = "ALTER TABLE core_book_authors RENAME TO cor ... ... ling for SQLite ( #23880 ). Fixed a crash when RunSQL SQL content was collected by the schema editor, typically when using sqlmigrate ( #23909 ). Fixed a regression in contrib.admin add/change views which caused some ModelAdmin methods to receive the incor ... ... やすいものになります。 See マイグレーション for the full details, including how to inspect the SQL a migration will run with sqlmigrate (see Executing sqlmigrate ). manage.py ユーティリティでできることについては django-admin のドキュメント を読んで下さい。 A ... ... initial.py: + Create model WorldBorder WorldBorder モデルのテーブルを生成するSQLを見てみましょう: / $ python manage.py sqlmigrate world 0001 ...\> py manage.py sqlmigrate world 0001 このコマンドを実行すると、次の出力が生成されるはずです: BEGIN ; -- -- ... ... じっくりと、データベースと状態のオペレーションを慎重にチェックすべきです。データベースのオペレーションをチェックするために、 sqlmigrate と dbshell を使うことができます。状態のオペレーションをチェックするために makemigrations 、特に --dry-run を使うことができ ... ort Operation class MyCustomOperation ( Operation ): # If this is False, it means that this operation will be ignored by # sqlmigrate; if true, it will be run and the SQL collected for its output. reduces_to_sql = False # If this is False, Django will refu ... ... umpdata コマンドラインオプション makemessages コマンドラインオプション --app loaddata コマンドラインオプション --backwards sqlmigrate コマンドラインオプション --blank ogrinspect コマンドラインオプション --buffer test コマンドラインオプション --check makemi ... move_stale_contenttypes コマンドラインオプション showmigrations コマンドラインオプション sqlflush コマンドラインオプション sqlmigrate コマンドラインオプション sqlsequencereset コマンドラインオプション --debug-mode test コマンドラインオプション --debug-sql ... tions migrate ogrinspect optimizemigration remove_stale_contenttypes runserver sendtestemail shell showmigrations sqlflush sqlmigrate sqlsequencereset squashmigrations startapp startproject test testserver version django.apps module django.conf.settings.co ... ... ンドで実行される SQL 文を表示します。 --database DATABASE SQLを表示するデータベースを指定します。デフォルトは default です。 sqlmigrate django-admin sqlmigrate app_label migration_name 指定された名前のマイグレーション用の SQL を出力します。これは、制約名の解 ... クティブなデータベース接続を必要とします。つまり、後で適用したいデータベースのコピーに対して SQL を生成する必要があります。 sqlmigrate は出力に色をつけないことに注意してください。 --backwards マイグレーションの適用を取り消すSQLを生成します。デフォルトでは、 ... ... ドが追加され、テストメールを送信して、Django 経由のメール送信が正常に動作しているかを簡単にチェックできるようになりました。 sqlmigrate が生成する SQL コードのリーダビリティを向上するため、マイグレーション操作ごとに生成される SQL コードの前に、マイグレーショ ... ... 、必要な ALTER TABLE ステップを実行するために、マイグレーションに RunSQL 操作を追加する必要があります。既存のテーブル名は、 sqlmigrate 、 dbshell 、またはフィールドの remote_field.through._meta.db_table プロパティを介して確認できます。 モデルで明示的に定義さ ... 2026年10月08日