Allocated price section (db schema change)#169
Allocated price section (db schema change)#169bbarni2020 wants to merge 3 commits intohackclub:stagingfrom
Conversation
Change error page to fat cat
There was a problem hiding this comment.
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
allocatedPriceUsdcolumn tomarket_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.
| allocatedPriceUsd: real().notNull().default(0), | ||
|
|
There was a problem hiding this comment.
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.
| @@ -0,0 +1 @@ | |||
| ALTER TABLE "market_item" ADD COLUMN "allocatedPriceUsd" real DEFAULT 0 NOT NULL; No newline at end of file | |||
There was a problem hiding this comment.
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.
| 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; |
No description provided.