﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
22898	Specify backend name for custom SQL	shaung	nobody	"
'''The problem:'''

Say I have a model named `AwesomeModel` which is managed but several functions need to be created along with the table.

So I created a `awesomemodel.sql` and put all the DDLs in it. In this way when running unittests the functions get created without problem.

Now as there are multiple DB backends defined in the `settings`, I'd like the custom SQL run only for the `default` DB but not for `another_schema`:


{{{
DATABASES = {
     ""default"": {
         ""ENGINE"": ""django_pyodbc"",
         # ...
     },
     ""another_schema"": {
         ""ENGINE"": ""django_pyodbc"",
         # ...
     }
}
}}}


It seems that custom SQLs can be specified to be executed for certain engines:

https://github.com/django/django/blob/master/django/core/management/sql.py#L221


{{{
    # Find custom SQL, if it's available.
    backend_name = connection.settings_dict['ENGINE'].split('.')[-1]

}}}

But for multiple backends that use the same engine, there is no way to distinguish from them.

So changing the file name to `model_name.django_pyodbc.sql` does not solve this problem.


'''Suggestion:'''

Add a new file custom SQL file name pattern to allow specify the target backend by backend name:

     `<Model Name>.<Engine Name>.<Backend Name>.sql`

(In my case it would be `awesomemodel.django_pyodbc.default.sql`)"	New feature	closed	Core (Management commands)	dev	Normal	wontfix	custom sql		Unreviewed	0	0	0	0	0	0
