8000
  • Allocated price section (db schema change) by bbarni2020 · Pull Request #169 · hackclub/construct · GitHub
    [go: up one dir, main page]

    Skip to content

    Allocated price section (db schema change)#169

    Open
    bbarni2020 wants to merge 3 commits intohackclub:stagingfrom
    bbarni2020:allocated-price-section
    Open

    Allocated price section (db schema change)#169
    bbarni2020 wants to merge 3 commits intohackclub:stagingfrom
    bbarni2020:allocated-price-section

    Conversation

    @bbarni2020
    Copy link
    Collaborator

    No description provided.

    Copilot AI review requested due to automatic review settings February 23, 2026 21:16
    @bbarni2020 bbarni2020 changed the title Allocated price section Allocated price section (db schema change) Feb 23, 2026
    Copy link
    Contributor
    Copilot AI left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Pull request overview

    This PR adds support for an “allocated price (USD)” field on market items, persists it in the database, and surfaces it in the admin UI (market item create/edit and order detail pages).

    Changes:

    • Add allocatedPriceUsd column to market_item (Drizzle schema + migration).
    • Add allocated price input to admin market item create/edit forms and persist it on create/update.
    • Display allocated price and user email on the admin order detail page.

    Reviewed changes

    Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

    Show a summary per file
    File Description
    src/routes/dashboard/admin/admin/orders/[id]/+page.svelte Shows user email (when available) and allocated USD price on the order detail page.
    src/routes/dashboard/admin/admin/orders/[id]/+page.server.ts Loads allocatedPriceUsd with the market item and fetches userEmail from IDV user data.
    src/routes/dashboard/admin/admin/market/item/create/+page.svelte Adds an “Allocated price (USD)” input to the create form.
    src/routes/dashboard/admin/admin/market/item/create/+page.server.ts Parses/validates allocatedPriceUsd and inserts it into market_item.
    src/routes/dashboard/admin/admin/market/item/[id]/edit/+page.svelte Adds an “Allocated price (USD)” input to the edit form.
    src/routes/dashboard/admin/admin/market/item/[id]/edit/+page.server.ts Parses/validates allocatedPriceUsd and updates it on market_item.
    src/lib/server/db/schema.ts Adds allocatedPriceUsd to the Drizzle marketItem table definition.
    drizzle/meta/_journal.json Adds a new migration journal entry for the new migration.
    drizzle/meta/0031_snapshot.json New Drizzle schema snapshot including the new column.
    drizzle/0031_jittery_squadron_sinister.sql Migration that adds the new allocatedPriceUsd column.

    💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

    Comment on lines +250 to +251
    allocatedPriceUsd: real().notNull().default(0),

    Copy link
    Copilot AI Feb 23, 2026

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    allocatedPriceUsd is stored as Postgres real (floating point). For currency amounts this can introduce rounding/precision errors (e.g., storing 0.1 + 0.2). Consider using a fixed-precision type (e.g., numeric(10,2)) or storing cents as an integer instead, and update the migration/schema accordingly.

    Copilot uses AI. Check for mistakes.
    @@ -0,0 +1 @@
    ALTER TABLE "market_item" ADD COLUMN "allocatedPriceUsd" real DEFAULT 0 NOT NULL; No newline at end of file
    Copy link
    Copilot AI Feb 23, 2026

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    This migration adds allocatedPriceUsd as a real (float). If this is intended to represent USD, consider using a fixed-precision numeric(10,2) (or storing cents as an integer) to avoid floating point rounding issues for currency.

    Suggested change
    ALTER TABLE "market_item" ADD COLUMN "allocatedPriceUsd" real DEFAULT 0 NOT NULL;
    ALTER TABLE "market_item" ADD COLUMN "allocatedPriceUsd" numeric(10,2) DEFAULT 0 NOT NULL;

    Copilot uses AI. Check for mistakes.
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    None yet

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    3 participants

    0