[Django] #29377: DatabaseSchemaEditor: add a hook to run DML statements after the entire schema is created

20 views
Skip to first unread message

Django

unread,
May 2, 2018, 3:04:04 PM5/2/18
to django-...@googlegroups.com
#29377: DatabaseSchemaEditor: add a hook to run DML statements after the entire
schema is created
-----------------------------------------------+------------------------
Reporter: Maximiliano Robaina | Owner: nobody
Type: New feature | Status: new
Component: Migrations | Version: 2.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------------+------------------------
This feature request is to better support of third-party database
backends.
In my case (Firebird SQL) to add a new field on already existing and
populated table is not enough set and drop a default value, we need to
update the new field with efective default value. It is not possible
without commit the schema alteration.
An aproach could be to have a kind of hook to run sql statements (DML
statement in this case) when the schema altereation finished (and
commited). Of course, must bu runned in another transaction.

--
Ticket URL: <https://code.djangoproject.com/ticket/29377>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 2, 2018, 9:35:55 PM5/2/18
to django-...@googlegroups.com
#29377: DatabaseSchemaEditor: add a hook to run DML statements after the entire
schema is created
-------------------------------------+-------------------------------------

Reporter: Maximiliano Robaina | Owner: nobody
Type: New feature | Status: new
Component: Migrations | Version: 2.0
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

Did you forgot about #26399 that you created or is this is a different
issue?

--
Ticket URL: <https://code.djangoproject.com/ticket/29377#comment:1>

Django

unread,
May 3, 2018, 9:39:08 AM5/3/18
to django-...@googlegroups.com
#29377: DatabaseSchemaEditor: add a hook to run DML statements after the entire
schema is created
-------------------------------------+-------------------------------------

Reporter: Maximiliano Robaina | Owner: nobody
Type: New feature | Status: new
Component: Migrations | Version: 2.0
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Maximiliano Robaina):

Tim,

It's a different issue. May be I need to write It better.
In this case is just for run a DML statement after all migrations were
applied (and commited). About change of defaults values that I mencioned
is just an uses case.

--
Ticket URL: <https://code.djangoproject.com/ticket/29377#comment:2>

Django

unread,
May 3, 2018, 9:43:54 AM5/3/18
to django-...@googlegroups.com
#29377: DatabaseSchemaEditor: add a hook to run DML statements after the entire
schema is created
-------------------------------------+-------------------------------------

Reporter: Maximiliano Robaina | Owner: nobody
Type: New feature | Status: new
Component: Migrations | Version: 2.0
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Maximiliano Robaina):

* cc: Maximiliano Robaina (added)


Old description:

> This feature request is to better support of third-party database
> backends.
> In my case (Firebird SQL) to add a new field on already existing and
> populated table is not enough set and drop a default value, we need to
> update the new field with efective default value. It is not possible
> without commit the schema alteration.
> An aproach could be to have a kind of hook to run sql statements (DML
> statement in this case) when the schema altereation finished (and
> commited). Of course, must bu runned in another transaction.

New description:

A nice option would be to have a hook to run DML statements after all
migrations were applied and commited.

A uses case (for example in Firebird SQL) is to add a new field on
already existing and populated table. Is not enough set and drop a default


value, we need to update the new field with efective default value. It is
not possible without commit the schema alteration.
An aproach could be to have a kind of hook to run sql statements (DML
statement in this case) when the schema altereation finished (and
commited). Of course, must bu runned in another transaction.

This feature request is to better support of third-party database
backends.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/29377#comment:3>

Django

unread,
May 4, 2018, 8:24:41 AM5/4/18
to django-...@googlegroups.com
#29377: DatabaseSchemaEditor: add a hook to run DML statements after the entire
schema is created
-------------------------------------+------------------------------------

Reporter: Maximiliano Robaina | Owner: nobody
Type: New feature | Status: new
Component: Migrations | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/29377#comment:4>

Django

unread,
Oct 25, 2019, 8:34:27 AM10/25/19
to django-...@googlegroups.com
#29377: DatabaseSchemaEditor: add a hook to run DML statements after the entire
schema is created
-------------------------------------+------------------------------------

Reporter: Maximiliano Robaina | Owner: nobody
Type: New feature | Status: closed
Component: Migrations | Version: 2.0
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Changes (by Simon Charette):

* status: new => closed
* cc: Simon Charette (added)
* resolution: => wontfix


Comment:

Any reason why a `post_migrate` receiver cannot be used for this purpose?

The schema editor and migration logic are decoupled for a good reason and
adding such a hook would introduce bidirectional coupling between the two
components.

I'll close as ''wontfix'' for the above reasons.

--
Ticket URL: <https://code.djangoproject.com/ticket/29377#comment:5>

Reply all
Reply to author
Forward
0 new messages