Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Commands and Scripts are defined in the `package.json` file. Prefer scripts over
- **Components**: Use Svelte 5 runes (`$props`, `$state`, `$derived`).
- **UI Library**: svelte-shadcn provides most of the shadcn components, stored in `src/lib/components/ui/`. Prefer these over building custom components.
- **Styling**: Tailwind CSS (v4) with `clsx` and `tailwind-merge` for dynamic classes.
- **Database**: Use Drizzle ORM with transactions for multi-step operations. Use `pnpm db:push` for rapid prototyping and `pnpm db:generate` for production migrations. Migration files must be generated. Hand-edits require approval.
- **Database**: Use Drizzle ORM with transactions for multi-step operations. Use `pnpm db:push` for rapid prototyping and `pnpm db:generate --name <DescriptiveName>` for production migrations. Migration files must be generated with a descriptive name. Hand-edits require approval.
- **Services**: Keep business logic in `$lib/server/services/`, database queries in services not routes, and blob/file side effects in services too.
- **Architecture**: Keep routes and remote functions thin; put validation at the boundary and refresh remote queries after mutations.
- **Cron jobs**: Background jobs live in `src/routes/api/cron/` and are scheduled in `vercel.json`.
Expand Down
23 changes: 23 additions & 0 deletions drizzle/0014_GroupAndReorderRecipeIngredients.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
CREATE TABLE "ingredient_sections" (
"id" serial PRIMARY KEY NOT NULL,
"name" text NOT NULL,
"section_order" integer NOT NULL,
"recipe_id" integer NOT NULL
);
--> statement-breakpoint
DROP INDEX "ingredients_recipe_id_idx";--> statement-breakpoint
ALTER TABLE "ingredients" ADD COLUMN "ingredient_order" integer;--> statement-breakpoint
ALTER TABLE "ingredients" ADD COLUMN "section_id" integer;--> statement-breakpoint
WITH ordered_ingredients AS (
SELECT "id", row_number() OVER (PARTITION BY "recipe_id" ORDER BY "id") AS "ingredient_order"
FROM "ingredients"
)
UPDATE "ingredients"
SET "ingredient_order" = ordered_ingredients."ingredient_order"
FROM ordered_ingredients
WHERE "ingredients"."id" = ordered_ingredients."id";--> statement-breakpoint
ALTER TABLE "ingredients" ALTER COLUMN "ingredient_order" SET NOT NULL;--> statement-breakpoint
ALTER TABLE "ingredient_sections" ADD CONSTRAINT "ingredient_sections_recipe_id_recipes_id_fk" FOREIGN KEY ("recipe_id") REFERENCES "public"."recipes"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "ingredient_sections_recipe_order_idx" ON "ingredient_sections" USING btree ("recipe_id","section_order");--> statement-breakpoint
ALTER TABLE "ingredients" ADD CONSTRAINT "ingredients_section_id_ingredient_sections_id_fk" FOREIGN KEY ("section_id") REFERENCES "public"."ingredient_sections"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "ingredients_recipe_section_order_idx" ON "ingredients" USING btree ("recipe_id","section_id","ingredient_order");
Loading
Loading