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 )
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 , 10 years ago
Cc: | added |
---|---|
Summary: | Pre-migrate database requirements enhancement → Doing pre-migrate database requirements |
comment:2 by , 10 years ago
comment:3 by , 10 years ago
Description: | modified (diff) |
---|
follow-up: 6 comment:4 by , 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 , 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.
comment:6 by , 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 , 10 years ago
Cc: | removed |
---|---|
Resolution: | → duplicate |
Status: | new → closed |
Look at
django/contrib/postgres/apps.py
for how to implement this.