#32205: ORM migrations after squash, command sqlmigrate will be error
-------------------------------------+-------------------------------------
               Reporter:  老广       |          Owner:  nobody
                   Type:             |         Status:  new
  Uncategorized                      |
              Component:  Database   |        Version:  3.1
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:  sqlmigrate
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 After upgrade django 2.2 to 3.1, If migrations was squashed, then
 sqlmigrate cause error. If back to 2.2, error lost.

 The migrate file error refer is in squash file.


 **Error stack**

 {{{
   File "/Users/guang/vm/py/py36/lib/python3.6/site-
 packages/django/core/management/commands/sqlmigrate.py", line 37, in
 handle
     loader = MigrationLoader(connection, replace_migrations=False)
   File "/Users/guang/vm/py/py36/lib/python3.6/site-
 packages/django/db/migrations/loader.py", line 53, in __init__
     self.build_graph()
   File "/Users/guang/vm/py/py36/lib/python3.6/site-
 packages/django/db/migrations/loader.py", line 255, in build_graph
     self.graph.validate_consistency()
   File "/Users/guang/vm/py/py36/lib/python3.6/site-
 packages/django/db/migrations/graph.py", line 195, in validate_consistency
     [n.raise_error() for n in self.node_map.values() if isinstance(n,
 DummyNode)]
   File "/Users/guang/vm/py/py36/lib/python3.6/site-
 packages/django/db/migrations/graph.py", line 195, in <listcomp>
     [n.raise_error() for n in self.node_map.values() if isinstance(n,
 DummyNode)]
   File "/Users/guang/vm/py/py36/lib/python3.6/site-
 packages/django/db/migrations/graph.py", line 58, in raise_error
     raise NodeNotFoundError(self.error_message, self.key,
 origin=self.origin)
 django.db.migrations.exceptions.NodeNotFoundError: Migration
 assets.0020_auto_20180816_1652 dependencies reference nonexistent parent
 node ('assets', '0019_auto_20180816_1320')
 }}}


 **Migrations**

 source code:
 
https://github.com/jumpserver/jumpserver/blob/master/apps/assets/migrations/0020_auto_20180816_1652.py

 {{{
 # Generated by Django 2.0.7 on 2018-08-16 08:52

 from django.db import migrations, models


 class Migration(migrations.Migration):

     dependencies = [
         ('assets', '0019_auto_20180816_1320'),
     ]

     operations = [
         migrations.AlterField(
             model_name='adminuser',
             name='org_id',
             field=models.CharField(blank=True, db_index=True, default='',
 max_length=36, verbose_name='Organization'),
         ),
 }}}


 The squash migrations:

 source code:
 
https://github.com/jumpserver/jumpserver/blob/master/apps/assets/migrations/0010_auto_20180307_1749_squashed_0019_auto_20180816_1320.py

 {{{
 class Migration(migrations.Migration):

     replaces = [('assets', '0010_auto_20180307_1749'), ('assets',
 '0011_auto_20180326_0957'), ('assets', '0012_auto_20180404_1302'),
 ('assets', '0013_auto_20180411_1135'), ('assets',
 '0014_auto_20180427_1245'), ('assets', '0015_auto_20180510_1235'),
 ('assets', '0016_auto_20180511_1203'), ('assets',
 '0017_auto_20180702_1415'), ('assets', '0018_auto_20180807_1116'),
 ('assets', '0019_auto_20180816_1320')]

     dependencies = [
         ('assets', '0009_auto_20180307_1212'),
     ]

 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32205>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.8e271a8f85933df95b402f93f23a0a3e%40djangoproject.com.

Reply via email to