tickets: 4528
This data as json
id | created | changetime | last_pulled_from_trac | stage | status | component | type | severity | version | resolution | summary | description | owner | reporter | keywords | easy | has_patch | needs_better_patch | needs_tests | needs_docs | ui_ux |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4528 | 2007-06-11 08:54:18 | 2012-01-18 21:06:03 | 2022-03-06 03:31:42.135490 | Accepted | closed | Core (Management commands) | New feature | Normal | dev | wontfix | Add DATABASE_PRE_SYNCDB to settings | 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 [http://code.djangoproject.com/ticket/347 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.[[BR]] Here's a "real world" example: {{{ #!python 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. | Johan Bergström <bugs@bergstroem.nu> | database_pre_syncdb sql syncdb | 1 | 1 | 0 | 0 | 0 | 0 |