mirror of
https://github.com/bitbaum/evig.git
synced 2026-12-04 18:58:49 +01:00
Major features: - Unified Device Intake system with AI text/voice extraction, checklist-gated publishing, tier change with checklist reset, and audit timeline - Marketplace admin panel with stats, listing moderation, reports, orders - IT-Hilfe admin for managing community tech help requests - Marketplace sell form: AI-assisted listing creation with image upload Fixes: - Marketplace image URL validation: accept relative /uploads/ paths (was rejecting valid uploads with z.string().url()) - Admin marketplace stats/orders: fix column name mismatch (amount_chf not total_cents) - Metadata title dedup: skip brand prefix when title already contains it - Remove "Produkte" from admin sidebar (replaced by Geräte-Eingang + Marketplace flow) - Dashboard quick action: "Neues Produkt" → "Neues Gerät" → /admin/intake Cleanup: - Delete unused modules: labels.ts, newsletter-status.ts, sensitive-areas.ts, role-checks.ts, unified-permissions.ts, mappers.ts, number-sources.ts, admin-access.ts, auth middleware, unused hooks - SSOT consolidation across API routes and config Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
38 lines
2.0 KiB
SQL
38 lines
2.0 KiB
SQL
-- Migration 046: Unified Device Intake System
|
|
--
|
|
-- Links donations → inventory and adds checklist-driven intake workflow.
|
|
-- Devices CANNOT be published to marketplace until all required checklist items are completed.
|
|
--
|
|
-- Depends on:
|
|
-- - 004_erfassung_tables.sql (inventory_items, ai_extracted_products)
|
|
-- - donations table (from earlier migrations)
|
|
|
|
-- Add intake workflow columns to inventory_items
|
|
ALTER TABLE inventory_items
|
|
ADD COLUMN IF NOT EXISTS intake_tier VARCHAR(20),
|
|
ADD COLUMN IF NOT EXISTS intake_checklist JSONB DEFAULT '{}',
|
|
ADD COLUMN IF NOT EXISTS checklist_complete BOOLEAN DEFAULT false,
|
|
ADD COLUMN IF NOT EXISTS source_donation_id UUID REFERENCES donations(id);
|
|
|
|
-- Add source tracking to ai_extracted_products
|
|
ALTER TABLE ai_extracted_products
|
|
ADD COLUMN IF NOT EXISTS source_type VARCHAR(20) DEFAULT 'erfassung';
|
|
|
|
-- Index for pipeline queries (intake items only)
|
|
CREATE INDEX IF NOT EXISTS idx_inventory_intake_tier ON inventory_items (intake_tier)
|
|
WHERE intake_tier IS NOT NULL;
|
|
|
|
-- Index for donation lookups
|
|
CREATE INDEX IF NOT EXISTS idx_inventory_donation ON inventory_items (source_donation_id)
|
|
WHERE source_donation_id IS NOT NULL;
|
|
|
|
-- Index for checklist readiness queries
|
|
CREATE INDEX IF NOT EXISTS idx_inventory_checklist_complete ON inventory_items (checklist_complete)
|
|
WHERE intake_tier IS NOT NULL;
|
|
|
|
COMMENT ON COLUMN inventory_items.intake_tier IS 'Intake processing tier: refurbish, parts, or recycle. NULL = legacy item (not created via intake)';
|
|
COMMENT ON COLUMN inventory_items.intake_checklist IS 'JSONB checklist state: { itemId: { completed, completedBy, completedAt, notes } }';
|
|
COMMENT ON COLUMN inventory_items.checklist_complete IS 'Derived flag: true when all required checklist items are completed. Gates marketplace publishing.';
|
|
COMMENT ON COLUMN inventory_items.source_donation_id IS 'Link to donation record if this item came from a device donation';
|
|
COMMENT ON COLUMN ai_extracted_products.source_type IS 'How this product was created: intake, erfassung, bulk_import';
|