Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #363 - django-admin sqlall now uses database-specific initial d…

…ata files if they exist.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@735 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 151b44c89a6c53bc5e312fd84afeedffb23a0e94 1 parent 022a03a
Jacob Kaplan-Moss jacobian authored
Showing with 12 additions and 1 deletion.
  1. +12 −1 django/core/management.py
13 django/core/management.py
View
@@ -163,7 +163,18 @@ def get_sql_initial_data(mod):
for klass in mod._MODELS:
opts = klass._meta
# Add custom SQL, if it's available.
- sql_file_name = os.path.join(app_dir, opts.module_name + '.sql')
+ from django.core import db
+
+ # Get the sql file name for the init data for the current database engine
+ db_engine_sql_file_name = os.path.join(app_dir, opts.module_name + '.' + db.DATABASE_ENGINE.lower() + '.sql')
+
+ # Check if the data specific file exists
+ if os.path.exists(db_engine_sql_file_name):
+ sql_file_name = db_engine_sql_file_name
+ # if the database specific file doesn't exist, use the database agnostic version
+ else:
+ sql_file_name = os.path.join(app_dir, opts.module_name + '.sql')
+
if os.path.exists(sql_file_name):
fp = open(sql_file_name, 'r')
output.append(fp.read())
Please sign in to comment.
Something went wrong with that request. Please try again.