feat: add quantity field to items schema
Add integer quantity column (default 1) to the items table, generate the corresponding Drizzle migration, and extend createItemSchema / updateItemSchema with an optional positive-integer quantity field. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1
drizzle/0008_loving_colossus.sql
Normal file
1
drizzle/0008_loving_colossus.sql
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE `items` ADD `quantity` integer DEFAULT 1 NOT NULL;
|
||||||
@@ -21,6 +21,7 @@ export const items = sqliteTable("items", {
|
|||||||
productUrl: text("product_url"),
|
productUrl: text("product_url"),
|
||||||
imageFilename: text("image_filename"),
|
imageFilename: text("image_filename"),
|
||||||
imageSourceUrl: text("image_source_url"),
|
imageSourceUrl: text("image_source_url"),
|
||||||
|
quantity: integer("quantity").notNull().default(1),
|
||||||
createdAt: integer("created_at", { mode: "timestamp" })
|
createdAt: integer("created_at", { mode: "timestamp" })
|
||||||
.notNull()
|
.notNull()
|
||||||
.$defaultFn(() => new Date()),
|
.$defaultFn(() => new Date()),
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export const createItemSchema = z.object({
|
|||||||
productUrl: z.string().url().optional().or(z.literal("")),
|
productUrl: z.string().url().optional().or(z.literal("")),
|
||||||
imageFilename: z.string().optional(),
|
imageFilename: z.string().optional(),
|
||||||
imageSourceUrl: z.string().url().optional().or(z.literal("")),
|
imageSourceUrl: z.string().url().optional().or(z.literal("")),
|
||||||
|
quantity: z.number().int().positive().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const updateItemSchema = createItemSchema.partial().extend({
|
export const updateItemSchema = createItemSchema.partial().extend({
|
||||||
|
|||||||
Reference in New Issue
Block a user