From 2b50aad68252db86d535bccc913074115497e651 Mon Sep 17 00:00:00 2001 From: Barcode Betty Date: Mon, 30 Mar 2026 20:13:56 +0000 Subject: [PATCH] fix(deploy): include alembic in API Docker image Adds alembic.ini and alembic/ directory to the production API image so alembic upgrade head can run in-cluster as an init container. Also carries migration 003 (make hashed_password nullable) from PR #66. Co-Authored-By: Paperclip --- api/Dockerfile | 2 ++ ...003_make_users_hashed_password_nullable.py | 26 +++++++++++++++++++ common/src/cartsnitch_common/models/user.py | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 api/alembic/versions/003_make_users_hashed_password_nullable.py diff --git a/api/Dockerfile b/api/Dockerfile index bb5d3bd..8eef88d 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -16,6 +16,8 @@ WORKDIR /app RUN adduser --system --group --uid 1000 app COPY --from=build /install /usr/local COPY src/ ./src/ +COPY alembic.ini ./ +COPY alembic/ ./alembic/ USER 1000 EXPOSE 8000 diff --git a/api/alembic/versions/003_make_users_hashed_password_nullable.py b/api/alembic/versions/003_make_users_hashed_password_nullable.py new file mode 100644 index 0000000..8aec2bc --- /dev/null +++ b/api/alembic/versions/003_make_users_hashed_password_nullable.py @@ -0,0 +1,26 @@ +"""Make users.hashed_password nullable. + +Better-Auth inserts users without hashed_password (passwords live in the +accounts table). This column is now purely optional. + +Revision ID: 003_make_users_hashed_password_nullable +Revises: 002_better_auth_tables +Create Date: 2026-03-30 +""" + +import sqlalchemy as sa + +from alembic import op + +revision = "003_make_users_hashed_password_nullable" +down_revision = "002_better_auth_tables" +branch_labels = None +depends_on = None + + +def upgrade() -> None: + op.alter_column("users", "hashed_password", existing_type=sa.String(255), nullable=True) + + +def downgrade() -> None: + op.alter_column("users", "hashed_password", existing_type=sa.String(255), nullable=False) diff --git a/common/src/cartsnitch_common/models/user.py b/common/src/cartsnitch_common/models/user.py index 5e35e5a..4382a08 100644 --- a/common/src/cartsnitch_common/models/user.py +++ b/common/src/cartsnitch_common/models/user.py @@ -21,7 +21,7 @@ class User(UUIDPrimaryKeyMixin, TimestampMixin, Base): __tablename__ = "users" email: Mapped[str] = mapped_column(String(255), nullable=False, unique=True) - hashed_password: Mapped[str] = mapped_column(String(255), nullable=False) + hashed_password: Mapped[str | None] = mapped_column(String(255), nullable=True) display_name: Mapped[str | None] = mapped_column(String(100)) email_verified: Mapped[bool] = mapped_column(Boolean, nullable=False, server_default="false") image: Mapped[str | None] = mapped_column(Text, nullable=True)