﻿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
33773	DEFAULT_INDEX_TABLESPACE setting is ignored for Indexes defined with multiple fields.	Bruce Cutler	Bruce Cutler	"Tested with Postgresql backend, Django versions 3.2 & 4.0

Defining an Index in the Meta of a model ignores the DEFAULT_INDEX_TABLESPACE setting if multiple fields are used for the index.
The setting is honoured if only a single field defines the index.

Example case, with a postgresql DB defined in settings, as well as:
{{{
DEFAULT_TABLESPACE = 'data_ts'
DEFAULT_INDEX_TABLESPACE = 'index_ts'
}}}

The below model definition:
{{{
class MyModel(models.Model):
    foo = models.CharField(max_length=10)
    bar = models.CharField(max_length=10)

    class Meta:
        indexes = [
            models.Index(fields=['foo']),
            models.Index(fields=['foo', 'bar']),
        ]
}}}
generates this output from management command {{{sqlmigrate}}} run on the produced migration:
{{{
BEGIN;
--
-- Create model MyModel
--
CREATE TABLE ""cbcap_mymodel"" (""id"" bigserial NOT NULL PRIMARY KEY USING INDEX TABLESPACE ""index_ts"", ""foo"" varchar(10) NOT NULL, ""bar"" varchar(10) NOT NULL) TABLESPACE ""data_ts"";
--
-- Create index cbcap_mymod_foo_f01529_idx on field(s) foo of model mymodel
--
CREATE INDEX ""cbcap_mymod_foo_f01529_idx"" ON ""cbcap_mymodel"" (""foo"") TABLESPACE ""index_ts"";
--
-- Create index cbcap_mymod_foo_44bcd6_idx on field(s) foo, bar of model mymodel
--
CREATE INDEX ""cbcap_mymod_foo_44bcd6_idx"" ON ""cbcap_mymodel"" (""foo"", ""bar"") TABLESPACE ""data_ts"";
COMMIT;
}}}
Note the 'data_ts' tablespace is used for the second index"	Bug	closed	Migrations	4.0	Normal	fixed			Ready for checkin	1	0	0	0	0	0
