diff --git a/flask_appbuilder/security/sqla/models.py b/flask_appbuilder/security/sqla/models.py index 680aff6a5f..74ca579bd1 100755 --- a/flask_appbuilder/security/sqla/models.py +++ b/flask_appbuilder/security/sqla/models.py @@ -6,6 +6,7 @@ Column, DateTime, ForeignKey, + Index, Integer, Sequence, String, @@ -52,6 +53,8 @@ def __repr__(self): Column("permission_view_id", Integer, ForeignKey("ab_permission_view.id")), Column("role_id", Integer, ForeignKey("ab_role.id")), UniqueConstraint("permission_view_id", "role_id"), + Index("idx_permission_view_id", "permission_view_id"), + Index("idx_role_id", "role_id"), ) @@ -72,7 +75,11 @@ def __repr__(self): class PermissionView(Model): __tablename__ = "ab_permission_view" - __table_args__ = (UniqueConstraint("permission_id", "view_menu_id"),) + __table_args__ = ( + UniqueConstraint("permission_id", "view_menu_id"), + Index("idx_permission_id", "permission_id"), + Index("idx_view_menu_id", "view_menu_id"), + ) id = Column(Integer, Sequence("ab_permission_view_id_seq"), primary_key=True) permission_id = Column(Integer, ForeignKey("ab_permission.id")) permission = relationship("Permission", lazy="joined")