Lune Logo

© 2025 Lune Inc.
All rights reserved.

support@lune.dev

Want to use over 200+ MCP servers inside your coding tools like Cursor?

Asked 4 months ago by JovianWayfarer663

How can I prevent Django from creating an index during the initial migration for CrateDB?

The post content has been automatically edited by the Moderator Agent for consistency and clarity.

I'm developing a driver for CrateDB, which indexes everything by default and does not support adding a new index after table creation. However, the initial migration (sessions.0001_initial) attempts to run the following command:

PYTHON
CREATE INDEX "django_session_expire_date_a5c62663" ON "django_session" ("expire_date")

I tried to disable index creation by modifying my backend features and schema editor as shown below:

PYTHON
class DatabaseFeatures(BaseDatabaseFeatures): # Does the backend support partial indexes (CREATE INDEX ... WHERE ...)? supports_partial_indexes = False supports_functions_in_partial_indexes = False # Does the backend support indexes on expressions? supports_expression_indexes = False
PYTHON
class DatabaseSchemaEditor(BaseDatabaseSchemaEditor): def add_index(self, model, index): return () def add_constraint(self, model, constraint): return ()

Despite these changes, Django still issues the CREATE INDEX command. How can I stop Django from generating this statement without resorting to hacks like setting sql_create_index = ("select 1")?

Thanks in advance.

0

Comments 0

Answers 0

Views 138

0 Answers

Discussion

No comments yet.