diff --git a/.gitea/workflows/deploy-dev.yml b/.gitea/workflows/deploy-dev.yml index ad2ae3d..d97832c 100644 --- a/.gitea/workflows/deploy-dev.yml +++ b/.gitea/workflows/deploy-dev.yml @@ -18,6 +18,11 @@ jobs: docker compose -f docker-compose.dev-env.yml build --no-cache docker compose -f docker-compose.dev-env.yml up -d sleep 5 - curl -sf http://localhost:8098/api/version && echo "✓ DEV API healthy" + if ! curl -sf http://localhost:8098/api/version; then + echo "✗ DEV API nicht erreichbar — Backend-Logs (Migration/Startup):" + docker compose -f docker-compose.dev-env.yml logs backend --tail 120 || true + exit 1 + fi + echo "✓ DEV API healthy" curl -sf http://localhost:3098/api/version && echo "✓ DEV über Frontend-Nginx (wie Browser) healthy" echo "=== Shinkan DEV Deploy complete ===" diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index 1cd75a8..56a75f0 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -11,9 +11,8 @@ on: jobs: # Pytest im laufenden backend-Container; ACCESS_LAYER + TRAINING_PLANNING Integration gegen dieselbe PostgreSQL wie Deploy (Schema via Container-Start migriert). - # Nicht bei push auf develop/main: Deploy läuft parallel → Container oft im Restart (siehe workflow_run nach Deploy). pytest-backend: - if: ${{ (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') || github.event_name == 'pull_request' }} + if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} runs-on: ubuntu-latest steps: - name: Backend pytest im deployten Container diff --git a/backend/migrations/078_club_features_and_plans.sql b/backend/migrations/078_club_features_and_plans.sql index c3e556d..7bbe3df 100644 --- a/backend/migrations/078_club_features_and_plans.sql +++ b/backend/migrations/078_club_features_and_plans.sql @@ -15,7 +15,15 @@ BEGIN SELECT 1 FROM information_schema.columns WHERE table_schema = 'public' AND table_name = 'features' AND column_name = 'limit_type' ) THEN - ALTER TABLE features RENAME TO features_legacy_001; + -- Nach abgebrochenem Erstversuch kann features_legacy_001 schon existieren + IF EXISTS ( + SELECT 1 FROM information_schema.tables + WHERE table_schema = 'public' AND table_name = 'features_legacy_001' + ) THEN + DROP TABLE features; + ELSE + ALTER TABLE features RENAME TO features_legacy_001; + END IF; END IF; IF EXISTS ( @@ -25,7 +33,14 @@ BEGIN SELECT 1 FROM information_schema.columns WHERE table_schema = 'public' AND table_name = 'tier_limits' AND column_name = 'tier' ) THEN - ALTER TABLE tier_limits RENAME TO tier_limits_legacy_001; + IF EXISTS ( + SELECT 1 FROM information_schema.tables + WHERE table_schema = 'public' AND table_name = 'tier_limits_legacy_001' + ) THEN + DROP TABLE tier_limits; + ELSE + ALTER TABLE tier_limits RENAME TO tier_limits_legacy_001; + END IF; END IF; IF EXISTS ( @@ -35,7 +50,14 @@ BEGIN SELECT 1 FROM information_schema.columns WHERE table_schema = 'public' AND table_name = 'user_feature_usage' AND column_name = 'profile_id' ) THEN - ALTER TABLE user_feature_usage RENAME TO user_feature_usage_legacy_001; + IF EXISTS ( + SELECT 1 FROM information_schema.tables + WHERE table_schema = 'public' AND table_name = 'user_feature_usage_legacy_001' + ) THEN + DROP TABLE user_feature_usage; + ELSE + ALTER TABLE user_feature_usage RENAME TO user_feature_usage_legacy_001; + END IF; END IF; END $migration$; diff --git a/backend/migrations/079_capabilities.sql b/backend/migrations/079_capabilities.sql index 4c6ae24..febf256 100644 --- a/backend/migrations/079_capabilities.sql +++ b/backend/migrations/079_capabilities.sql @@ -1,5 +1,19 @@ -- Migration 079: Capability-Registry + Rollen-Grants (M3 / CAPABILITY_CATALOG.v1.md C1) -- Account-Gates und Enforcement in Python (account_lifecycle.py, capabilities.py). +-- Voraussetzung: Migration 078 (features.id TEXT). Kein FK auf features — vermeidet +-- Startup-Abbruch wenn 078 noch aussteht oder features-Schema driftet (001 vs v9c). + +DO $migration$ +BEGIN + IF NOT EXISTS ( + SELECT 1 FROM information_schema.columns + WHERE table_schema = 'public' AND table_name = 'features' AND column_name = 'limit_type' + ) THEN + RAISE EXCEPTION + 'Migration 079: features-Tabelle nicht v9c (limit_type fehlt). Zuerst 078_club_features_and_plans anwenden.'; + END IF; +END +$migration$; CREATE TABLE IF NOT EXISTS capabilities ( id TEXT PRIMARY KEY, @@ -10,7 +24,7 @@ CREATE TABLE IF NOT EXISTS capabilities ( CHECK (min_account_state IN ( 'unverified', 'verified_pending_club', 'active_member', 'platform_admin' )), - linked_feature_id TEXT REFERENCES features(id) ON DELETE SET NULL, + linked_feature_id TEXT, active BOOLEAN NOT NULL DEFAULT true, created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()