Opened 6 years ago

Closed 6 years ago

Last modified 22 months ago

#30060 closed Cleanup/optimization (fixed)

Improve extensibility of schema migration for custom backends for new Index/Check/Unique and other constraints

Reported by: Pavel Tyslacki Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

New in django 2.2 Index condition https://code.djangoproject.com/ticket/29547 and Check/Unique constraints https://code.djangoproject.com/ticket/29641 are a very useful, but have a some issues with extensibility by custom backends:

  • sql generation for migrations splitted to schema and indexes/constraints modules, but custom backend for indexes/constraints modules don't appliable
  • schema logic can be improved for extensibility to avoid huge overriding as _alter_field method

to fix it proposed:

  • move sql generation from Index/CheckConstraint/UniqueConstraint to schema methods (similar to _create_index_sql)
  • provide methods for sql generation for index/unique/primary key/foreign key/check constraints

Change History (4)

comment:1 by Simon Charette, 6 years ago

Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization
Last edited 6 years ago by Tim Graham (previous) (diff)

comment:2 by Simon Charette, 6 years ago

Triage Stage: AcceptedReady for checkin

comment:3 by Tim Graham <timograham@…>, 6 years ago

Resolution: fixed
Status: newclosed

In 0123b67:

Fixed #30060 -- Moved SQL generation for indexes and constraints to SchemaEditor.

comment:4 by GitHub <noreply@…>, 22 months ago

In 16c966ff:

Refs #30060, Refs #34217 -- Made SchemaEditor not generate SQL for CheckConstraint if not supported.

The new logic mirrors the logic in SchemaEditor._delete_check_sql()
added in 68ef274bc505cd44f305c03cbf84cf08826200a8.

Thanks Tim Graham for the report.

Note: See TracTickets for help on using tickets.
Back to Top