Skip to content
This repository has been archived by the owner on Apr 14, 2024. It is now read-only.

Speed up get positions #247

Merged
merged 3 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions sapphire/database/migrations/versions/891640b6839e_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ def upgrade() -> None:
postgresql_using="hash")
op.create_index("positions__specialization_id_idx", "positions", ["specialization_id"],
unique=False, postgresql_using="hash")
op.create_index("positions__created_at_idx", "positions", ["created_at"],
unique=False, postgresql_using="btree")
op.create_table("profiles",
sa.Column("user_id", sa.Uuid(), nullable=False),
sa.Column("about", sa.Text(), nullable=True),
Expand All @@ -161,6 +163,8 @@ def upgrade() -> None:
)
op.create_index("projects_history__project_id_idx", "projects_history", ["project_id"],
unique=False, postgresql_using="hash")
op.create_index("projects_history__created_at_idx", "projects_history", ["created_at"],
unique=False, postgresql_using="btree")
op.create_table("reviews",
sa.Column("id", sa.Uuid(), nullable=False),
sa.Column("project_id", sa.Uuid(), nullable=False),
Expand Down Expand Up @@ -218,6 +222,8 @@ def upgrade() -> None:

def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
bind = op.get_bind()

op.drop_index("positions_skills__skill_id_idx", table_name="positions_skills",
postgresql_using="hash")
op.drop_index("positions_skills__position_id_idx", table_name="positions_skills",
Expand All @@ -229,13 +235,17 @@ def downgrade() -> None:
op.drop_index("participants__position_id_idx", table_name="participants",
postgresql_using="hash")
op.drop_table("participants")
if bind.engine.name == "postgresql":
op.execute("DROP TYPE participantstatusenum")
op.drop_index("reviews__to_user_id_idx", table_name="reviews", postgresql_using="hash")
op.drop_index("reviews__project_id_idx", table_name="reviews", postgresql_using="hash")
op.drop_index("reviews__from_user_id_idx", table_name="reviews", postgresql_using="hash")
op.drop_table("reviews")
op.drop_index("projects_history__project_id_idx", table_name="projects_history",
postgresql_using="hash")
op.drop_table("projects_history")
if bind.engine.name == "postgresql":
op.execute("DROP TYPE projectstatusenum")
op.drop_table("profiles")
op.drop_index("positions__specialization_id_idx", table_name="positions",
postgresql_using="hash")
Expand Down
2 changes: 2 additions & 0 deletions sapphire/database/models/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class ProjectHistory(Base):

__table_args__ = (
Index("projects_history__project_id_idx", "project_id", postgresql_using="hash"),
Index("projects_history__created_at_idx", "created_at", postgresql_using="btree"),
)


Expand Down Expand Up @@ -119,6 +120,7 @@ class Position(Base):
Index("positions__project_id_idx", "project_id", postgresql_using="hash"),
Index("positions__specialization_id_idx", "specialization_id",
postgresql_using="hash"),
Index("positions__created_at_idx", "created_at", postgresql_using="btree"),
)


Expand Down