diff --git a/superset/migrations/versions/2024-03-04_14-48_efb7a20ff8d8_add_query_sql_editor_id_index.py b/superset/migrations/versions/2024-03-04_14-48_efb7a20ff8d8_add_query_sql_editor_id_index.py index 82f4f29cc5891..f79e0a7510dd1 100644 --- a/superset/migrations/versions/2024-03-04_14-48_efb7a20ff8d8_add_query_sql_editor_id_index.py +++ b/superset/migrations/versions/2024-03-04_14-48_efb7a20ff8d8_add_query_sql_editor_id_index.py @@ -31,7 +31,7 @@ from superset.migrations.shared.utils import table_has_index table = "query" -index = "ix_query_user_id_sql_editor_id" +index = "ix_sql_editor_id" def upgrade(): @@ -39,7 +39,7 @@ def upgrade(): op.create_index( op.f(index), table, - ["user_id", "sql_editor_id"], + ["sql_editor_id"], unique=False, ) diff --git a/superset/models/sql_lab.py b/superset/models/sql_lab.py index 8e5dd7d1d6ade..3655a44e9eb11 100644 --- a/superset/models/sql_lab.py +++ b/superset/models/sql_lab.py @@ -86,7 +86,7 @@ class Query( user_id = Column(Integer, ForeignKey("ab_user.id"), nullable=True) status = Column(String(16), default=QueryStatus.PENDING) tab_name = Column(String(256)) - sql_editor_id = Column(String(256)) + sql_editor_id = Column(String(256), index=True) schema = Column(String(256)) sql = Column(MediumText()) # Query to retrieve the results, @@ -128,10 +128,7 @@ class Query( ) user = relationship(security_manager.user_model, foreign_keys=[user_id]) - __table_args__ = ( - sqla.Index("ti_user_id_changed_on", user_id, changed_on), - sqla.Index("ix_query_user_id_sql_editor_id", user_id, sql_editor_id), - ) + __table_args__ = (sqla.Index("ti_user_id_changed_on", user_id, changed_on),) def get_template_processor(self, **kwargs: Any) -> BaseTemplateProcessor: return get_template_processor(query=self, database=self.database, **kwargs)