#25247: makemigrations unable to generate necessary migration for making a
superclass abstract
-------------------------------------+-------------------------------------
     Reporter:  rapilabs             |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  Migrations           |                  Version:  1.8
     Severity:  Normal               |               Resolution:
     Keywords:  abstract             |             Triage Stage:  Accepted
  makemigrations                     |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by charettes):

 @MarkusH, I think it shouldn't be an issue if the sequence is started at
 the referenced field's serial current value:

 {{{#!sql
 CREATE TABLE foo (
     id serial primary key
 );

 CREATE TABLE bar (
     foo_ptr_id integer primary key REFERENCES foo (id)
 );

 INSERT INTO foo DEFAULT VALUES;
 INSERT INTO foo DEFAULT VALUES;
 INSERT INTO foo DEFAULT VALUES;

 SELECT * FROM foo;
  id
 ----
   1
   2
   3
 (3 rows)

 INSERT INTO bar SELECT id FROM foo;

 SELECT * FROM bar;
  foo_ptr_id
 ------------
           1
           2
           3
 (3 rows)

 CREATE SEQUENCE bar_id_seq;
 SELECT setval('bar_id_seq', currval('foo_id_seq'));
 ALTER TABLE bar RENAME COLUMN foo_ptr_id TO id;
 ALTER TABLE bar ALTER COLUMN id SET DEFAULT nextval('bar_id_seq');
 ALTER TABLE bar DROP CONSTRAINT bar_foo_ptr_id_fkey;

 INSERT INTO bar DEFAULT VALUES;
 INSERT INTO bar DEFAULT VALUES;

 SELECT * FROM bar;
  id
 ----
   1
   2
   3
   4
   5
 (5 rows)
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25247#comment:4>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.65c4c2446eb2da6c4edc3b5177330431%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to