#30511: Support Identity columns on PostgreSQL.
-------------------------------------+-------------------------------------
     Reporter:  Michael Kany         |                    Owner:  Michael
                                     |  Kany
         Type:  New feature          |                   Status:  assigned
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  postgres generated   |             Triage Stage:  Accepted
  identity                           |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

 Michael, I haven't look into all the details but I'm confident you'll have
 to at least change the following

 1.
 
https://github.com/django/django/blob/76b993a117b61c41584e95149a67d8a1e9f49dd1/django/db/backends/postgresql/base.py#L74-L75
 (not that you want `bigint GENERATED ...` for `BigAutoField`).
 2. You'll probably have to adjust introspection logic and tests to have
 both `serial` and `int GENERATED ...` map to `AutoField` and do the same
 for the `bigserial` and `BigAutoField`.
 3. You might have to adjust some migration code as I see
 
[https://github.com/django/django/blob/1378d665a1c85897d951f2ca9618b848fdbba2e7/django/db/backends/postgresql/schema.py#L9-L10
 it performs some sequence creation and deletion]. I guess you'll have to
 change the `create_sequence` usage in `_alter_column_type_sql` to use
 `ALTER COLUMN %(column) ADD GENERATED BY DEFAULT AS IDENTITY` on
 PostgreSQL 10+. Note at in this particular case I think we should keep
 dropping the sequence using `DROP SEQUENCE IF EXISTS ... CASCADE` even on
 PostgreSQL 10+ at least for one release after we drop support for
 PostgreSQL < 10 to avoid orphaning sequences during Django and PostgreSQL
 upgrades.

 That should get you started :)

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30511#comment:13>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.8fa74d06520470f34149c378c2f02802%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to