PHASE 1: Cleanup & Analyse - Feature-Konsolidierung: export_csv/json/zip → data_export (1 Feature) - Umbenennung: csv_import → data_import - Auto-Migration bei Container-Start (apply_v9c_migration.py) - Diagnose-Script (check_features.sql) Lessons Learned angewendet: - Ein Feature für Export, nicht drei - Migration ist idempotent (kann mehrfach laufen) - Zeigt BEFORE/AFTER State im Log Finaler Feature-Katalog (10 statt 13): - Data: weight, circumference, caliper, nutrition, activity, photos - AI: ai_calls, ai_pipeline - Export/Import: data_export, data_import Tier Limits: - FREE: 30 data entries, 0 AI/export/import - BASIC: unlimited data, 3 AI/month, 5 export/month, 3 import/month - PREMIUM/SELFHOSTED: unlimited Migration läuft automatisch auf dev UND prod beim Container-Start. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
51 lines
1.7 KiB
SQL
51 lines
1.7 KiB
SQL
-- ============================================================================
|
|
-- Feature Check Script - Diagnose vor/nach Migration
|
|
-- ============================================================================
|
|
-- Usage: psql -U mitai_dev -d mitai_dev -f check_features.sql
|
|
-- ============================================================================
|
|
|
|
\echo '=== CURRENT FEATURES ==='
|
|
SELECT id, name, category, limit_type, reset_period, default_limit, active
|
|
FROM features
|
|
ORDER BY category, id;
|
|
|
|
\echo ''
|
|
\echo '=== TIER LIMITS MATRIX ==='
|
|
SELECT
|
|
f.id as feature,
|
|
f.category,
|
|
MAX(CASE WHEN tl.tier_id = 'free' THEN COALESCE(tl.limit_value::text, '∞') END) as free,
|
|
MAX(CASE WHEN tl.tier_id = 'basic' THEN COALESCE(tl.limit_value::text, '∞') END) as basic,
|
|
MAX(CASE WHEN tl.tier_id = 'premium' THEN COALESCE(tl.limit_value::text, '∞') END) as premium,
|
|
MAX(CASE WHEN tl.tier_id = 'selfhosted' THEN COALESCE(tl.limit_value::text, '∞') END) as selfhosted
|
|
FROM features f
|
|
LEFT JOIN tier_limits tl ON f.id = tl.feature_id
|
|
GROUP BY f.id, f.category
|
|
ORDER BY f.category, f.id;
|
|
|
|
\echo ''
|
|
\echo '=== FEATURE COUNT BY CATEGORY ==='
|
|
SELECT category, COUNT(*) as count
|
|
FROM features
|
|
WHERE active = true
|
|
GROUP BY category
|
|
ORDER BY category;
|
|
|
|
\echo ''
|
|
\echo '=== ORPHANED TIER LIMITS (feature not exists) ==='
|
|
SELECT tl.tier_id, tl.feature_id, tl.limit_value
|
|
FROM tier_limits tl
|
|
LEFT JOIN features f ON tl.feature_id = f.id
|
|
WHERE f.id IS NULL;
|
|
|
|
\echo ''
|
|
\echo '=== USER FEATURE USAGE (current usage tracking) ==='
|
|
SELECT
|
|
p.name as user,
|
|
ufu.feature_id,
|
|
ufu.usage_count,
|
|
ufu.reset_at
|
|
FROM user_feature_usage ufu
|
|
JOIN profiles p ON ufu.profile_id = p.id
|
|
ORDER BY p.name, ufu.feature_id;
|