mitai-jinkendo/backend/migrations/v9c_fix_features.sql
Lars cbad50a987
Some checks failed
Build Test / lint-backend (push) Waiting to run
Build Test / build-frontend (push) Waiting to run
Deploy Development / deploy (push) Has been cancelled
fix: add missing feature check endpoint and features
Critical fixes for feature enforcement:
- Add GET /api/features/{feature_id}/check-access endpoint (was missing!)
- Add migration for missing features: data_export, csv_import
- These features were used in frontend but didn't exist in DB

This fixes:
- "No analysis available" when setting KI limit
- Export features not working
- Frontend calling non-existent API endpoint

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-20 12:57:29 +01:00

34 lines
1.4 KiB
SQL

-- Fix missing features for v9c feature enforcement
-- 2026-03-20
-- Add missing features
INSERT INTO features (id, name, description, category, limit_type, reset_period, default_limit, active) VALUES
('data_export', 'Daten exportieren', 'CSV/JSON/ZIP Export', 'export', 'count', 'monthly', 0, true),
('csv_import', 'CSV importieren', 'FDDB/Apple Health CSV Import + ZIP Backup Import', 'import', 'count', 'monthly', 0, true)
ON CONFLICT (id) DO NOTHING;
-- Add tier limits for new features
-- FREE tier
INSERT INTO tier_limits (tier_id, feature_id, limit_value) VALUES
('free', 'data_export', 0), -- Kein Export
('free', 'csv_import', 0) -- Kein Import
ON CONFLICT (tier_id, feature_id) DO NOTHING;
-- BASIC tier
INSERT INTO tier_limits (tier_id, feature_id, limit_value) VALUES
('basic', 'data_export', 5), -- 5 Exporte/Monat
('basic', 'csv_import', 3) -- 3 Imports/Monat
ON CONFLICT (tier_id, feature_id) DO NOTHING;
-- PREMIUM tier
INSERT INTO tier_limits (tier_id, feature_id, limit_value) VALUES
('premium', 'data_export', NULL), -- Unbegrenzt
('premium', 'csv_import', NULL) -- Unbegrenzt
ON CONFLICT (tier_id, feature_id) DO NOTHING;
-- SELFHOSTED tier
INSERT INTO tier_limits (tier_id, feature_id, limit_value) VALUES
('selfhosted', 'data_export', NULL), -- Unbegrenzt
('selfhosted', 'csv_import', NULL) -- Unbegrenzt
ON CONFLICT (tier_id, feature_id) DO NOTHING;