Opened 16 months ago

Closed 6 months ago

#22340 closed Bug (fixed)

Legacy Table Creation Methods Not Properly Deprecated

Reported by: mlavin Owned by: timgraham
Component: Migrations Version: master
Severity: Release blocker Keywords:
Cc: mmanfre@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

As noted in https://github.com/django/django/commit/1cb6729f58ef14c2042373d8bd61fa264a955705 and https://groups.google.com/d/msg/django-developers/PWPj3etj3-U/vH4DjnVttIUJ the DB backend DatabaseCreation class and the legacy path for table creating in the migrate command are being removed. DatabaseCreation is a documented part of the API in https://docs.djangoproject.com/en/1.6/topics/testing/advanced/#django-db-connection-creation and is still actively used in Django's code and test suite. For this to be deprecated per Django's published policy these should raise a deprecation warning when used prior to removal and currently neither do.

Change History (20)

comment:1 Changed 16 months ago by manfre

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 16 months ago by manfre

  • Cc mmanfre@… added

comment:3 Changed 15 months ago by akaariai

  • Component changed from Database layer (models, ORM) to Migrations

comment:4 Changed 15 months ago by timo

  • Version changed from 1.7-beta-1 to master

I'm going to change the version of this to master so we don't consider it a release blocker for 1.7. from Andrew in the django-dev thread:

"Yes, the test suite is basically the biggest obstacle to full usage of migrations - I've tried to make it see sense, but given my limited time at the moment and the fact that it's a tortuous mess of hacks in places it means that I can't see that happening before the RC.

I'd like to have started the Creation deprecation cycle this release, but it's probably fine if we let that slip a release (it's going to be harder to remove than many other features). Migrations will hopefully drive the adoption of SchemaEditor by developers and third-party backends anyway."

We'll need to update the deprecation timeline and 1.7 release at some point once this punt is confirmed for sure.

comment:5 Changed 14 months ago by Andrew Godwin <andrew@…>

In 61da5f3f02f34810aaa6fcddac3808318a5b95c4:

Bump DatabaseCreation deprecation to 2.0 (refs #22340)

comment:6 Changed 14 months ago by Tim Graham <timograham@…>

In 10327be1f3f9fed5dc40f6fe42e5494afcf7aa76:

[1.7.x] Bump DatabaseCreation deprecation to 2.0 (refs #22340)

Backport of 61da5f3f02 from master

comment:7 Changed 14 months ago by Tim Graham <timograham@…>

In a2e3c9694823d6d451d6dd234e9d416600aacc68:

Updated some docs for the delayed deprecation of legacy table creation; refs #22340.

comment:8 Changed 14 months ago by Tim Graham <timograham@…>

In af06203cead2968f4d58a718100dedc0faa7c619:

[1.7.x] Updated some docs for the delayed deprecation of legacy table creation; refs #22340.

Backport of a2e3c96948 from master

comment:9 Changed 14 months ago by giuliettamasina

I gather this ticket should be unmarked as release blocker for now, no?

comment:10 Changed 14 months ago by timo

The Trac UI isn't very intuitive, but it's a release blocker for 1.8 (currently master) as indicated by the "Version" flag.

comment:11 Changed 10 months ago by claudep

This pull request is aiming to move more DDL instructions go through schema editors, mainly migrate in sync_apps.
We'll also see what's the CI server thinks about that...
https://github.com/django/django/pull/3220

comment:12 Changed 6 months ago by Claude Paroz <claude@…>

In 30cbd5d360a2b8becdef7c6a0c939e0633a5468e:

Replaced DatabaseCreation sql methods by schema editor equivalents

Also used schema editor in migrate to sync unmigrated apps (sync_apps).
Refs #22340. Thanks Tim Graham for the review.

comment:13 Changed 6 months ago by timgraham

The remaining work for this ticket seems to be to replace the documented django.db.connection.creation methods (create_test_db() and destroy_test_db()) with a SchemaEditor equivalent. I think all of the DatabaseCreation methods that deal with generating SQL don't need to go through a deprecation cycle as they will be unused in Django 1.9 when support for apps without migrations is removed.

comment:14 Changed 6 months ago by Tim Graham <timograham@…>

In d7fc6eb8ca67a6a628e8c7ce669731cf563606e7:

Revert "Updated some docs for the delayed deprecation of legacy table creation; refs #22340."

This reverts commit a2e3c9694823d6d451d6dd234e9d416600aacc68.

The deprecation was moved back to 1.9 in
61da5f3f02f34810aaa6fcddac3808318a5b95c4.

comment:15 Changed 6 months ago by Tim Graham <timograham@…>

In 9311a94ca50ac86f9c945922c212c6e605d2d90a:

[1.7.x] Revert "Updated some docs for the delayed deprecation of legacy table creation; refs #22340."

The deprecation was moved back to 1.9 in
61da5f3f02f34810aaa6fcddac3808318a5b95c4.

Backport of d7fc6eb8ca67a6a628e8c7ce669731cf563606e7 from master

comment:16 Changed 6 months ago by timgraham

  • Has patch set
  • Owner changed from nobody to timgraham
  • Status changed from new to assigned

After looking at this some more, I am not sure there is an actual benefit or need to move the code that deals with test database creation and to remove the DatabaseCreation class. It seems to me to be a clear separation of concerns to keep this code where it is (after all, it deals with database creation).

If that rationale is accepted, the remaining cleanups are:

  1. Move the DatabaseCreation.data_types properties to DatabaseWrapper as proposed in pull request 3810.
  2. Remove the legacy SQL generation methods when support for apps without migrations is dropped in Django 1.9 (done in the commit "Removed obsolete SQL generation methods." commit of pull request 3791).
  3. Remove the note about DatabaseCreation from the deprecation timeline.

This will leave create_test_db(), destroy_test_db(), and their helper methods as the only functionality remaining on the DatabaseCreation class.

comment:17 Changed 6 months ago by Tim Graham <timograham@…>

In 93d73dac91104fd82d44b0dd4521cfa4f31e02aa:

Moved DatabaseCreation.data_types properties to DatabaseWrapper.

refs #22340.

comment:18 Changed 6 months ago by Tim Graham <timograham@…>

In 478d6a950361ef541ff40b51b7c04439647e0492:

Copied BaseDatabaseCreation._digest() to SchemaEditor to remove dependency.

refs #22340.

comment:19 Changed 6 months ago by claudep

OK with the plan. I'm just not sure if we really have to drop support for apps without migrations, but that's not the subject of this ticket.

comment:20 Changed 6 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In 09bce0b2cb6813e1b7acf184a1e26402736618a0:

Fixed #22340 -- Removed DatabaseCreation deprecation from timeline.

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