Schema (W0): - Add garments, garment_wears, outfits tables with Drizzle migrations - Drizzle migrations 0001 (garments/wears) and 0002 (outfits) auto-apply on deploy - RLS policies in drizzle/manual/06-wardrobe-rls.sql (apply via superuser in prod) API (W1–W9): - POST /api/garments/upload — direct upload to R2 garments/ prefix with sharp thumbnail - POST /api/garments/tag — vision tagging via LiteLLM, defensive parse, category validated - GET/POST /api/garments — list with composable filters, create - GET/PATCH/DELETE /api/garments/[id] — detail, edit, delete - POST /api/garments/[id]/wear — log worn date - GET /api/garments/outgrowth — pure SQL, explicit size ordering (no lexicographic sort) - GET /api/garments/packing — active garments grouped by category - GET /api/garments/outfit — Open-Meteo weather + deterministic outfit pairing, no LLM - GET/POST /api/garments/outfits + DELETE [id] — saved outfits Pages: - /wardrobe — grid with status/category/size/season filters + outgrowth nudge - /wardrobe/add — 3-step capture→vision→form, size required, batch-friendly - /wardrobe/[id] — detail/edit/status lifecycle + wear history - /wardrobe/packing — packing checklist by category - /wardrobe/outfit — weather-aware suggestions with shown basis - /wardrobe/saved-outfits — view/delete saved combinations Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
21 lines
986 B
SQL
21 lines
986 B
SQL
-- RLS for garments and garment_wears
|
|
-- Run AFTER 0001_wardrobe_tables.sql has been applied
|
|
-- Apply as superuser: psql $DATABASE_URL_SUPERUSER -f drizzle/manual/06-wardrobe-rls.sql
|
|
|
|
ALTER TABLE garments ENABLE ROW LEVEL SECURITY;
|
|
ALTER TABLE garment_wears ENABLE ROW LEVEL SECURITY;
|
|
|
|
-- Both tables carry family_id directly, so we use the same direct comparison
|
|
-- pattern as family_invites rather than the child_id subquery pattern.
|
|
-- FOR ALL with USING also enforces WITH CHECK on INSERT (prevents cross-family writes).
|
|
CREATE POLICY family_isolation ON garments
|
|
FOR ALL USING (family_id = current_setting('app.current_family_id', true)::uuid);
|
|
|
|
CREATE POLICY family_isolation ON garment_wears
|
|
FOR ALL USING (family_id = current_setting('app.current_family_id', true)::uuid);
|
|
|
|
-- W9: Saved outfits
|
|
ALTER TABLE outfits ENABLE ROW LEVEL SECURITY;
|
|
|
|
CREATE POLICY family_isolation ON outfits
|
|
FOR ALL USING (family_id = current_setting('app.current_family_id', true)::uuid);
|