Skip to content

Commit

Permalink
Added indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
samhotep committed Jun 18, 2024
1 parent 985cbbe commit 3938c34
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
35 changes: 35 additions & 0 deletions migrations/versions/c27fec1bfee2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""empty message
Revision ID: c27fec1bfee2
Revises: f18a0bd8a809
Create Date: 2024-06-14 18:33:53.519236
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "c27fec1bfee2"
down_revision = "f18a0bd8a809"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_index(
"notices_published_desc_idx",
"notice",
[sa.text("published DESC")],
unique=False,
)
op.create_index(
"notices_published_idx", "notice", ["published"], unique=False
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index("notices_published_idx", table_name="notice")
op.drop_index("notices_published_desc_idx", table_name="notice")
# ### end Alembic commands ###
5 changes: 5 additions & 0 deletions webapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Enum,
Float,
ForeignKey,
Index,
JSON,
String,
Table,
Expand Down Expand Up @@ -162,6 +163,10 @@ class Notice(db.Model):
order_by="desc(Release.release_date)",
back_populates="notices",
)
notices_published_idx = Index("notices_published_idx", published)
notices_published_desc_idx = Index(
"notices_published_desc_idx", published.desc()
)

@hybrid_property
def cves_ids(self):
Expand Down

0 comments on commit 3938c34

Please sign in to comment.