# Start: EF Core Migration Pre-flight

> Reference for step-start.md — BLOCKING check for release/hotfix branches.

## Migration Naming Validation

```bash
if [ "$branch_type" = "release" ] || [ "$branch_type" = "hotfix" ]; then
  echo "EF CORE MIGRATION PRE-FLIGHT"
  echo "─────────────────────────────"

  MIGRATION_DIRS=$(find . -type d -name "Migrations" -path "*/src/*" 2>/dev/null)

  if [ -n "$MIGRATION_DIRS" ]; then
    BAD_MIGRATIONS=""
    GOOD_COUNT=0
    BAD_COUNT=0

    for dir in $MIGRATION_DIRS; do
      for file in $(find "$dir" -name "*.cs" ! -name "*Designer*" ! -name "*ModelSnapshot*" | sort); do
        FILENAME=$(basename "$file" .cs)
        # Strip EF Core 14-digit timestamp prefix (e.g., 20260128220215_)
        NAME_PART=$(echo "$FILENAME" | sed 's/^[0-9]\{14\}_//')

        # Validate: {context}_v{version}_{sequence}_{Description}
        # Accepts both dot (v2.0.0) and underscore (v2_0_0) version separators
        if echo "$NAME_PART" | grep -qE '^[a-zA-Z]+_v[0-9]+[._][0-9]+[._][0-9]+_[0-9]{3}_[A-Z]'; then
          echo "  ✅ $FILENAME"
          GOOD_COUNT=$((GOOD_COUNT + 1))
        else
          echo "  ❌ $FILENAME"
          BAD_COUNT=$((BAD_COUNT + 1))
          BAD_MIGRATIONS="$BAD_MIGRATIONS  - $FILENAME\n"
        fi
      done
    done

    echo ""
    echo "Result: $GOOD_COUNT OK, $BAD_COUNT non-compliant"

    if [ "$BAD_COUNT" -gt 0 ]; then
      echo ""
      echo "⛔ RELEASE BLOCKED - Non-compliant migration names detected"
      echo "Expected format: {context}_v{version}_{sequence}_{Description}"
      echo "  Example OK:  core_v2.0.0_001_InitialSchema"
      echo "  Example NOK: AddApplicationAccessRequests"
    fi
  fi
fi
```

## If Non-Compliant Migrations Found

```yaml
AskUserQuestion:
  header: "Migrations"
  question: "Non-compliant migration names block this release. How to proceed?"
  options:
    - label: "Run /efcore squash (Recommended)"
      description: "Squash migrations on develop to fix naming via MCP, then retry release"
    - label: "Abort release"
      description: "Cancel release, fix manually on develop"
    - label: "Continue anyway"
      description: "Proceed despite naming issues (NOT recommended for production)"
```

**Actions:**
- **"/efcore squash"** → Delegate to `efcore-squash` agent on develop, then re-run `/gitflow start release`
- **"Abort release"** → STOP immediately
- **"Continue anyway"** → Log warning to `.claude/gitflow/logs/audit.log` and proceed
