Re: migrate id field from integer to biginter (probable bug)
Opened a bug here: https://code.djangoproject.com/ticket/28298 and have a working patch here: https://github.com/django/django/pull/8628 -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at https://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/65af82c8-116a-4269-b682-ef3be8c2dbba%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: migrate id field from integer to biginter (probable bug)
Yes, it looks like a bug. The incorrect SQL is added here: https://github.com/django/django/blob/8149bd00d8b8af816a683e5ecc0e204f344616f5/django/db/backends/base/schema.py#L745-L749 On Wednesday, May 31, 2017 at 1:34:07 PM UTC-4, drakkan wrote: > > Hi, > > I have two models like these: > > class Allarme(models.Model): > > > class Registrazione(models.Model): >allarme = models.ForeignKey(Allarme, blank=True, null=True, > on_delete=models.DO_NOTHING, db_constraint=False) > > > now I want to change id field for these models from int to bigint so I > added to both > > id = models.BigAutoField(primary_key=True) > > and I did the migration, > > python manage.py sqlmigrate > > show something like this: > > BEGIN; > -- > -- Alter field id on allarme > -- > ALTER TABLE "multimedia_allarmi" ALTER COLUMN "id" TYPE bigint USING > "id"::bigint; > DROP SEQUENCE IF EXISTS "multimedia_allarmi_id_seq" CASCADE; > CREATE SEQUENCE "multimedia_allarmi_id_seq"; > ALTER TABLE "multimedia_allarmi" ALTER COLUMN "id" SET DEFAULT > nextval('"multimedia_allarmi_id_seq"'); > SELECT setval('"multimedia_allarmi_id_seq"', MAX("id")) FROM > "multimedia_allarmi"; > ALTER TABLE "multimedia_registrazioni" ALTER COLUMN "allarme_id" TYPE > bigint USING "allarme_id"::bigint; > *ALTER TABLE "multimedia_registrazioni" ADD CONSTRAINT > "multimedia_registrazioni_allarme_id_4919213e_fk" FOREIGN KEY > ("allarme_id") REFERENCES "multimedia_allarmi" ("id") DEFERRABLE INITIALLY > DEFERRED;* > -- > -- Alter field id on registrazione > -- > ALTER TABLE "multimedia_registrazioni" ALTER COLUMN "id" TYPE bigint USING > "id"::bigint; > DROP SEQUENCE IF EXISTS "multimedia_registrazioni_id_seq" CASCADE; > CREATE SEQUENCE "multimedia_registrazioni_id_seq"; > ALTER TABLE "multimedia_registrazioni" ALTER COLUMN "id" SET DEFAULT > nextval('"multimedia_registrazioni_id_seq"'); > SELECT setval('"multimedia_registrazioni_id_seq"', MAX("id")) FROM > "multimedia_registrazioni"; > COMMIT; > > so as you can see a foreign key is added for a model field with > db_constraint=False, > > can you please confirm that this is a bug? I'm using django 1.11.1 > > thanks! > > > -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at https://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/5f1f024e-f737-4ee3-ac83-b92e9c956a7b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
migrate id field from integer to biginter (probable bug)
Hi, I have two models like these: class Allarme(models.Model): class Registrazione(models.Model): allarme = models.ForeignKey(Allarme, blank=True, null=True, on_delete=models.DO_NOTHING, db_constraint=False) now I want to change id field for these models from int to bigint so I added to both id = models.BigAutoField(primary_key=True) and I did the migration, python manage.py sqlmigrate show something like this: BEGIN; -- -- Alter field id on allarme -- ALTER TABLE "multimedia_allarmi" ALTER COLUMN "id" TYPE bigint USING "id"::bigint; DROP SEQUENCE IF EXISTS "multimedia_allarmi_id_seq" CASCADE; CREATE SEQUENCE "multimedia_allarmi_id_seq"; ALTER TABLE "multimedia_allarmi" ALTER COLUMN "id" SET DEFAULT nextval('"multimedia_allarmi_id_seq"'); SELECT setval('"multimedia_allarmi_id_seq"', MAX("id")) FROM "multimedia_allarmi"; ALTER TABLE "multimedia_registrazioni" ALTER COLUMN "allarme_id" TYPE bigint USING "allarme_id"::bigint; *ALTER TABLE "multimedia_registrazioni" ADD CONSTRAINT "multimedia_registrazioni_allarme_id_4919213e_fk" FOREIGN KEY ("allarme_id") REFERENCES "multimedia_allarmi" ("id") DEFERRABLE INITIALLY DEFERRED;* -- -- Alter field id on registrazione -- ALTER TABLE "multimedia_registrazioni" ALTER COLUMN "id" TYPE bigint USING "id"::bigint; DROP SEQUENCE IF EXISTS "multimedia_registrazioni_id_seq" CASCADE; CREATE SEQUENCE "multimedia_registrazioni_id_seq"; ALTER TABLE "multimedia_registrazioni" ALTER COLUMN "id" SET DEFAULT nextval('"multimedia_registrazioni_id_seq"'); SELECT setval('"multimedia_registrazioni_id_seq"', MAX("id")) FROM "multimedia_registrazioni"; COMMIT; so as you can see a foreign key is added for a model field with db_constraint=False, can you please confirm that this is a bug? I'm using django 1.11.1 thanks! -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at https://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/18bafe5a-6cc0-412d-8e51-672b15f08325%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.