@atlashub/smartstack-cli 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.documentation/agents.html +912 -0
- package/.documentation/apex.html +1014 -0
- package/.documentation/business-analyse.html +1074 -0
- package/.documentation/commands.html +676 -0
- package/.documentation/css/styles.css +2030 -0
- package/.documentation/efcore.html +2501 -0
- package/.documentation/gitflow.html +2053 -0
- package/.documentation/hooks.html +409 -0
- package/.documentation/index.html +319 -0
- package/.documentation/installation.html +458 -0
- package/.documentation/js/app.js +794 -0
- package/.documentation/test-web.html +509 -0
- package/README.md +90 -0
- package/config/default-config.json +86 -0
- package/config/settings.json +53 -0
- package/config/settings.local.example.json +16 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +38198 -0
- package/dist/index.js.map +1 -0
- package/package.json +86 -0
- package/templates/agents/action.md +36 -0
- package/templates/agents/efcore/conflicts.md +57 -0
- package/templates/agents/efcore/db-deploy.md +51 -0
- package/templates/agents/efcore/db-reset.md +59 -0
- package/templates/agents/efcore/db-seed.md +56 -0
- package/templates/agents/efcore/db-status.md +43 -0
- package/templates/agents/efcore/migration.md +85 -0
- package/templates/agents/efcore/rebase-snapshot.md +62 -0
- package/templates/agents/efcore/scan.md +60 -0
- package/templates/agents/efcore/squash.md +67 -0
- package/templates/agents/explore-codebase.md +65 -0
- package/templates/agents/explore-docs.md +97 -0
- package/templates/agents/fix-grammar.md +49 -0
- package/templates/agents/gitflow/abort.md +45 -0
- package/templates/agents/gitflow/cleanup.md +85 -0
- package/templates/agents/gitflow/commit.md +40 -0
- package/templates/agents/gitflow/exec.md +48 -0
- package/templates/agents/gitflow/finish.md +92 -0
- package/templates/agents/gitflow/init.md +139 -0
- package/templates/agents/gitflow/merge.md +62 -0
- package/templates/agents/gitflow/plan.md +42 -0
- package/templates/agents/gitflow/pr.md +78 -0
- package/templates/agents/gitflow/review.md +49 -0
- package/templates/agents/gitflow/start.md +61 -0
- package/templates/agents/gitflow/status.md +32 -0
- package/templates/agents/snipper.md +36 -0
- package/templates/agents/websearch.md +46 -0
- package/templates/commands/_resources/formatting-guide.md +124 -0
- package/templates/commands/ai-prompt.md +315 -0
- package/templates/commands/apex/1-analyze.md +100 -0
- package/templates/commands/apex/2-plan.md +145 -0
- package/templates/commands/apex/3-execute.md +171 -0
- package/templates/commands/apex/4-examine.md +116 -0
- package/templates/commands/apex/5-tasks.md +209 -0
- package/templates/commands/apex.md +76 -0
- package/templates/commands/application/create.md +362 -0
- package/templates/commands/application/templates-backend.md +463 -0
- package/templates/commands/application/templates-frontend.md +517 -0
- package/templates/commands/application/templates-i18n.md +478 -0
- package/templates/commands/application/templates-seed.md +362 -0
- package/templates/commands/application.md +303 -0
- package/templates/commands/business-analyse/1-init.md +269 -0
- package/templates/commands/business-analyse/2-discover.md +520 -0
- package/templates/commands/business-analyse/3-analyse.md +408 -0
- package/templates/commands/business-analyse/4-specify.md +598 -0
- package/templates/commands/business-analyse/5-validate.md +326 -0
- package/templates/commands/business-analyse/6-handoff.md +746 -0
- package/templates/commands/business-analyse/7-doc-html.md +602 -0
- package/templates/commands/business-analyse/bug.md +325 -0
- package/templates/commands/business-analyse/change-request.md +368 -0
- package/templates/commands/business-analyse/hotfix.md +200 -0
- package/templates/commands/business-analyse.md +559 -0
- package/templates/commands/controller/create.md +216 -0
- package/templates/commands/controller/postman-templates.md +528 -0
- package/templates/commands/controller/templates.md +600 -0
- package/templates/commands/controller.md +278 -0
- package/templates/commands/debug.md +95 -0
- package/templates/commands/documentation/module.md +202 -0
- package/templates/commands/documentation/templates.md +432 -0
- package/templates/commands/documentation.md +190 -0
- package/templates/commands/efcore/_env-check.md +153 -0
- package/templates/commands/efcore/conflicts.md +269 -0
- package/templates/commands/efcore/db-deploy.md +193 -0
- package/templates/commands/efcore/db-reset.md +426 -0
- package/templates/commands/efcore/db-seed.md +326 -0
- package/templates/commands/efcore/db-status.md +214 -0
- package/templates/commands/efcore/migration.md +388 -0
- package/templates/commands/efcore/rebase-snapshot.md +264 -0
- package/templates/commands/efcore/scan.md +202 -0
- package/templates/commands/efcore/squash.md +298 -0
- package/templates/commands/efcore.md +176 -0
- package/templates/commands/epct.md +69 -0
- package/templates/commands/explain.md +186 -0
- package/templates/commands/explore.md +45 -0
- package/templates/commands/feature-full.md +267 -0
- package/templates/commands/gitflow/1-init.md +1038 -0
- package/templates/commands/gitflow/10-start.md +768 -0
- package/templates/commands/gitflow/11-finish.md +323 -0
- package/templates/commands/gitflow/12-cleanup.md +276 -0
- package/templates/commands/gitflow/13-sync.md +216 -0
- package/templates/commands/gitflow/14-rebase.md +251 -0
- package/templates/commands/gitflow/2-status.md +167 -0
- package/templates/commands/gitflow/3-commit.md +194 -0
- package/templates/commands/gitflow/4-plan.md +145 -0
- package/templates/commands/gitflow/5-exec.md +147 -0
- package/templates/commands/gitflow/6-abort.md +344 -0
- package/templates/commands/gitflow/7-pull-request.md +226 -0
- package/templates/commands/gitflow/8-review.md +176 -0
- package/templates/commands/gitflow/9-merge.md +224 -0
- package/templates/commands/gitflow.md +128 -0
- package/templates/commands/implement.md +663 -0
- package/templates/commands/notification.md +129 -0
- package/templates/commands/oneshot.md +57 -0
- package/templates/commands/quick-search.md +72 -0
- package/templates/commands/review.md +106 -0
- package/templates/commands/utils/test-web-config.md +160 -0
- package/templates/commands/utils/test-web.md +151 -0
- package/templates/commands/workflow.md +193 -0
- package/templates/gitflow/config.json +138 -0
- package/templates/hooks/ef-migration-check.md +139 -0
- package/templates/hooks/hooks.json +15 -0
- package/templates/skills/ai-prompt/SKILL.md +778 -0
- package/templates/skills/application/SKILL.md +563 -0
- package/templates/skills/application/templates-backend.md +450 -0
- package/templates/skills/application/templates-frontend.md +531 -0
- package/templates/skills/application/templates-i18n.md +520 -0
- package/templates/skills/application/templates-seed.md +647 -0
- package/templates/skills/business-analyse/SKILL.md +191 -0
- package/templates/skills/business-analyse/questionnaire.md +283 -0
- package/templates/skills/business-analyse/templates-frd.md +477 -0
- package/templates/skills/business-analyse/templates-react.md +580 -0
- package/templates/skills/controller/SKILL.md +240 -0
- package/templates/skills/controller/postman-templates.md +614 -0
- package/templates/skills/controller/templates.md +1468 -0
- package/templates/skills/documentation/SKILL.md +133 -0
- package/templates/skills/documentation/templates.md +476 -0
- package/templates/skills/feature-full/SKILL.md +838 -0
- package/templates/skills/notification/SKILL.md +555 -0
- package/templates/skills/ui-components/SKILL.md +870 -0
- package/templates/skills/workflow/SKILL.md +582 -0
- package/templates/test-web/api-health.json +38 -0
- package/templates/test-web/minimal.json +19 -0
- package/templates/test-web/npm-package.json +46 -0
- package/templates/test-web/seo-check.json +54 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Scan all branches for migrations with risk analysis
|
|
3
|
+
agent: efcore-scan
|
|
4
|
+
model: sonnet
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# EF Core Scan - Cross-Branch Migration Scanner
|
|
8
|
+
|
|
9
|
+
Scans all active branches to detect migrations and analyze conflict risks.
|
|
10
|
+
|
|
11
|
+
**USAGE:** Before creating a migration or before a merge to check the status of other branches.
|
|
12
|
+
|
|
13
|
+
**SECURITY:** Read-only - no modifications.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## STEP 1: List active worktrees
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Check that worktrees exist
|
|
21
|
+
WORKTREE_BASE=$(git config --get gitflow.worktrees.basePath 2>/dev/null || echo "../worktrees")
|
|
22
|
+
|
|
23
|
+
if [ ! -d "$WORKTREE_BASE" ]; then
|
|
24
|
+
echo "Worktrees structure not found: $WORKTREE_BASE"
|
|
25
|
+
echo "Run /gitflow:1-init to create structure"
|
|
26
|
+
exit 1
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
# List all worktrees
|
|
30
|
+
echo "DETECTED WORKTREES"
|
|
31
|
+
echo "=================="
|
|
32
|
+
git worktree list
|
|
33
|
+
echo ""
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## STEP 2: Scan migrations per branch
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# For each worktree
|
|
42
|
+
for worktree in $(git worktree list --porcelain | grep "^worktree" | cut -d' ' -f2); do
|
|
43
|
+
BRANCH=$(git -C "$worktree" branch --show-current 2>/dev/null)
|
|
44
|
+
|
|
45
|
+
if [ -z "$BRANCH" ]; then
|
|
46
|
+
continue
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
# Find Migrations folder
|
|
50
|
+
MIGRATIONS_DIR=$(find "$worktree" -type d -name "Migrations" 2>/dev/null | head -1)
|
|
51
|
+
|
|
52
|
+
if [ -n "$MIGRATIONS_DIR" ]; then
|
|
53
|
+
# Count migrations
|
|
54
|
+
MIGRATION_COUNT=$(find "$MIGRATIONS_DIR" -name "*.cs" | grep -v "Designer" | grep -v "Snapshot" | wc -l)
|
|
55
|
+
|
|
56
|
+
# ModelSnapshot hash
|
|
57
|
+
SNAPSHOT=$(find "$MIGRATIONS_DIR" -name "*ModelSnapshot.cs" 2>/dev/null | head -1)
|
|
58
|
+
if [ -n "$SNAPSHOT" ]; then
|
|
59
|
+
SNAPSHOT_HASH=$(md5sum "$SNAPSHOT" 2>/dev/null | cut -d' ' -f1 | head -c 8)
|
|
60
|
+
else
|
|
61
|
+
SNAPSHOT_HASH="N/A"
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
echo "$BRANCH | $MIGRATION_COUNT migrations | Snapshot: $SNAPSHOT_HASH"
|
|
65
|
+
fi
|
|
66
|
+
done
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## STEP 3: Compare with develop
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# Get develop's ModelSnapshot hash
|
|
75
|
+
DEVELOP_WORKTREE="$WORKTREE_BASE/develop"
|
|
76
|
+
|
|
77
|
+
if [ -d "$DEVELOP_WORKTREE" ]; then
|
|
78
|
+
DEVELOP_SNAPSHOT=$(find "$DEVELOP_WORKTREE" -name "*ModelSnapshot.cs" 2>/dev/null | head -1)
|
|
79
|
+
|
|
80
|
+
if [ -n "$DEVELOP_SNAPSHOT" ]; then
|
|
81
|
+
DEVELOP_HASH=$(md5sum "$DEVELOP_SNAPSHOT" 2>/dev/null | cut -d' ' -f1)
|
|
82
|
+
echo ""
|
|
83
|
+
echo "REFERENCE: develop ModelSnapshot = ${DEVELOP_HASH:0:8}"
|
|
84
|
+
fi
|
|
85
|
+
fi
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## STEP 4: Analyze conflict risks
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
echo ""
|
|
94
|
+
echo "RISK ANALYSIS"
|
|
95
|
+
echo "==================="
|
|
96
|
+
|
|
97
|
+
# Compare each branch with develop
|
|
98
|
+
for worktree in $(git worktree list --porcelain | grep "^worktree" | cut -d' ' -f2); do
|
|
99
|
+
BRANCH=$(git -C "$worktree" branch --show-current 2>/dev/null)
|
|
100
|
+
|
|
101
|
+
if [ "$BRANCH" = "develop" ] || [ "$BRANCH" = "main" ]; then
|
|
102
|
+
continue
|
|
103
|
+
fi
|
|
104
|
+
|
|
105
|
+
SNAPSHOT=$(find "$worktree" -name "*ModelSnapshot.cs" 2>/dev/null | head -1)
|
|
106
|
+
|
|
107
|
+
if [ -n "$SNAPSHOT" ] && [ -n "$DEVELOP_SNAPSHOT" ]; then
|
|
108
|
+
# Compare snapshots
|
|
109
|
+
if diff -q "$SNAPSHOT" "$DEVELOP_SNAPSHOT" > /dev/null 2>&1; then
|
|
110
|
+
RISK="NONE"
|
|
111
|
+
else
|
|
112
|
+
# Analyze differences
|
|
113
|
+
DIFF_LINES=$(diff "$DEVELOP_SNAPSHOT" "$SNAPSHOT" 2>/dev/null | wc -l)
|
|
114
|
+
|
|
115
|
+
if [ "$DIFF_LINES" -lt 50 ]; then
|
|
116
|
+
RISK="LOW"
|
|
117
|
+
elif [ "$DIFF_LINES" -lt 200 ]; then
|
|
118
|
+
RISK="MEDIUM"
|
|
119
|
+
else
|
|
120
|
+
RISK="HIGH"
|
|
121
|
+
fi
|
|
122
|
+
fi
|
|
123
|
+
|
|
124
|
+
echo "$BRANCH: $RISK"
|
|
125
|
+
fi
|
|
126
|
+
done
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## STEP 5: Recommend merge order
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
echo ""
|
|
135
|
+
echo "RECOMMENDED MERGE ORDER"
|
|
136
|
+
echo "========================="
|
|
137
|
+
echo "1. Branches with RISK=NONE (independent)"
|
|
138
|
+
echo "2. Branches with RISK=LOW (minor modifications)"
|
|
139
|
+
echo "3. Branches with RISK=MEDIUM (order matters)"
|
|
140
|
+
echo "4. Branches with RISK=HIGH (rebase required before merge)"
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Output Format
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
================================================================================
|
|
149
|
+
EF CORE CROSS-BRANCH SCAN
|
|
150
|
+
================================================================================
|
|
151
|
+
|
|
152
|
+
DETECTED WORKTREES (5)
|
|
153
|
+
main/ [main]
|
|
154
|
+
develop/ [develop]
|
|
155
|
+
features/user-auth/ [feature/user-auth]
|
|
156
|
+
features/add-products/ [feature/add-products]
|
|
157
|
+
hotfixes/login-fix/ [hotfix/login-fix]
|
|
158
|
+
|
|
159
|
+
MIGRATIONS PER BRANCH
|
|
160
|
+
develop | 12 migrations | Snapshot: a1b2c3d4 (REFERENCE)
|
|
161
|
+
feature/user-auth | 13 migrations | Snapshot: e5f6g7h8
|
|
162
|
+
feature/add-products | 13 migrations | Snapshot: i9j0k1l2
|
|
163
|
+
hotfix/login-fix | 12 migrations | Snapshot: a1b2c3d4
|
|
164
|
+
|
|
165
|
+
RISK ANALYSIS
|
|
166
|
+
feature/user-auth : LOW (different table)
|
|
167
|
+
feature/add-products : MEDIUM (FK to same table)
|
|
168
|
+
hotfix/login-fix : NONE (snapshot = develop)
|
|
169
|
+
|
|
170
|
+
RECOMMENDED MERGE ORDER
|
|
171
|
+
1. hotfix/login-fix (NONE - direct merge)
|
|
172
|
+
2. feature/user-auth (LOW - merge OK)
|
|
173
|
+
3. feature/add-products (MEDIUM - after user-auth)
|
|
174
|
+
|
|
175
|
+
================================================================================
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Options
|
|
181
|
+
|
|
182
|
+
| Option | Description |
|
|
183
|
+
|--------|-------------|
|
|
184
|
+
| `--json` | JSON output for CI/CD |
|
|
185
|
+
| `--branch <name>` | Scan a specific branch |
|
|
186
|
+
| `--verbose` | Display difference details |
|
|
187
|
+
| `--no-recommend` | Don't display recommendations |
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## CI/CD Usage
|
|
192
|
+
|
|
193
|
+
```yaml
|
|
194
|
+
# GitHub Actions
|
|
195
|
+
- name: Scan EF Core migrations
|
|
196
|
+
run: |
|
|
197
|
+
OUTPUT=$(claude-code "/efcore:scan --json")
|
|
198
|
+
CONFLICTS=$(echo $OUTPUT | jq '.risks[] | select(.level == "HIGH") | length')
|
|
199
|
+
if [ "$CONFLICTS" -gt 0 ]; then
|
|
200
|
+
echo "::warning::High risk migration conflicts detected"
|
|
201
|
+
fi
|
|
202
|
+
```
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Merge multiple migrations into one (for releases)
|
|
3
|
+
agent: efcore-squash
|
|
4
|
+
model: sonnet
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# EF Core Squash - Consolidate Migrations
|
|
8
|
+
|
|
9
|
+
Merges multiple migrations into a single consolidated migration using EF Core CLI only.
|
|
10
|
+
|
|
11
|
+
**USAGE:** Before creating a release branch to clean up migration history.
|
|
12
|
+
|
|
13
|
+
**WARNING:** This operation is **DESTRUCTIVE**. Migration history will be lost.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## RÈGLES DE CONFORMITÉ (OBLIGATOIRE)
|
|
18
|
+
|
|
19
|
+
> **INTERDIT - Violations CLAUDE.md:**
|
|
20
|
+
> - ❌ Génération de scripts SQL dans le repository (`./scripts/migrations/*.sql`)
|
|
21
|
+
> - ❌ Fichiers .sql versionnés dans Git
|
|
22
|
+
> - ❌ `migrationBuilder.Sql()` avec SQL brut
|
|
23
|
+
>
|
|
24
|
+
> **OBLIGATOIRE - Méthodes autorisées:**
|
|
25
|
+
> - ✅ `dotnet ef migrations add` pour créer la migration consolidée
|
|
26
|
+
> - ✅ `dotnet ef migrations remove` pour supprimer les anciennes
|
|
27
|
+
> - ✅ Backup des fichiers .cs dans `.claude/gitflow/backup/` (non versionné)
|
|
28
|
+
>
|
|
29
|
+
> **Contact support:** support@atlshub.ch
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## STEP 1: Check prerequisites
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Check branch
|
|
37
|
+
CURRENT_BRANCH=$(git branch --show-current)
|
|
38
|
+
echo "Current branch: $CURRENT_BRANCH"
|
|
39
|
+
|
|
40
|
+
# Check clean state
|
|
41
|
+
if [ -n "$(git status --porcelain)" ]; then
|
|
42
|
+
echo "ERROR: Working directory not clean"
|
|
43
|
+
exit 1
|
|
44
|
+
fi
|
|
45
|
+
|
|
46
|
+
# Find EF Core projects
|
|
47
|
+
STARTUP_PROJECT=$(find . -name "*.Api.csproj" -o -name "*Web.csproj" | head -1)
|
|
48
|
+
INFRA_PROJECT=$(find . -name "*Infrastructure.csproj" | head -1)
|
|
49
|
+
|
|
50
|
+
if [ -z "$INFRA_PROJECT" ]; then
|
|
51
|
+
INFRA_PROJECT=$(find . -name "*.csproj" -exec grep -l "Microsoft.EntityFrameworkCore" {} \; | head -1)
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
PROJECT_DIR=$(dirname "$INFRA_PROJECT")
|
|
55
|
+
MIGRATIONS_DIR="$PROJECT_DIR/Migrations"
|
|
56
|
+
|
|
57
|
+
# List migrations
|
|
58
|
+
ALL_MIGRATIONS=$(find "$MIGRATIONS_DIR" -name "*.cs" 2>/dev/null | grep -v "Designer" | grep -v "Snapshot" | sort)
|
|
59
|
+
MIGRATION_COUNT=$(echo "$ALL_MIGRATIONS" | grep -c "." || echo "0")
|
|
60
|
+
|
|
61
|
+
echo "Migrations found: $MIGRATION_COUNT"
|
|
62
|
+
echo "Project directory: $PROJECT_DIR"
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## STEP 2: Request confirmation
|
|
68
|
+
|
|
69
|
+
```javascript
|
|
70
|
+
AskUserQuestion({
|
|
71
|
+
questions: [{
|
|
72
|
+
question: "You are about to merge " + MIGRATION_COUNT + " migrations into one. This operation is DESTRUCTIVE. Continue?",
|
|
73
|
+
header: "Squash",
|
|
74
|
+
options: [
|
|
75
|
+
{ label: "Yes, squash all", description: "Merge all migrations into one" },
|
|
76
|
+
{ label: "Cancel", description: "Do nothing" }
|
|
77
|
+
],
|
|
78
|
+
multiSelect: false
|
|
79
|
+
}]
|
|
80
|
+
})
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## STEP 3: Full backup (local only - NOT in repository)
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# Create backup in .claude directory (gitignored)
|
|
89
|
+
BACKUP_DIR=".claude/gitflow/backup/migrations/squash_$(date +%Y%m%d_%H%M%S)"
|
|
90
|
+
mkdir -p "$BACKUP_DIR"
|
|
91
|
+
|
|
92
|
+
echo "Backup to $BACKUP_DIR (local only, not in Git)"
|
|
93
|
+
cp "$MIGRATIONS_DIR"/*.cs "$BACKUP_DIR/" 2>/dev/null
|
|
94
|
+
echo " $(ls -1 "$BACKUP_DIR" | wc -l) files backed up"
|
|
95
|
+
|
|
96
|
+
# Keep ModelSnapshot for reference
|
|
97
|
+
cp "$MIGRATIONS_DIR"/*ModelSnapshot.cs "$BACKUP_DIR/ModelSnapshot_backup.cs" 2>/dev/null
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## STEP 4: Delete all migrations
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
echo "Deleting migrations..."
|
|
106
|
+
|
|
107
|
+
# Delete all migration files (except ModelSnapshot)
|
|
108
|
+
for file in $(find "$MIGRATIONS_DIR" -name "*.cs" -not -name "*ModelSnapshot.cs" 2>/dev/null); do
|
|
109
|
+
rm -f "$file"
|
|
110
|
+
echo " - $(basename "$file")"
|
|
111
|
+
done
|
|
112
|
+
|
|
113
|
+
# Also delete Designer files
|
|
114
|
+
for file in $(find "$MIGRATIONS_DIR" -name "*.Designer.cs" 2>/dev/null); do
|
|
115
|
+
rm -f "$file"
|
|
116
|
+
echo " - $(basename "$file")"
|
|
117
|
+
done
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## STEP 5: Create consolidated migration
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# Version
|
|
126
|
+
VERSION=$(grep -oP '(?<=<Version>).*(?=</Version>)' "$INFRA_PROJECT" 2>/dev/null | head -1 || echo "1.0.0")
|
|
127
|
+
VERSION_CLEAN=$(echo "$VERSION" | sed 's/\./_/g')
|
|
128
|
+
|
|
129
|
+
# Migration name
|
|
130
|
+
if [[ "$CURRENT_BRANCH" == release/* ]]; then
|
|
131
|
+
MIGRATION_NAME="Release_${VERSION_CLEAN}_Initial"
|
|
132
|
+
else
|
|
133
|
+
MIGRATION_NAME="Consolidated_${VERSION_CLEAN}_AllMigrations"
|
|
134
|
+
fi
|
|
135
|
+
|
|
136
|
+
echo ""
|
|
137
|
+
echo "Creating consolidated migration: $MIGRATION_NAME"
|
|
138
|
+
|
|
139
|
+
dotnet ef migrations add "$MIGRATION_NAME" \
|
|
140
|
+
--project "$INFRA_PROJECT" \
|
|
141
|
+
--startup-project "$STARTUP_PROJECT" \
|
|
142
|
+
--verbose
|
|
143
|
+
|
|
144
|
+
if [ $? -eq 0 ]; then
|
|
145
|
+
echo " Migration created successfully"
|
|
146
|
+
else
|
|
147
|
+
echo " ERROR - restoring backup"
|
|
148
|
+
cp "$BACKUP_DIR"/*.cs "$MIGRATIONS_DIR/"
|
|
149
|
+
exit 1
|
|
150
|
+
fi
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## STEP 6: Validation (NO SQL script generation)
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
echo ""
|
|
159
|
+
echo "Validation..."
|
|
160
|
+
|
|
161
|
+
# Build
|
|
162
|
+
dotnet build --no-restore
|
|
163
|
+
if [ $? -ne 0 ]; then
|
|
164
|
+
echo " ERROR: Build failed"
|
|
165
|
+
echo " Restoring backup..."
|
|
166
|
+
cp "$BACKUP_DIR"/*.cs "$MIGRATIONS_DIR/"
|
|
167
|
+
exit 1
|
|
168
|
+
fi
|
|
169
|
+
echo " Build OK"
|
|
170
|
+
|
|
171
|
+
# Verify migration can be listed
|
|
172
|
+
dotnet ef migrations list \
|
|
173
|
+
--project "$INFRA_PROJECT" \
|
|
174
|
+
--startup-project "$STARTUP_PROJECT" \
|
|
175
|
+
--no-build 2>/dev/null
|
|
176
|
+
|
|
177
|
+
if [ $? -ne 0 ]; then
|
|
178
|
+
echo " ERROR: Migration list failed"
|
|
179
|
+
exit 1
|
|
180
|
+
fi
|
|
181
|
+
echo " Migration list OK"
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## STEP 7: Summary
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
================================================================================
|
|
190
|
+
SQUASH COMPLETE
|
|
191
|
+
================================================================================
|
|
192
|
+
|
|
193
|
+
BRANCH: {current_branch}
|
|
194
|
+
BACKUP: {backup_dir} (local only)
|
|
195
|
+
|
|
196
|
+
BEFORE:
|
|
197
|
+
Migrations: {old_count}
|
|
198
|
+
|
|
199
|
+
AFTER:
|
|
200
|
+
Migration: {migration_name}
|
|
201
|
+
|
|
202
|
+
COMPLIANT: ✓ EF Core CLI only (no SQL scripts in repository)
|
|
203
|
+
|
|
204
|
+
================================================================================
|
|
205
|
+
IMPORTANT - PRODUCTION DEPLOYMENT
|
|
206
|
+
================================================================================
|
|
207
|
+
|
|
208
|
+
Pour déployer en production, vous avez DEUX options:
|
|
209
|
+
|
|
210
|
+
OPTION 1 - EF Core CLI (Recommandé):
|
|
211
|
+
────────────────────────────────────────────────────────────────────────────────
|
|
212
|
+
dotnet ef database update {migration_name} \
|
|
213
|
+
--project "$INFRA_PROJECT" \
|
|
214
|
+
--startup-project "$STARTUP_PROJECT" \
|
|
215
|
+
--connection "Server=...;Database=...;..."
|
|
216
|
+
────────────────────────────────────────────────────────────────────────────────
|
|
217
|
+
|
|
218
|
+
OPTION 2 - Si migrations déjà appliquées (mark as applied):
|
|
219
|
+
────────────────────────────────────────────────────────────────────────────────
|
|
220
|
+
# Insérer manuellement dans __EFMigrationsHistory via SSMS/Azure
|
|
221
|
+
# INSERT INTO __EFMigrationsHistory (MigrationId, ProductVersion)
|
|
222
|
+
# VALUES ('{migration_name}', '10.0.0')
|
|
223
|
+
────────────────────────────────────────────────────────────────────────────────
|
|
224
|
+
|
|
225
|
+
⚠️ NE PAS générer de scripts SQL dans le repository!
|
|
226
|
+
Utilisez toujours EF Core CLI pour les déploiements.
|
|
227
|
+
|
|
228
|
+
================================================================================
|
|
229
|
+
NEXT STEPS
|
|
230
|
+
================================================================================
|
|
231
|
+
|
|
232
|
+
1. Vérifier le contenu de la migration consolidée
|
|
233
|
+
2. Tester sur dev DB: /efcore:db-reset && /efcore:db-deploy
|
|
234
|
+
3. Commit: /gitflow:3-commit
|
|
235
|
+
|
|
236
|
+
================================================================================
|
|
237
|
+
RESTORE (if needed)
|
|
238
|
+
================================================================================
|
|
239
|
+
|
|
240
|
+
cp {backup_dir}/*.cs {migrations_dir}/
|
|
241
|
+
|
|
242
|
+
================================================================================
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## Options
|
|
248
|
+
|
|
249
|
+
| Option | Description |
|
|
250
|
+
|--------|-------------|
|
|
251
|
+
| `--no-backup` | Don't create backup (dangerous) |
|
|
252
|
+
| `--name <name>` | Force a migration name |
|
|
253
|
+
| `--keep-snapshot` | Keep current ModelSnapshot |
|
|
254
|
+
| `--dry-run` | Show without executing |
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## When to use Squash
|
|
259
|
+
|
|
260
|
+
| Situation | Use Squash? |
|
|
261
|
+
|-----------|-------------|
|
|
262
|
+
| Before release | YES - clean up history |
|
|
263
|
+
| After merging multiple features | YES - consolidate |
|
|
264
|
+
| In production | NO - use EF Core CLI directly |
|
|
265
|
+
| Feature branch in progress | CAUTION - prefer rebase-snapshot |
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## Forbidden Patterns
|
|
270
|
+
|
|
271
|
+
```
|
|
272
|
+
❌ INTERDIT - Ne jamais faire:
|
|
273
|
+
────────────────────────────────────────────────────────────────────────────────
|
|
274
|
+
# Génération de script SQL dans le repo
|
|
275
|
+
dotnet ef migrations script -o ./scripts/migrations/*.sql
|
|
276
|
+
|
|
277
|
+
# Stockage de fichiers .sql versionnés
|
|
278
|
+
./scripts/migrations/Release_1_0_0.sql
|
|
279
|
+
./scripts/seed.sql
|
|
280
|
+
────────────────────────────────────────────────────────────────────────────────
|
|
281
|
+
|
|
282
|
+
✅ CORRECT - Toujours utiliser:
|
|
283
|
+
────────────────────────────────────────────────────────────────────────────────
|
|
284
|
+
# EF Core CLI pour déploiement
|
|
285
|
+
dotnet ef database update
|
|
286
|
+
|
|
287
|
+
# Backup local uniquement (gitignored)
|
|
288
|
+
.claude/gitflow/backup/migrations/
|
|
289
|
+
────────────────────────────────────────────────────────────────────────────────
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## Support
|
|
295
|
+
|
|
296
|
+
> **Questions ou problèmes avec le squash EF Core?**
|
|
297
|
+
>
|
|
298
|
+
> 📧 **support@atlshub.ch**
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: EF Core Commands - Migration and database management
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# EF Core Commands
|
|
6
|
+
|
|
7
|
+
Set of commands to manage Entity Framework Core: migrations, database, and seeding.
|
|
8
|
+
|
|
9
|
+
## Available Commands
|
|
10
|
+
|
|
11
|
+
### Migrations
|
|
12
|
+
|
|
13
|
+
| Command | Description | Risk |
|
|
14
|
+
|---------|-------------|------|
|
|
15
|
+
| `/efcore:migration` | Create/recreate migration (1 per feature) | Low |
|
|
16
|
+
| `/efcore:db-status` | Show migration status | None (read-only) |
|
|
17
|
+
| `/efcore:db-deploy` | Apply migrations | Low |
|
|
18
|
+
| `/efcore:db-seed` | Populate with data | Low |
|
|
19
|
+
| `/efcore:db-reset` | Drop + Recreate database | **HIGH** |
|
|
20
|
+
|
|
21
|
+
### Cross-Branch (v1.2)
|
|
22
|
+
|
|
23
|
+
| Command | Description | Risk |
|
|
24
|
+
|---------|-------------|------|
|
|
25
|
+
| `/efcore:scan` | Scan migrations across all branches | None (read-only) |
|
|
26
|
+
| `/efcore:conflicts` | Analyze potential conflicts (BLOCKING) | None (read-only) |
|
|
27
|
+
| `/efcore:rebase-snapshot` | Rebase ModelSnapshot on develop | Medium |
|
|
28
|
+
| `/efcore:squash` | Merge multiple migrations into one | **HIGH** |
|
|
29
|
+
|
|
30
|
+
## Golden Rule: 1 Migration per Feature
|
|
31
|
+
|
|
32
|
+
**Never accumulate multiple migrations on a feature.** If you modify the model:
|
|
33
|
+
1. Delete the existing migration
|
|
34
|
+
2. Recreate it with `/efcore:migration`
|
|
35
|
+
|
|
36
|
+
The `/efcore:migration` command handles this automatically.
|
|
37
|
+
|
|
38
|
+
## Migration Naming
|
|
39
|
+
|
|
40
|
+
Pattern: `{BranchType}_{Version}_{BranchName}_{Description}`
|
|
41
|
+
|
|
42
|
+
| Branch | Version | Description | Generated Name |
|
|
43
|
+
|--------|---------|-------------|----------------|
|
|
44
|
+
| feature/user-auth | 1.2.0 | AddRolesTable | `Feature_1_2_0_UserAuth_AddRolesTable` |
|
|
45
|
+
| hotfix/login-fix | 1.2.1 | FixNullEmail | `Hotfix_1_2_1_LoginFix_FixNullEmail` |
|
|
46
|
+
| release/v1.3.0 | 1.3.0 | Initial | `Release_1_3_0_Initial` |
|
|
47
|
+
|
|
48
|
+
## Typical Workflow
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
1. /gitflow:10-start feature xxx → Create worktree + appsettings.Local.json
|
|
52
|
+
2. /efcore:db-deploy → Apply existing migrations
|
|
53
|
+
3. ... model modifications ...
|
|
54
|
+
4. /efcore:migration → Create THE migration for this feature
|
|
55
|
+
5. /efcore:db-deploy → Apply to local DB
|
|
56
|
+
6. /gitflow:3-commit → Commit
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Cross-Branch Workflow (v1.2)
|
|
60
|
+
|
|
61
|
+
With GitFlow worktrees, multiple branches can have migrations in parallel. To avoid conflicts:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
1. /efcore:scan → Scan all active branches
|
|
65
|
+
2. /efcore:conflicts → Check for conflicts (BLOCKING)
|
|
66
|
+
3. /efcore:rebase-snapshot → If conflict, rebase on develop
|
|
67
|
+
4. /efcore:migration → Create/recreate migration
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Recommended Merge Order
|
|
71
|
+
|
|
72
|
+
The scan analyzes migrations and recommends a merge order:
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
ACTIVE BRANCHES (3)
|
|
76
|
+
--------------------
|
|
77
|
+
feature/user-roles +1 migration Conflict: NONE
|
|
78
|
+
feature/add-products +1 migration Conflict: POTENTIAL
|
|
79
|
+
feature/orders +2 migrations Conflict: HIGH
|
|
80
|
+
|
|
81
|
+
RECOMMENDED MERGE ORDER:
|
|
82
|
+
1. feature/user-roles (independent)
|
|
83
|
+
2. feature/add-products (before orders)
|
|
84
|
+
3. feature/orders (rebase required)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Configuration
|
|
88
|
+
|
|
89
|
+
Commands use configuration in `.claude/gitflow/config.json`:
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"efcore": {
|
|
94
|
+
"database": {
|
|
95
|
+
"configFile": "appsettings.Local.json",
|
|
96
|
+
"connectionStringName": "DefaultConnection",
|
|
97
|
+
"provider": "SqlServer"
|
|
98
|
+
},
|
|
99
|
+
"crossBranch": {
|
|
100
|
+
"enabled": true,
|
|
101
|
+
"scanOnMigrationCreate": true,
|
|
102
|
+
"blockOnConflict": true,
|
|
103
|
+
"cacheExpiry": 300
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### crossBranch Options
|
|
110
|
+
|
|
111
|
+
| Option | Description | Default |
|
|
112
|
+
|--------|-------------|---------|
|
|
113
|
+
| `enabled` | Enable cross-branch validation | `true` |
|
|
114
|
+
| `scanOnMigrationCreate` | Scan before `/efcore:migration` | `true` |
|
|
115
|
+
| `blockOnConflict` | Block if conflict detected | `true` |
|
|
116
|
+
| `cacheExpiry` | Scan cache duration (seconds) | `300` |
|
|
117
|
+
|
|
118
|
+
## Environment Selection (NEW)
|
|
119
|
+
|
|
120
|
+
All EF Core commands now display the target database BEFORE execution:
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
================================================================================
|
|
124
|
+
EF CORE - DATABASE DEPLOY
|
|
125
|
+
================================================================================
|
|
126
|
+
|
|
127
|
+
FICHIERS DISPONIBLES:
|
|
128
|
+
- appsettings.json
|
|
129
|
+
- appsettings.Local.json
|
|
130
|
+
- appsettings.Development.json
|
|
131
|
+
|
|
132
|
+
ENVIRONNEMENT: appsettings.Local.json
|
|
133
|
+
|
|
134
|
+
CONNEXION CIBLE:
|
|
135
|
+
Server: localhost
|
|
136
|
+
Database: SmartStack_Dev
|
|
137
|
+
String: Server=localhost;Database=SmartStack_Dev;...
|
|
138
|
+
|
|
139
|
+
================================================================================
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Override Environment
|
|
143
|
+
|
|
144
|
+
Use `--env` flag to target a different environment:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
# Deploy to Development environment
|
|
148
|
+
/efcore:db-deploy --env Development
|
|
149
|
+
|
|
150
|
+
# Reset Staging database
|
|
151
|
+
/efcore:db-reset --env Staging
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Protection Production
|
|
155
|
+
|
|
156
|
+
Commands that modify the database are **automatically blocked** if `appsettings.Production.json` is detected.
|
|
157
|
+
|
|
158
|
+
## appsettings.Local.json File
|
|
159
|
+
|
|
160
|
+
This file contains the local connection string and is **never committed**:
|
|
161
|
+
|
|
162
|
+
```json
|
|
163
|
+
{
|
|
164
|
+
"ConnectionStrings": {
|
|
165
|
+
"DefaultConnection": "Server=localhost;Database=MyApp;Trusted_Connection=true;TrustServerCertificate=true"
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
The file is automatically created by `/gitflow:10-start` and added to `.gitignore`.
|
|
171
|
+
|
|
172
|
+
## Prerequisites
|
|
173
|
+
|
|
174
|
+
- .NET SDK installed
|
|
175
|
+
- EF Core Tools: `dotnet tool install --global dotnet-ef`
|
|
176
|
+
- SQL Server (or other configured provider)
|