#30741: sqlmigrate doesn't show a drop constraint SQL when previous create
constrain operation wasn't perform.
-------------------------------------+-------------------------------------
     Reporter:  Scott Stafford       |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Migrations           |                  Version:  master
     Severity:  Normal               |               Resolution:
     Keywords:  db_constraint,       |             Triage Stage:
  migrations                         |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Scott Stafford):

 * status:  closed => new
 * resolution:  invalid =>


Comment:

 Thank you for looking into this!  Curiously, I am not seeing what you are
 seeing, however.  We encountered this bug first in normal course of usage
 and found that the constraint had not been removed.  And, in the test
 example I set up for this ticket, I just now ran the first migration and
 then sqlmigrate-checked the second, and it still is a no-op:


 {{{
 (.env) c:\wc\dbconstraintnotdropped>python manage.py migrate myapp 0001
 Operations to perform:
   Target specific migration: 0001_initial, from myapp
 Running migrations:
   Applying myapp.0001_initial... OK

 (.env) c:\wc\dbconstraintnotdropped>python manage.py sqlmigrate myapp 0002
 BEGIN;
 --
 -- Alter field submission on child
 --
 COMMIT;
 }}}


 Then also, I ran the second migration yet the constraint remained:


 {{{
 (.env) c:\wc\dbconstraintnotdropped>python manage.py dbshell
 psql (11.2)
 WARNING: Console code page (437) differs from Windows code page (1252)
          8-bit characters might not work correctly. See psql reference
          page "Notes for Windows users" for details.
 Type "help" for help.

 ventus_master=# \d+ myapp_child
                                                     Table
 "public.myapp_child"
     Column     |  Type   | Collation | Nullable |                 Default
 | Storage | Stats target | Description
 
---------------+---------+-----------+----------+-----------------------------------------+---------+--------------+-------------
  id            | integer |           | not null |
 nextval('myapp_child_id_seq'::regclass) | plain   |              |
  parent_id     | integer |           | not null |
 | plain   |              |
 Indexes:
     "myapp_child_pkey" PRIMARY KEY, btree (id)
     "myapp_child_parent_id_af46d0ab" btree (parent_id)
 Foreign-key constraints:
     "myapp_child_parent_id_af46d0ab_fk_myapp_parent_id" FOREIGN KEY
 (parent_id) REFERENCES myapp_parent(id) DEFERRABLE INITIALLY DEFERRED
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30741#comment:3>
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/063.98d9ebd2b27e11826a3c3c38b5e04e0b%40djangoproject.com.

Reply via email to