Opened 10 years ago

Closed 10 years ago

#23966 closed Cleanup/optimization (duplicate)

Doing pre-migrate database requirements

Reported by: Kenial Sookyum Lee Owned by: nobody
Component: Database layer (models, ORM) Version: 1.7
Severity: Normal Keywords: migrate BaseDatabaseWrapper spatialite
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Kenial Sookyum Lee)

Some database backends has special requirements when the database gets migrated.

For example, when using django.contrib.gis.db.backends.spatialite as a backend, the database file should be initialized at first time with this command: "SELECT InitSpatialMetaData();" Unless, it causes some error like https://code.djangoproject.com/ticket/20968.

I guess this would be appropriate: adding a before_migration() method to DatabaseWrapper, and letting database backends inherit it to do some jobs.

New workaround codes are added to django/contrib/gis/apps.py. (Thanks @aaugustin!)

Pull request link: https://github.com/django/django/pull/3695

Change History (7)

comment:1 by Kenial Sookyum Lee, 10 years ago

Cc: keniallee@… added
Summary: Pre-migrate database requirements enhancementDoing pre-migrate database requirements

comment:2 by Aymeric Augustin, 10 years ago

Look at django/contrib/postgres/apps.py for how to implement this.

comment:3 by Kenial Sookyum Lee, 10 years ago

Description: modified (diff)

comment:4 by Claude Paroz, 10 years ago

Seems we have parallely worked on the same issue with two different approaches (#20968 reopened with https://github.com/django/django/pull/3697). Should we close this ticket now?

comment:5 by Kenial Sookyum Lee, 10 years ago

Perhaps ... if InitSpatialMetaData query is executed in init_connection_state() method, then it will check it every time when opening a connection. As you know, there is no connection pooling on sqlite3 (and SpatiaLite) by default. It means that every query will execute PRAGMA table_info(geometry_columns);, I don't think it's a right way.

How about merging document stuff from pull request ​https://github.com/django/django/pull/3697 into mine? I forgot to update document about this.

Last edited 10 years ago by Kenial Sookyum Lee (previous) (diff)

in reply to:  4 comment:6 by Kenial Sookyum Lee, 10 years ago

Replying to claudep:
Okay claudep, I will close this ticket. But as I commented, there is a possible issue on your code, so I'm gonna move my opinion on your ticket.

comment:7 by Kenial Sookyum Lee, 10 years ago

Cc: keniallee@… removed
Resolution: duplicate
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top