Skip to content

Commit d1e1f4e

Browse files
authored
Merge branch 'master' into mai/error-dumps
2 parents 7e8a66f + e11ff32 commit d1e1f4e

File tree

14 files changed

+326
-210
lines changed

14 files changed

+326
-210
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
"""add indexes
2+
3+
Revision ID: cf8f743fd0b7
4+
Revises: 48604dfdc5f4
5+
Create Date: 2025-04-04 09:46:38.853675+00:00
6+
7+
"""
8+
9+
import sqlalchemy as sa
10+
from alembic import op
11+
12+
# revision identifiers, used by Alembic.
13+
revision = "cf8f743fd0b7"
14+
down_revision = "48604dfdc5f4"
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
# ### commands auto generated by Alembic - please adjust! ###
21+
op.create_index(
22+
"idx_project_to_groups_gid", "project_to_groups", ["gid"], unique=False
23+
)
24+
op.create_index(
25+
"idx_projects_last_change_date_desc",
26+
"projects",
27+
["last_change_date"],
28+
unique=False,
29+
postgresql_using="btree",
30+
postgresql_ops={"last_change_date": "DESC"},
31+
)
32+
op.create_index(
33+
"ix_projects_partial_type",
34+
"projects",
35+
["type"],
36+
unique=False,
37+
postgresql_where=sa.text("type = 'TEMPLATE'"),
38+
)
39+
op.create_index(
40+
"idx_project_to_folders_project_uuid",
41+
"projects_to_folders",
42+
["project_uuid"],
43+
unique=False,
44+
)
45+
op.create_index(
46+
"idx_project_to_folders_user_id",
47+
"projects_to_folders",
48+
["user_id"],
49+
unique=False,
50+
)
51+
op.create_index(
52+
"idx_projects_to_products_product_name",
53+
"projects_to_products",
54+
["product_name"],
55+
unique=False,
56+
)
57+
op.create_index(
58+
"idx_workspaces_access_rights_gid",
59+
"workspaces_access_rights",
60+
["gid"],
61+
unique=False,
62+
)
63+
# ### end Alembic commands ###
64+
65+
66+
def downgrade():
67+
# ### commands auto generated by Alembic - please adjust! ###
68+
op.drop_index(
69+
"idx_workspaces_access_rights_gid", table_name="workspaces_access_rights"
70+
)
71+
op.drop_index(
72+
"idx_projects_to_products_product_name", table_name="projects_to_products"
73+
)
74+
op.drop_index("idx_project_to_folders_user_id", table_name="projects_to_folders")
75+
op.drop_index(
76+
"idx_project_to_folders_project_uuid", table_name="projects_to_folders"
77+
)
78+
op.drop_index(
79+
"ix_projects_partial_type",
80+
table_name="projects",
81+
postgresql_where=sa.text("type = 'TEMPLATE'"),
82+
)
83+
op.drop_index(
84+
"idx_projects_last_change_date_desc",
85+
table_name="projects",
86+
postgresql_using="btree",
87+
postgresql_ops={"last_change_date": "DESC"},
88+
)
89+
op.drop_index("idx_project_to_groups_gid", table_name="project_to_groups")
90+
# ### end Alembic commands ###

packages/postgres-database/src/simcore_postgres_database/models/project_to_groups.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,5 @@
6060
column_created_datetime(timezone=True),
6161
column_modified_datetime(timezone=True),
6262
sa.UniqueConstraint("project_uuid", "gid"),
63+
sa.Index("idx_project_to_groups_gid", "gid"),
6364
)

packages/postgres-database/src/simcore_postgres_database/models/projects.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
""" Projects table
1+
"""Projects table"""
22

3-
"""
43
import enum
54

65
import sqlalchemy as sa
@@ -171,6 +170,20 @@ class ProjectType(enum.Enum):
171170
server_default=sa.text("'{}'::jsonb"),
172171
doc="DEPRECATED: Read/write/delete access rights of each group (gid) on this project",
173172
),
173+
### INDEXES ----------------------------
174+
sa.Index(
175+
"idx_projects_last_change_date_desc",
176+
"last_change_date",
177+
postgresql_using="btree",
178+
postgresql_ops={"last_change_date": "DESC"},
179+
),
180+
)
181+
182+
# We define the partial index
183+
sa.Index(
184+
"ix_projects_partial_type",
185+
projects.c.type,
186+
postgresql_where=(projects.c.type == ProjectType.TEMPLATE),
174187
)
175188

176189

packages/postgres-database/src/simcore_postgres_database/models/projects_to_folders.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@
4242
column_created_datetime(timezone=True),
4343
column_modified_datetime(timezone=True),
4444
sa.UniqueConstraint("project_uuid", "folder_id", "user_id"),
45+
sa.Index("idx_project_to_folders_project_uuid", "project_uuid"),
46+
sa.Index("idx_project_to_folders_user_id", "user_id"),
4547
)

packages/postgres-database/src/simcore_postgres_database/models/projects_to_products.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@
3434
column_created_datetime(timezone=False),
3535
column_modified_datetime(timezone=False),
3636
sa.UniqueConstraint("project_uuid", "product_name"),
37+
sa.Index("idx_projects_to_products_product_name", "product_name"),
3738
)

packages/postgres-database/src/simcore_postgres_database/models/workspaces_access_rights.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,5 @@
5757
column_created_datetime(timezone=True),
5858
column_modified_datetime(timezone=True),
5959
sa.UniqueConstraint("workspace_id", "gid"),
60+
sa.Index("idx_workspaces_access_rights_gid", "gid"),
6061
)

scripts/maintenance/computational-clusters/autoscaled_monitor/cli.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,11 @@ def cancel_jobs(
177177
@app.command()
178178
def trigger_cluster_termination(
179179
user_id: Annotated[int, typer.Option(help="the user ID")],
180-
wallet_id: Annotated[int, typer.Option(help="the wallet ID")],
180+
wallet_id: Annotated[
181+
Optional[int | None], # noqa: UP007 # typer does not understand | syntax
182+
typer.Option(help="the wallet ID"),
183+
] = None,
184+
*,
181185
force: Annotated[bool, typer.Option(help="will not ask for confirmation")] = False,
182186
) -> None:
183187
"""this will set the Heartbeat tag on the primary machine to 1 hour, thus ensuring the

0 commit comments

Comments
 (0)