From 6755ca8c2709e02f946fd313461713213a37f01b Mon Sep 17 00:00:00 2001 From: Barcode Betty Date: Sat, 23 May 2026 23:36:08 +0000 Subject: [PATCH 1/2] Fix: strip PostgreSQL server_default from UUID + gen_random_bytes columns for SQLite tests The sync engine fixture (engine) and async engine fixture (db_engine) now iterate all Base.metadata tables and null server_default on any column whose SQL text contains 'gen_random_uuid' or 'gen_random_bytes'. This covers all UUIDPrimaryKeyMixin columns (Purchase, PurchaseItem, Store, StoreLocation, Coupon, NormalizedProduct, PriceHistory, ShrinkflationEvent, UserStoreAccount) as well as the email_inbound_token gen_random_bytes expression in User. Without this, SQLite raises 'type UUID is not supported' when the ORM tries to bind Python UUID objects, and NOT NULL constraint failures when server_default expressions reference non-existent PostgreSQL functions. Co-Authored-By: Paperclip --- tests/conftest.py | 31 ++++++++++++++++++++++--------- tests/test_encrypted_json.py | 9 +++++++++ 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 5bd4e67..6439552 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -51,12 +51,21 @@ def disable_rate_limiting(): @pytest.fixture def engine(): - """Sync in-memory SQLite engine for model unit tests.""" - eng = create_engine("sqlite:///:memory:") - from cartsnitch_api.models.user import User + """Sync in-memory SQLite engine for model unit tests. + + Strips PostgreSQL-specific server_default expressions so SQLite can + handle all column inserts without missing-function errors. + """ + eng = create_engine("sqlite:///:memory:") + + for table in Base.metadata.tables.values(): + for col in table.columns.values(): + sd = col.server_default + if sd is not None: + expr_str = str(sd.expression).lower() + if "gen_random_uuid" in expr_str or "gen_random_bytes" in expr_str: + col.server_default = None - col = User.__table__.columns["email_inbound_token"] - col.server_default = None Base.metadata.create_all(eng) yield eng eng.dispose() @@ -80,12 +89,16 @@ async def db_engine(): cursor.execute("PRAGMA foreign_keys=ON") cursor.close() - async with engine.begin() as conn: - from cartsnitch_api.models.user import User + for table in Base.metadata.tables.values(): + for col in table.columns.values(): + sd = col.server_default + if sd is not None: + expr_str = str(sd.expression).lower() + if "gen_random_uuid" in expr_str or "gen_random_bytes" in expr_str: + col.server_default = None - User.__table__.columns["email_inbound_token"].server_default = None + async with engine.begin() as conn: await conn.run_sync(Base.metadata.create_all) - # Create Better-Auth tables (not managed by SQLAlchemy models) await conn.execute( text(""" CREATE TABLE IF NOT EXISTS sessions ( diff --git a/tests/test_encrypted_json.py b/tests/test_encrypted_json.py index 2ef3ccb..07cf44c 100644 --- a/tests/test_encrypted_json.py +++ b/tests/test_encrypted_json.py @@ -17,6 +17,15 @@ from cartsnitch_api.models.user import User, UserStoreAccount @pytest.fixture def engine(): eng = create_engine("sqlite:///:memory:") + + for table in Base.metadata.tables.values(): + for col in table.columns.values(): + sd = col.server_default + if sd is not None: + expr_str = str(sd.expression).lower() + if "gen_random_uuid" in expr_str or "gen_random_bytes" in expr_str: + col.server_default = None + Base.metadata.create_all(eng) yield eng eng.dispose() -- 2.52.0 From 84c143c4e737882d624aea091129457e63df83de Mon Sep 17 00:00:00 2001 From: Barcode Betty <32+cs_betty@noreply.git.farh.net> Date: Wed, 27 May 2026 01:56:53 +0000 Subject: [PATCH 2/2] Remove deploy-dev/deploy-uat CI jobs (CAR-1069) (#37) Co-authored-by: Barcode Betty <32+cs_betty@noreply.git.farh.net> Co-committed-by: Barcode Betty <32+cs_betty@noreply.git.farh.net> --- .gitea/workflows/ci.yml | 87 ----------------------------------------- .mcp.json | 11 ++++++ 2 files changed, 11 insertions(+), 87 deletions(-) create mode 100644 .mcp.json diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 12dcd77..c74a1d1 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -175,90 +175,3 @@ jobs: git tag "v${{ steps.calver.outputs.version }}" git push origin "v${{ steps.calver.outputs.version }}" - deploy-dev: - runs-on: ubuntu-latest - needs: [build-and-push] - if: always() && !cancelled() && github.event_name == 'push' && (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main') - steps: - - name: Checkout infra repo - uses: actions/checkout@v4 - with: - repository: cartsnitch/infra - token: ${{ secrets.GITEA_TOKEN }} - ref: main - path: infra - - - name: Install kubectl - uses: azure/setup-kubectl@v4 - - - name: Install kustomize - uses: imranismail/setup-kustomize@v2 - - - name: Determine image tag - id: api_tag - run: | - if [ "${{ github.ref }}" == "refs/heads/main" ]; then - echo "tag=${{ needs.build-and-push.outputs.calver_tag }}" >> "$GITHUB_OUTPUT" - else - echo "tag=${{ needs.build-and-push.outputs.sha_tag }}" >> "$GITHUB_OUTPUT" - fi - - - name: Update api image tag - if: needs.build-and-push.result == 'success' - run: | - cd infra/apps/overlays/dev - kustomize edit set image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.api_tag.outputs.tag }} - - - name: Commit and push to infra - run: | - cd infra - git config user.name "cartsnitch-ci[bot]" - git config user.email "cartsnitch-ci[bot]@users.noreply.github.com" - git add apps/overlays/dev/kustomization.yaml - git commit -m "ci(dev): update api image" - git pull --rebase origin main - git push origin main - - deploy-uat: - runs-on: ubuntu-latest - needs: [build-and-push] - if: always() && !cancelled() && github.event_name == 'push' && (github.ref == 'refs/heads/uat' || github.ref == 'refs/heads/main') - steps: - - name: Checkout infra repo - uses: actions/checkout@v4 - with: - repository: cartsnitch/infra - token: ${{ secrets.GITEA_TOKEN }} - ref: main - path: infra - - - name: Install kubectl - uses: azure/setup-kubectl@v4 - - - name: Install kustomize - uses: imranismail/setup-kustomize@v2 - - - name: Determine image tag - id: api_tag - run: | - if [ "${{ github.ref }}" == "refs/heads/main" ]; then - echo "tag=${{ needs.build-and-push.outputs.calver_tag }}" >> "$GITHUB_OUTPUT" - else - echo "tag=${{ needs.build-and-push.outputs.sha_tag }}" >> "$GITHUB_OUTPUT" - fi - - - name: Update api image tag - if: needs.build-and-push.result == 'success' - run: | - cd infra/apps/overlays/uat - kustomize edit set image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.api_tag.outputs.tag }} - - - name: Commit and push to infra - run: | - cd infra - git config user.name "cartsnitch-ci[bot]" - git config user.email "cartsnitch-ci[bot]@users.noreply.github.com" - git add apps/overlays/uat/kustomization.yaml - git commit -m "ci(uat): update api image" - git pull --rebase origin main - git push origin main \ No newline at end of file diff --git a/.mcp.json b/.mcp.json new file mode 100644 index 0000000..6efc1ca --- /dev/null +++ b/.mcp.json @@ -0,0 +1,11 @@ +{ + "mcpServers": { + "gitea": { + "type": "http", + "url": "https://git-mcp.farh.net/mcp", + "headers": { + "Authorization": "Bearer ${GITEA_TOKEN}" + } + } + } +} -- 2.52.0