Opened 17 years ago
Closed 13 years ago
#4528 closed New feature (wontfix)
Add DATABASE_PRE_SYNCDB to settings
Reported by: | Owned by: | ||
---|---|---|---|
Component: | Core (Management commands) | Version: | dev |
Severity: | Normal | Keywords: | database_pre_syncdb sql syncdb |
Cc: | Silver_Ghost | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
DATABASE_PRE_SYNCDB is a way of letting users execute SQL before tables are created (for instance through syncdb).
The main reason for this is users which don't have control over their db - in practise, no rights to set default modes (which has been brought up earlier). This would allow users to set the "correct" charset and storage engine for his/her tables.
Another useful feature is that django now has the possibility to create a database.
Here's a "real world" example:
DATABASE_PRE_SYNCDB = ( "CREATE DATABASE IF NOT EXISTS %s" % DATABASE_NAME, "SET storage_engine=INNODB", )
Alternative approaches to this has been suggested, such as:
- Alter tables after the table has been created (refs: wiki:AlterModelOnSyncDB)
- Export SQL, modify and import manually
I personally think this implementation is cleaner and allows greater flexibility.
Attachments (4)
Change History (18)
by , 17 years ago
Attachment: | pre_syncdb_sql_hook.patch added |
---|
comment:1 by , 17 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
follow-up: 3 comment:2 by , 17 years ago
If we're going allow modifications before all the sync activities, why not just create a pre_syncdb signal. That way it won't be yet another setting to clutter the 99% case, but people could easily add the dispatcher to a management.py in their own app.
Or, with the new management refactor, maybe a user should just add their own command entirely, and have their command call the syncdb command?
comment:3 by , 17 years ago
Replying to George Vilches <gav@thataddress.com>:
If we're going allow modifications before all the sync activities, why not just create a pre_syncdb signal. That way it won't be yet another setting to clutter the 99% case, but people could easily add the dispatcher to a management.py in their own app.
Or, with the new management refactor, maybe a user should just add their own command entirely, and have their command call the syncdb command?
I like both of these ideas. Feel like writing up an implementation of one of them?
by , 17 years ago
Attachment: | db_pre_sync_r6799.patch added |
---|
comment:5 by , 17 years ago
Triage Stage: | Design decision needed → Accepted |
---|
comment:7 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:8 by , 13 years ago
Component: | Core (Other) → Core (Management commands) |
---|---|
Easy pickings: | unset |
Needs documentation: | set |
UI/UX: | unset |
comment:9 by , 13 years ago
Needs tests: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:10 by , 13 years ago
Cc: | added |
---|
comment:11 by , 13 years ago
Easy pickings: | set |
---|---|
Needs tests: | unset |
Patch needs improvement: | unset |
I put tests in regressiontests/syncdb
according to advice from Russell.
comment:13 by , 13 years ago
Needs documentation: | unset |
---|---|
Owner: | removed |
Status: | assigned → new |
Added send of pre_syncdb
signal in flush
command and documentation. Documentation probably is not good enough but I can't write better because of my poor English.
comment:14 by , 13 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
It seems like this ticket has been hijacked for a different purpose. I'm wontfixing the idea of a DATABASE_PRE_SYNCDB
setting, but not a pre_syncdb signal.
We have ticket #11398 to track that, I'll move Silver_Ghost's patch there.
database_pre_syncdb patch