Skip to content

Commit

Permalink
Update backend dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
treiher committed Dec 20, 2023
1 parent ea8d66e commit 15ab26c
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 62 deletions.
21 changes: 11 additions & 10 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ include = [

[tool.poetry.dependencies]
python = ">=3.9, <4"
alembic = ">=1.6, <1.8.1"
flask = ">=2.0.2, <3"
alembic = ">=1.6, <2"
flask = ">=3, <4"
sqlalchemy = ">=2, <3"

[tool.poetry.group.dev.dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@


def upgrade() -> None:
with op.batch_alter_table(
"routine_activity", schema=None
) as batch_op: # type: ignore[no-untyped-call]
with op.batch_alter_table("routine_activity", schema=None) as batch_op:
for constraint_name, _ in check_constraints_down:
batch_op.drop_constraint(constraint_name, type_="check")

Expand All @@ -42,9 +40,7 @@ def upgrade() -> None:


def downgrade() -> None:
with op.batch_alter_table(
"routine_activity", schema=None
) as batch_op: # type: ignore[no-untyped-call]
with op.batch_alter_table("routine_activity", schema=None) as batch_op:
for constraint_name, _ in check_constraints_up:
batch_op.drop_constraint(constraint_name, type_="check")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
Create Date: 2023-04-01
"""
from typing import Union

import sqlalchemy as sa
from alembic import op

Expand All @@ -15,7 +17,7 @@
depends_on = None


check_constraints = [
check_constraints: list[tuple[str, Union[str, sa.ColumnElement[bool]]]] = [
("reps_type_integer", "typeof(reps) = 'integer'"),
("weight_type_real", "typeof(weight) = 'real'"),
("rpe_type_real", "typeof(rpe) = 'real'"),
Expand All @@ -27,9 +29,7 @@


def upgrade() -> None:
with op.batch_alter_table(
"routine_activity", schema=None
) as batch_op: # type: ignore[no-untyped-call]
with op.batch_alter_table("routine_activity", schema=None) as batch_op:
batch_op.add_column(sa.Column("reps", sa.Integer(), nullable=False, default=0))
batch_op.add_column(sa.Column("weight", sa.Float(), nullable=False, default=0))
batch_op.add_column(sa.Column("rpe", sa.Float(), nullable=False, default=0))
Expand All @@ -38,9 +38,7 @@ def upgrade() -> None:


def downgrade() -> None:
with op.batch_alter_table(
"routine_activity", schema=None
) as batch_op: # type: ignore[no-untyped-call]
with op.batch_alter_table("routine_activity", schema=None) as batch_op:
batch_op.drop_column("rpe")
batch_op.drop_column("weight")
batch_op.drop_column("reps")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
Create Date: 2021-07-18
"""
from typing import Any

from alembic import op
from sqlalchemy import CheckConstraint, column

Expand All @@ -15,93 +17,91 @@
depends_on = None


FOREIGN_KEY_CONSTRAINTS = [
FOREIGN_KEY_CONSTRAINTS: list[tuple[str, str, str, str, tuple[Any, ...]]] = [ # type: ignore[misc]
(
"fk_body_weight_user_id_user",
"body_weight",
"user",
"user_id",
[
CheckConstraint(column("weight") > 0, name="ck_body_weight_weight_gt_0"),
],
(CheckConstraint(column("weight") > 0, name="ck_body_weight_weight_gt_0"),),
),
(
"fk_body_fat_user_id_user",
"body_fat",
"user",
"user_id",
[
(
CheckConstraint(column("chest") > 0, name="ck_body_fat_chest_gt_0"),
CheckConstraint(column("abdominal") > 0, name="ck_body_fat_abdominal_gt_0"),
CheckConstraint(column("tigh") > 0, name="ck_body_fat_tigh_gt_0"),
CheckConstraint(column("tricep") > 0, name="ck_body_fat_tricep_gt_0"),
CheckConstraint(column("subscapular") > 0, name="ck_body_fat_subscapular_gt_0"),
CheckConstraint(column("suprailiac") > 0, name="ck_body_fat_suprailiac_gt_0"),
CheckConstraint(column("midaxillary") > 0, name="ck_body_fat_midaxillary_gt_0"),
],
),
),
(
"fk_period_user_id_user",
"period",
"user",
"user_id",
[
(
CheckConstraint(column("intensity") >= 1, name="ck_period_intensity_ge_1"),
CheckConstraint(column("intensity") <= 4, name="ck_period_intensity_le_4"),
],
),
),
(
"fk_routine_exercise_routine_id_routine",
"routine_exercise",
"routine",
"routine_id",
[
(
CheckConstraint(column("position") > 0, name="ck_routine_exercise_position_gt_0"),
CheckConstraint(column("sets") > 0, name="ck_routine_exercise_sets_gt_0"),
],
),
),
(
"fk_routine_exercise_exercise_id_exercise",
"routine_exercise",
"exercise",
"exercise_id",
[
(
CheckConstraint(column("position") > 0, name="ck_routine_exercise_position_gt_0"),
CheckConstraint(column("sets") > 0, name="ck_routine_exercise_sets_gt_0"),
],
),
),
(
"fk_workout_set_workout_id_workout",
"workout_set",
"workout",
"workout_id",
[
(
CheckConstraint(column("position") > 0, name="ck_workout_set_position_gt_0"),
CheckConstraint(column("reps") > 0, name="ck_workout_set_reps_gt_0"),
CheckConstraint(column("time") > 0, name="ck_workout_set_time_gt_0"),
CheckConstraint(column("weight") > 0, name="ck_workout_set_weight_gt_0"),
CheckConstraint(column("rpe") >= 0, name="ck_workout_set_rpe_ge_0"),
CheckConstraint(column("rpe") <= 10, name="ck_workout_set_rpe_le_10"),
],
),
),
(
"fk_workout_set_exercise_id_exercise",
"workout_set",
"exercise",
"exercise_id",
[
(
CheckConstraint(column("position") > 0, name="ck_workout_set_position_gt_0"),
CheckConstraint(column("reps") > 0, name="ck_workout_set_reps_gt_0"),
CheckConstraint(column("time") > 0, name="ck_workout_set_time_gt_0"),
CheckConstraint(column("weight") > 0, name="ck_workout_set_weight_gt_0"),
CheckConstraint(column("rpe") >= 0, name="ck_workout_set_rpe_ge_0"),
CheckConstraint(column("rpe") <= 10, name="ck_workout_set_rpe_le_10"),
],
),
),
("fk_exercise_user_id_user", "exercise", "user", "user_id", []),
("fk_workout_user_id_user", "workout", "user", "user_id", []),
("fk_workout_routine_id_routine", "workout", "routine", "routine_id", []),
("fk_routine_user_id_user", "routine", "user", "user_id", []),
("fk_exercise_user_id_user", "exercise", "user", "user_id", ()),
("fk_workout_user_id_user", "workout", "user", "user_id", ()),
("fk_workout_routine_id_routine", "workout", "routine", "routine_id", ()),
("fk_routine_user_id_user", "routine", "user", "user_id", ()),
]


Expand All @@ -113,9 +113,7 @@ def upgrade() -> None:
local_col,
table_args,
) in FOREIGN_KEY_CONSTRAINTS:
with op.batch_alter_table(
source_table, schema=None, table_args=table_args
) as batch_op: # type: ignore[no-untyped-call]
with op.batch_alter_table(source_table, schema=None, table_args=table_args) as batch_op:
batch_op.drop_constraint(constraint_name, type_="foreignkey")
batch_op.create_foreign_key(
batch_op.f(constraint_name), referent_table, [local_col], ["id"], ondelete="CASCADE"
Expand All @@ -130,9 +128,7 @@ def downgrade() -> None:
local_col,
table_args,
) in FOREIGN_KEY_CONSTRAINTS:
with op.batch_alter_table(
source_table, schema=None, table_args=table_args
) as batch_op: # type: ignore[no-untyped-call]
with op.batch_alter_table(source_table, schema=None, table_args=table_args) as batch_op:
batch_op.drop_constraint(constraint_name, type_="foreignkey")
batch_op.create_foreign_key(
batch_op.f(constraint_name), referent_table, [local_col], ["id"]
Expand Down
4 changes: 2 additions & 2 deletions valens/migrations/versions/4b6051594962_add_type_checking.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@

def upgrade() -> None:
for constraint_name, table_name, condition in CHECK_CONSTRAINTS:
with op.batch_alter_table(table_name) as batch_op: # type: ignore[no-untyped-call]
with op.batch_alter_table(table_name) as batch_op:
batch_op.create_check_constraint(constraint_name, condition)


def downgrade() -> None:
for constraint_name, table_name, _ in CHECK_CONSTRAINTS:
with op.batch_alter_table(table_name) as batch_op: # type: ignore[no-untyped-call]
with op.batch_alter_table(table_name) as batch_op:
batch_op.drop_constraint(f"ck_{table_name}_{constraint_name}")
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@


def upgrade() -> None:
with op.batch_alter_table("workout", schema=None) as batch_op: # type: ignore[no-untyped-call]
with op.batch_alter_table("workout", schema=None) as batch_op:
batch_op.add_column(sa.Column("routine_id", sa.Integer(), nullable=True))
batch_op.create_foreign_key(
batch_op.f("fk_workout_routine_id_routine"), "routine", ["routine_id"], ["id"]
)


def downgrade() -> None:
with op.batch_alter_table("workout", schema=None) as batch_op: # type: ignore[no-untyped-call]
with op.batch_alter_table("workout", schema=None) as batch_op:
batch_op.drop_constraint(batch_op.f("fk_workout_routine_id_routine"), type_="foreignkey")
batch_op.drop_column("routine_id")
12 changes: 5 additions & 7 deletions valens/migrations/versions/8a0dc258bf2a_extend_workouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
Create Date: 2023-02-16
"""
from typing import Union

import sqlalchemy as sa
from alembic import op

Expand Down Expand Up @@ -33,7 +35,7 @@
sa.column("automatic", sa.Boolean),
)

check_constraints = [
check_constraints: list[tuple[str, Union[str, sa.ColumnElement[bool]]]] = [
(
"target_reps_type_integer_or_null",
"typeof(target_reps) = 'integer' or typeof(target_reps) = 'null'",
Expand Down Expand Up @@ -116,9 +118,7 @@ def upgrade() -> None:
sa.PrimaryKeyConstraint("workout_id", "position", name=op.f("pk_workout_rest")),
)

with op.batch_alter_table(
"workout_set", schema=None
) as batch_op: # type: ignore[no-untyped-call]
with op.batch_alter_table("workout_set", schema=None) as batch_op:
batch_op.add_column(sa.Column("target_reps", sa.Integer(), nullable=True))
batch_op.add_column(sa.Column("target_time", sa.Integer(), nullable=True))
batch_op.add_column(sa.Column("target_weight", sa.Float(), nullable=True))
Expand All @@ -136,9 +136,7 @@ def upgrade() -> None:


def downgrade() -> None:
with op.batch_alter_table(
"workout_set", schema=None
) as batch_op: # type: ignore[no-untyped-call]
with op.batch_alter_table("workout_set", schema=None) as batch_op:
batch_op.drop_constraint(
batch_op.f("fk_workout_set_workout_id_workout_element"), type_="foreignkey"
)
Expand Down

0 comments on commit 15ab26c

Please sign in to comment.