| 1 | |
| 2 | As discussed in the documentation[#foot1 (1)]: |
| 3 | - After syncdb, execute an ALTER TABLE statement to convert tables |
| 4 | {{{ |
| 5 | ALTER TABLE <tablename> ENGINE=INNODB; |
| 6 | }}} |
| 7 | - or, change settings to use the init_command option for MySQLdb: |
| 8 | {{{#!python |
| 9 | # settings.py |
| 10 | DATABASES = { |
| 11 | 'default': { |
| 12 | 'OPTIONS': { |
| 13 | # works because South changes table creation |
| 14 | 'init_command': 'SET storage_engine=INNODB', |
| 15 | } |
| 16 | } |
| 17 | } |
| 18 | }}} |
| 19 | - or, use post_syncdb trick listed in wiki:AlterModelOnSyncDB, |
| 20 | - or, create a management.py file along with your app, with: |
| 21 | {{{#!python |
| 22 | # management.py |
| 23 | from django.db import connection |
| 24 | # syncdb does "import_module('.management', app_name)" |
| 25 | # IOW, this gets executed before creating the tables. |
| 26 | connection.cursor().execute('SET storage_engine=InnoDB;') |
| 27 | }}} |
| 28 | - or, if you use South[#foot2 (2)] for migrations, with: |
| 29 | {{{#!python |
| 30 | # settings.py |
| 31 | DATABASES = { |
| 32 | 'default': { |
| 33 | 'STORAGE_ENGINE': 'INNODB' |
| 34 | } |
| 35 | } |
| 36 | }}} |
| 37 | - or, if you can, edit my.cnf |
| 38 | {{{ |
| 39 | # my.cnf |
| 40 | default-storage-engine=InnoDB |
| 41 | }}} |
| 42 | |
| 43 | * [=#foot1 (1)] https://docs.djangoproject.com/en/dev/ref/databases/#creating-your-tables |
| 44 | * [=#foot2 (2)] http://south.aeracode.org/docs/settings.html#mysql-storage-engine |