Files
evig/scripts/db/migrations/045_admin_management_columns.sql
g-butandClaude Opus 4.6 45bd7832fe feat: unified intake system, marketplace admin, IT-Hilfe, sidebar cleanup
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>
2026-03-04 18:56:42 +01:00

44 lines
2.0 KiB
SQL

-- ============================================================================
-- Migration 045: Admin Management Columns
--
-- Adds columns needed for full admin management of Marketplace and IT-Hilfe:
-- 1. listing_reports: resolution fields
-- 2. listings: admin_notes
-- 3. helper_profiles: verification and suspension fields
-- 4. it_hilfe_requests: admin_notes
-- ============================================================================
-- listing_reports: add resolution fields
ALTER TABLE listing_reports
ADD COLUMN IF NOT EXISTS resolution_notes TEXT,
ADD COLUMN IF NOT EXISTS resolution_action VARCHAR(50);
COMMENT ON COLUMN listing_reports.resolution_notes IS 'Admin notes about resolution of the report';
COMMENT ON COLUMN listing_reports.resolution_action IS 'Action taken: dismiss, warn_seller, remove_listing';
-- listings: add admin_notes
ALTER TABLE listings
ADD COLUMN IF NOT EXISTS admin_notes TEXT;
COMMENT ON COLUMN listings.admin_notes IS 'Internal admin notes about this listing';
-- helper_profiles: add verification and suspension fields
ALTER TABLE helper_profiles
ADD COLUMN IF NOT EXISTS is_verified BOOLEAN DEFAULT false,
ADD COLUMN IF NOT EXISTS verified_at TIMESTAMPTZ,
ADD COLUMN IF NOT EXISTS verified_by UUID REFERENCES users(id),
ADD COLUMN IF NOT EXISTS suspended_at TIMESTAMPTZ,
ADD COLUMN IF NOT EXISTS admin_notes TEXT;
COMMENT ON COLUMN helper_profiles.is_verified IS 'Whether the helper has been verified by admin';
COMMENT ON COLUMN helper_profiles.verified_at IS 'When the helper was verified';
COMMENT ON COLUMN helper_profiles.verified_by IS 'Admin who verified the helper';
COMMENT ON COLUMN helper_profiles.suspended_at IS 'When the helper was suspended (NULL = active)';
COMMENT ON COLUMN helper_profiles.admin_notes IS 'Internal admin notes about this helper';
-- it_hilfe_requests: add admin_notes
ALTER TABLE it_hilfe_requests
ADD COLUMN IF NOT EXISTS admin_notes TEXT;
COMMENT ON COLUMN it_hilfe_requests.admin_notes IS 'Internal admin notes about this request';