Code

Ticket #363: managment.py.diff

File managment.py.diff, 1.0 KB (added by slashzero, 9 years ago)

patch for change

Line 
1Index: management.py
2===================================================================
3--- management.py       (revision 535)
4+++ management.py       (working copy)
5@@ -165,7 +165,18 @@
6     for klass in mod._MODELS:
7         opts = klass._meta
8         # Add custom SQL, if it's available.
9-        sql_file_name = os.path.join(app_dir, opts.module_name + '.sql')
10+        from django.core import db
11+       
12+        # Get the sql file name for the init data for the current database engine
13+        db_engine_sql_file_name = os.path.join(app_dir, opts.module_name + '.' + db.DATABASE_ENGINE.lower() +  '.sql')
14+
15+        # Check if the data specific file exists
16+        if os.path.exists(db_engine_sql_file_name):
17+            sql_file_name = db_engine_sql_file_name
18+        # if the database specific file doesn't exist, use the database agnostic version
19+        else:
20+            sql_file_name = os.path.join(app_dir, opts.module_name + '.sql')
21+
22         if os.path.exists(sql_file_name):
23             fp = open(sql_file_name, 'r')
24             output.append(fp.read())