Skip to content

Files

32 lines (25 loc) · 735 Bytes

display_generated_sql.md

File metadata and controls

32 lines (25 loc) · 735 Bytes

Feature: display generated SQL

This feature adds generated SQL as comment to migrations generated by manage.py makemigrations. It avoids having to do a manage.py sqlmigrate when reviewing a migration.

Example:

# -*- coding: utf-8 -*-
# Generated by Django 1.9 on 2017-12-01 00:00
from __future__ import unicode_literals

from django.db import migrations, models


# Generated SQL code (sqlite):
#
# --
# -- Create model Person
# --
# CREATE TABLE "example_app_person" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(100) NOT NULL);
#
class Migration(migrations.Migration):
    ...

    operations = [
        migrations.CreateModel(
            ...
        ),
    ]