For that I have another approach I took, I modified the settings file & added in Meta an option. To give you an idea here's the patch against Revision: 5773.
# use a consistant MySQL storage type for all apps, all models
Index: django/db/models/options.py
===================================================================
--- django/db/models/options.py (revision 5773)
+++ django/db/models/options.py (working copy)
@@ -15,7 +15,7 @@
DEFAULT_NAMES = ('verbose_name', 'db_table', 'ordering',
'unique_together', 'permissions', 'get_latest_by',
- 'order_with_respect_to', 'app_label', 'db_tablespace')
+ 'order_with_respect_to', 'app_label', 'db_tablespace', 'db_storage_engine')
class Options(object):
def __init__(self, meta):
@@ -30,6 +30,7 @@
self.get_latest_by = None
self.order_with_respect_to = None
self.db_tablespace = None
+ self.db_storage_engine = None
self.admin = None
self.meta = meta
self.pk = None
Index: django/db/backends/mysql/base.py
===================================================================
--- django/db/backends/mysql/base.py (revision 5773)
+++ django/db/backends/mysql/base.py (working copy)
@@ -141,6 +141,7 @@
needs_upper_for_iops = False
supports_constraints = True
supports_tablespaces = False
+supports_storage_engines = True
uses_case_insensitive_names = False
def quote_name(name):
@@ -207,6 +208,9 @@
def get_autoinc_sql(table):
return None
+def get_storageengine_sql(engine):
+ return "ENGINE = %s" % engine
+
def get_sql_flush(style, tables, sequences):
"""Return a list of SQL statements required to remove all data from
all tables in the database (without actually removing the tables
Index: django/core/management.py
===================================================================
--- django/core/management.py (revision 5773)
+++ django/core/management.py (working copy)
@@ -153,6 +153,7 @@
Returns list_of_sql, pending_references_dict
"""
from django.db import backend, models
+ from django.conf import settings
opts = model._meta
final_output = []
@@ -203,6 +204,9 @@
full_statement.append(')')
if opts.db_tablespace and backend.supports_tablespaces:
full_statement.append(backend.get_tablespace_sql(opts.db_tablespace))
+ if backend.supports_storage_engines:
+ storage = opts.db_storage_engine or settings.DATABASE_STORAGE_ENGINE
+ full_statement.append(backend.get_storageengine_sql(storage))
full_statement.append(';')
final_output.append('\n'.join(full_statement))
For brevity's sake, Only works for SQL here, other backends would need to simply set the supports_storage_engines = False.
If enough interest arises, I can modify that into a proper patch against HEAD