#34131: Postgres AutoField change from serial to identity
-------------------------------------+-------------------------------------
               Reporter:  Marco      |          Owner:  nobody
  Glauser                            |
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  4.1
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 With django 4.1 the following change was added (#30511):
   On PostgreSQL, AutoField, BigAutoField, and SmallAutoField are now
 created as identity columns rather than serial columns with sequences.

 This causes issues for us because our migrations depend on sequences being
 created by the BigAutoField.

 We use Luhn's algorithm to generate ids that are harder to mistype by
 accident. The easiest way for us to do that is to change the default of
 the id column.

 {{{
 ALTER TABLE invoice_invoice ALTER COLUMN id SET DEFAULT
 luhn_generate(nextval('invoice_invoice_id_seq'));
 }}}

 This no longer works with 4.1 and we get the following error when trying
 to apply the migration (for example when running tests)

 {{{
 django.db.utils.ProgrammingError: column "id" of relation
 "invoice_invoice" is an identity column
 }}}

 Already migrated databases continue to work as expected.
 This is currently blocking our upgrade path to 4.1 since we cannot run our
 unit tests.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34131>
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/0107018436566f0d-432e206f-09b8-4bc7-b7ab-83986c8ddd16-000000%40eu-central-1.amazonses.com.

Reply via email to