Changes between Initial Version and Version 1 of Ticket #23379


Ignore:
Timestamp:
Aug 28, 2014, 12:28:27 PM (10 years ago)
Author:
Simon Charette
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #23379 – Description

    initial v1  
    551) python manage.py repro  # generates correct sql
    66
     7{{{#!sql
    78CREATE TABLE `repro_app_a` (
    89    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
     
    1718ALTER TABLE `repro_app_b` ADD CONSTRAINT `a_id_refs_id_4838e71a` FOREIGN KEY (`a_id`) REFERENCES `repro_app_a` (`id`);
    1819ALTER TABLE `repro_app_a` ADD CONSTRAINT `b_id_refs_id_b49a3179` FOREIGN KEY (`b_id`) REFERENCES `repro_app_b` (`id`);
    19 
     20}}}
    20212) python manage.py migrate
    21223) python manage.py repro  # generates incorrect sql; the first constraint fails because table repro_app_b hasn't been created yet.
    22 
     23{{{#!sql
    2324CREATE TABLE `repro_app_a` (
    2425    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
     
    3334;
    3435ALTER TABLE `repro_app_b` ADD CONSTRAINT `a_id_refs_id_4838e71a` FOREIGN KEY (`a_id`) REFERENCES `repro_app_a` (`id`);
    35 
     36}}}
    3637
    3738Fortunately, the (or, "a") fix is an easy one-liner:
    3839
    39 diff --git a/django/core/management/sql.py b/django/core/management/sql.py
    40 index 323cb54..048b051 100644
     40{{{
     41#!diff
    4142--- a/django/core/management/sql.py
    4243+++ b/django/core/management/sql.py
     
    5051     tables = connection.introspection.table_names()
    5152     known_models = set(model for model in connection.introspection.installed_models(tables) if model not in app_models)
    52 
     53}}}
Back to Top