@atlashub/smartstack-cli 1.23.0 → 1.24.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/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/skills/check-version/SKILL.md +183 -0
- package/templates/skills/debug/SKILL.md +161 -0
- package/templates/skills/explore/SKILL.md +96 -0
- package/templates/skills/quick-search/SKILL.md +87 -0
- package/templates/skills/refactor/SKILL.md +219 -0
- package/templates/skills/review-code/SKILL.md +72 -44
- package/templates/skills/review-code/references/smartstack-conventions.md +93 -33
- package/templates/skills/ui-components/responsive-guidelines.md +278 -0
- package/templates/skills/utils/SKILL.md +37 -0
- package/templates/{commands/utils → skills/utils/subcommands}/test-web-config.md +35 -43
- package/templates/{commands/utils → skills/utils/subcommands}/test-web.md +25 -53
- package/templates/{commands/validate.md → skills/validate/SKILL.md} +80 -139
- package/templates/commands/check-version.md +0 -267
- package/templates/commands/debug.md +0 -95
- package/templates/commands/efcore/_env-check.md +0 -153
- package/templates/commands/efcore/_shared.md +0 -352
- package/templates/commands/efcore/conflicts.md +0 -90
- package/templates/commands/efcore/db-deploy.md +0 -109
- package/templates/commands/efcore/db-reset.md +0 -180
- package/templates/commands/efcore/db-seed.md +0 -103
- package/templates/commands/efcore/db-status.md +0 -102
- package/templates/commands/efcore/migration.md +0 -186
- package/templates/commands/efcore/rebase-snapshot.md +0 -172
- package/templates/commands/efcore/scan.md +0 -94
- package/templates/commands/efcore/squash.md +0 -329
- package/templates/commands/efcore.md +0 -96
- package/templates/commands/explore.md +0 -45
- package/templates/commands/quick-search.md +0 -72
- package/templates/commands/refactor.md +0 -164
- /package/templates/{commands → skills}/_resources/formatting-guide.md +0 -0
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Rebase ModelSnapshot on develop and regenerate migration
|
|
3
|
-
agent: efcore-rebase-snapshot
|
|
4
|
-
model: sonnet
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# EF Core Rebase-Snapshot
|
|
8
|
-
|
|
9
|
-
> **Ref:** [_shared.md](_shared.md)
|
|
10
|
-
> **Usage:** Après `/efcore:conflicts` HIGH
|
|
11
|
-
> **WARNING:** Modifie fichiers migration. Backup automatique.
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
## STEP 1: Vérifier Prérequis
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
CURRENT_BRANCH=$(git branch --show-current)
|
|
19
|
-
[[ ! $CURRENT_BRANCH =~ ^(feature|release|hotfix)/ ]] && exit 1
|
|
20
|
-
[ -n "$(git status --porcelain)" ] && { echo "Working directory non clean"; exit 1; }
|
|
21
|
-
|
|
22
|
-
# Détecte projet ET DbContext (core vs extensions)
|
|
23
|
-
detect_efcore_project # Appelle detect_dbcontext() automatiquement
|
|
24
|
-
determine_base_branch # Détermine la branche parente
|
|
25
|
-
|
|
26
|
-
echo "DbContext: $DBCONTEXT ($DBCONTEXT_TYPE)"
|
|
27
|
-
echo "Branche parente: $BASE_BRANCH"
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
**Si DbContext non détecté automatiquement :**
|
|
31
|
-
|
|
32
|
-
```javascript
|
|
33
|
-
AskUserQuestion({
|
|
34
|
-
questions: [{
|
|
35
|
-
question: "Quel DbContext utiliser ?",
|
|
36
|
-
header: "DbContext",
|
|
37
|
-
options: [
|
|
38
|
-
{ label: "CoreDbContext", description: "Entités SmartStack" },
|
|
39
|
-
{ label: "ExtensionsDbContext", description: "Entités client" }
|
|
40
|
-
],
|
|
41
|
-
multiSelect: false
|
|
42
|
-
}]
|
|
43
|
-
})
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
---
|
|
47
|
-
|
|
48
|
-
## STEP 2: Backup
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
BACKUP_DIR=".claude/gitflow/backup/migrations/rebase_$(date +%Y%m%d_%H%M%S)"
|
|
52
|
-
mkdir -p "$BACKUP_DIR"
|
|
53
|
-
cp "$MIGRATIONS_DIR"/*.cs "$BACKUP_DIR/"
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
## STEP 3: Identifier Migrations de la Branche
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
# Migrations sur develop
|
|
62
|
-
DEVELOP_MIGRATIONS=$(git show develop:$MIGRATIONS_DIR | grep "\.cs$")
|
|
63
|
-
|
|
64
|
-
# Nouvelles migrations (cette branche seulement)
|
|
65
|
-
for migration in $LOCAL_MIGRATIONS; do
|
|
66
|
-
echo "$DEVELOP_MIGRATIONS" | grep -q "$migration" || BRANCH_MIGRATIONS+=" $migration"
|
|
67
|
-
done
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
---
|
|
71
|
-
|
|
72
|
-
## STEP 4: Reset ModelSnapshot sur Develop
|
|
73
|
-
|
|
74
|
-
```bash
|
|
75
|
-
git fetch origin develop
|
|
76
|
-
git checkout origin/develop -- "$MIGRATIONS_DIR/*ModelSnapshot.cs"
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
---
|
|
80
|
-
|
|
81
|
-
## STEP 5: Supprimer Migrations de la Branche
|
|
82
|
-
|
|
83
|
-
```bash
|
|
84
|
-
for migration in $BRANCH_MIGRATIONS; do
|
|
85
|
-
rm -f "$MIGRATIONS_DIR/${migration%.cs}.cs"
|
|
86
|
-
rm -f "$MIGRATIONS_DIR/${migration%.cs}.Designer.cs"
|
|
87
|
-
done
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
## STEP 6: Régénérer Migration Consolidée
|
|
93
|
-
|
|
94
|
-
**OBLIGATOIRE : Utiliser le MCP pour le nommage conforme**
|
|
95
|
-
|
|
96
|
-
```bash
|
|
97
|
-
# Construire la description
|
|
98
|
-
BRANCH_NAME_CLEAN=$(echo "$CURRENT_BRANCH" | sed 's|.*/||' | sed 's/-/ /g')
|
|
99
|
-
DESCRIPTION="${BRANCH_NAME_CLEAN} Consolidated"
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
**Appel MCP OBLIGATOIRE :**
|
|
103
|
-
|
|
104
|
-
```javascript
|
|
105
|
-
// Obtenir le nom conforme via MCP
|
|
106
|
-
mcp__smartstack__suggest_migration({
|
|
107
|
-
description: DESCRIPTION, // Ex: "user auth Consolidated"
|
|
108
|
-
context: DBCONTEXT_TYPE // "core" ou "extensions" (de detect_dbcontext)
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
// Résultat: core_v1.7.0_001_UserAuthConsolidated
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
**Puis créer la migration :**
|
|
115
|
-
|
|
116
|
-
```bash
|
|
117
|
-
# $MIGRATION_NAME = résultat du MCP
|
|
118
|
-
# $DBCONTEXT = CoreDbContext ou ExtensionsDbContext
|
|
119
|
-
|
|
120
|
-
dotnet ef migrations add "$MIGRATION_NAME" \
|
|
121
|
-
--context "$DBCONTEXT" \
|
|
122
|
-
--project "$INFRA_PROJECT" \
|
|
123
|
-
--startup-project "$STARTUP_PROJECT" \
|
|
124
|
-
-o Persistence/Migrations \
|
|
125
|
-
--verbose
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
> **Convention :** `{context}_v{version}_{sequence}_{Description}` - Jamais de nom hardcodé
|
|
129
|
-
|
|
130
|
-
---
|
|
131
|
-
|
|
132
|
-
## STEP 7: Validation
|
|
133
|
-
|
|
134
|
-
```bash
|
|
135
|
-
dotnet build --no-restore
|
|
136
|
-
dotnet ef migrations script --no-build > /dev/null
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
---
|
|
140
|
-
|
|
141
|
-
## Résumé
|
|
142
|
-
|
|
143
|
-
```
|
|
144
|
-
REBASE-SNAPSHOT - {branch}
|
|
145
|
-
├── Backup: {backup_dir}
|
|
146
|
-
├── Avant: {old_migrations}
|
|
147
|
-
├── Après: {new_migration_name} (Snapshot = develop)
|
|
148
|
-
├── Validations: ✓ Build, ✓ Script
|
|
149
|
-
└── Prochains: /efcore:db-reset, /efcore:db-deploy, /gitflow:3-commit
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
**Si échec:** Backup restauré automatiquement.
|
|
153
|
-
|
|
154
|
-
---
|
|
155
|
-
|
|
156
|
-
## Options
|
|
157
|
-
|
|
158
|
-
| Option | Description |
|
|
159
|
-
|--------|-------------|
|
|
160
|
-
| `--no-backup` | Sans backup (dangereux) |
|
|
161
|
-
| `--name <name>` | Forcer nom migration |
|
|
162
|
-
| `--dry-run` | Afficher sans exécuter |
|
|
163
|
-
|
|
164
|
-
---
|
|
165
|
-
|
|
166
|
-
## Quand utiliser
|
|
167
|
-
|
|
168
|
-
| Situation | Action |
|
|
169
|
-
|-----------|--------|
|
|
170
|
-
| `/efcore:conflicts` HIGH | Utiliser rebase-snapshot |
|
|
171
|
-
| Conflit merge sur ModelSnapshot | Utiliser rebase-snapshot |
|
|
172
|
-
| Plusieurs migrations à consolider | Utiliser rebase-snapshot |
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Scan all branches for migrations with risk analysis
|
|
3
|
-
agent: efcore-scan
|
|
4
|
-
model: sonnet
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# EF Core Scan
|
|
8
|
-
|
|
9
|
-
> **Ref:** [_shared.md](_shared.md)
|
|
10
|
-
> **MCP:** `mcp__smartstack__check_migrations` pour chaque branche
|
|
11
|
-
> **Type:** Read-only, aucune modification
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
## STEP 1: Détecter Worktrees Actifs
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
WORKTREES=$(git worktree list --porcelain | grep "^worktree" | cut -d' ' -f2)
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## STEP 2: Invoquer MCP pour Chaque Branche
|
|
24
|
-
|
|
25
|
-
```
|
|
26
|
-
FOR each branch in [feature/*, hotfix/*, release/*]:
|
|
27
|
-
CALL mcp__smartstack__check_migrations WITH:
|
|
28
|
-
- branch: {branch}
|
|
29
|
-
- compareBranch: "develop"
|
|
30
|
-
STORE result in BRANCH_RESULTS[branch]
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
## STEP 3: Calculer Niveau Risque
|
|
36
|
-
|
|
37
|
-
| Condition | Risque |
|
|
38
|
-
|-----------|--------|
|
|
39
|
-
| Snapshot = develop | NONE |
|
|
40
|
-
| Tables différentes | LOW |
|
|
41
|
-
| FK vers même table | MEDIUM |
|
|
42
|
-
| Même tables/colonnes | HIGH |
|
|
43
|
-
|
|
44
|
-
---
|
|
45
|
-
|
|
46
|
-
## STEP 4: Recommander Ordre Merge
|
|
47
|
-
|
|
48
|
-
```
|
|
49
|
-
1. Branches RISK=NONE (merge immédiat)
|
|
50
|
-
2. Branches RISK=LOW (modifications mineures)
|
|
51
|
-
3. Branches RISK=MEDIUM (ordre important)
|
|
52
|
-
4. Branches RISK=HIGH (rebase requis)
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
---
|
|
56
|
-
|
|
57
|
-
## Résumé
|
|
58
|
-
|
|
59
|
-
```
|
|
60
|
-
SCAN CROSS-BRANCH
|
|
61
|
-
├── Worktrees: {count}
|
|
62
|
-
├── Branches avec migrations: {N}
|
|
63
|
-
├── Conflits: {none/low/medium/high}
|
|
64
|
-
│
|
|
65
|
-
├── ORDRE MERGE RECOMMANDÉ
|
|
66
|
-
│ 1. {branch} - AUCUN risque - ✓ Merge OK
|
|
67
|
-
│ 2. {branch} - FAIBLE risque - ✓ Merge OK
|
|
68
|
-
│ 3. {branch} - MOYEN risque - ⚠ Après #{2}, puis rebase
|
|
69
|
-
│
|
|
70
|
-
└── Prochains: /gitflow:9-merge, /efcore:rebase-snapshot, /efcore:conflicts
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
---
|
|
74
|
-
|
|
75
|
-
## Options
|
|
76
|
-
|
|
77
|
-
| Option | Description |
|
|
78
|
-
|--------|-------------|
|
|
79
|
-
| `--json` | Output JSON pour CI/CD |
|
|
80
|
-
| `--branch <name>` | Scanner branche spécifique |
|
|
81
|
-
| `--verbose` | Détails MCP |
|
|
82
|
-
| `--no-recommend` | Sans recommandations |
|
|
83
|
-
|
|
84
|
-
---
|
|
85
|
-
|
|
86
|
-
## CI/CD Usage
|
|
87
|
-
|
|
88
|
-
```yaml
|
|
89
|
-
- name: Scan EF Core migrations
|
|
90
|
-
run: |
|
|
91
|
-
OUTPUT=$(claude-code "/efcore:scan --json")
|
|
92
|
-
HIGH_RISK=$(echo $OUTPUT | jq '[.branches[] | select(.riskLevel == "HIGH")] | length')
|
|
93
|
-
[ "$HIGH_RISK" -gt 0 ] && echo "::warning::$HIGH_RISK branches HIGH risk"
|
|
94
|
-
```
|
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Merge multiple migrations into one (for releases)
|
|
3
|
-
agent: efcore-squash
|
|
4
|
-
model: sonnet
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# EF Core Squash
|
|
8
|
-
|
|
9
|
-
> **Ref:** [_shared.md](_shared.md) - `determine_base_branch()`, `detect_efcore_project()`
|
|
10
|
-
> **Usage:** Consolider migrations avant merge ou release
|
|
11
|
-
> **WARNING:** DESTRUCTIF - historique migrations perdu
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
## Conformité
|
|
16
|
-
|
|
17
|
-
| INTERDIT | OBLIGATOIRE |
|
|
18
|
-
|----------|-------------|
|
|
19
|
-
| Scripts .sql dans repo | `dotnet ef migrations add` |
|
|
20
|
-
| `migrationBuilder.Sql()` brut | `dotnet ef migrations remove` |
|
|
21
|
-
| Squash sans récupérer snapshot parent | Backup dans `.claude/` (gitignored) |
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
## STEP 0: Déterminer Branche Parente (CRITIQUE)
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
determine_base_branch # Voir _shared.md
|
|
29
|
-
|
|
30
|
-
# Résultat:
|
|
31
|
-
# - BASE_BRANCH = branche parente (develop, main, etc.)
|
|
32
|
-
# - BRANCH_TYPE = type de branche courante
|
|
33
|
-
# - Exit si main/master (BLOQUÉ)
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
| Branche courante | BASE_BRANCH | Action |
|
|
37
|
-
|------------------|-------------|--------|
|
|
38
|
-
| `feature/*` | `develop` | Récupère snapshot develop |
|
|
39
|
-
| `develop` | `main` | Récupère snapshot main |
|
|
40
|
-
| `release/*` | `main` | Récupère snapshot main |
|
|
41
|
-
| `hotfix/*` | `main` | Récupère snapshot main |
|
|
42
|
-
| `main/master` | **BLOQUÉ** | Exit code 1 |
|
|
43
|
-
|
|
44
|
-
---
|
|
45
|
-
|
|
46
|
-
## STEP 1: Vérifier Prérequis
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
CURRENT_BRANCH=$(git branch --show-current)
|
|
50
|
-
[ -n "$(git status --porcelain)" ] && { echo "Working directory non propre"; exit 1; }
|
|
51
|
-
detect_efcore_project # Appelle detect_dbcontext() → $DBCONTEXT, $DBCONTEXT_TYPE, $SCHEMA
|
|
52
|
-
|
|
53
|
-
echo "DbContext: $DBCONTEXT ($DBCONTEXT_TYPE)"
|
|
54
|
-
echo "Schema: $SCHEMA"
|
|
55
|
-
|
|
56
|
-
# Compter migrations LOCALES uniquement (pas celles héritées)
|
|
57
|
-
git fetch origin "$BASE_BRANCH" --quiet
|
|
58
|
-
BASE_MIGRATIONS=$(git ls-tree -r --name-only "origin/$BASE_BRANCH" -- "$MIGRATIONS_DIR" | grep "\.cs$" | grep -v "Designer\|Snapshot")
|
|
59
|
-
LOCAL_MIGRATIONS=$(find "$MIGRATIONS_DIR" -name "*.cs" | grep -v "Designer\|Snapshot" | xargs -I{} basename {})
|
|
60
|
-
|
|
61
|
-
# Migrations propres à cette branche
|
|
62
|
-
BRANCH_ONLY_MIGRATIONS=()
|
|
63
|
-
for mig in $LOCAL_MIGRATIONS; do
|
|
64
|
-
echo "$BASE_MIGRATIONS" | grep -q "$mig" || BRANCH_ONLY_MIGRATIONS+=("$mig")
|
|
65
|
-
done
|
|
66
|
-
|
|
67
|
-
MIGRATION_COUNT=${#BRANCH_ONLY_MIGRATIONS[@]}
|
|
68
|
-
echo "Migrations à consolider: $MIGRATION_COUNT (propres à $CURRENT_BRANCH)"
|
|
69
|
-
echo "Branche parente: $BASE_BRANCH"
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
---
|
|
73
|
-
|
|
74
|
-
## STEP 2: Confirmation Utilisateur
|
|
75
|
-
|
|
76
|
-
```javascript
|
|
77
|
-
AskUserQuestion({
|
|
78
|
-
questions: [{
|
|
79
|
-
question: `Squash ${MIGRATION_COUNT} migrations de ${CURRENT_BRANCH}?
|
|
80
|
-
|
|
81
|
-
Le ModelSnapshot de ${BASE_BRANCH} sera récupéré comme base.
|
|
82
|
-
Vos migrations seront consolidées en UNE seule.
|
|
83
|
-
|
|
84
|
-
Cette opération est DESTRUCTIVE et IRRÉVERSIBLE (sauf backup).`,
|
|
85
|
-
header: "Squash",
|
|
86
|
-
options: [
|
|
87
|
-
{ label: "Oui, squash", description: `Consolider sur base de ${BASE_BRANCH}` },
|
|
88
|
-
{ label: "Voir détails", description: "Afficher migrations concernées" },
|
|
89
|
-
{ label: "Annuler", description: "Ne rien faire" }
|
|
90
|
-
],
|
|
91
|
-
multiSelect: false
|
|
92
|
-
}]
|
|
93
|
-
})
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
---
|
|
97
|
-
|
|
98
|
-
## STEP 3: Backup Local
|
|
99
|
-
|
|
100
|
-
```bash
|
|
101
|
-
BACKUP_DIR=".claude/gitflow/backup/migrations/squash_$(date +%Y%m%d_%H%M%S)"
|
|
102
|
-
mkdir -p "$BACKUP_DIR"
|
|
103
|
-
cp "$MIGRATIONS_DIR"/*.cs "$BACKUP_DIR/"
|
|
104
|
-
echo "Backup: $BACKUP_DIR"
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
---
|
|
108
|
-
|
|
109
|
-
## STEP 4: Récupérer Migrations ET Snapshot de la Branche Parente (CRUCIAL)
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
# Sauvegarder snapshot actuel
|
|
113
|
-
cp "$MIGRATIONS_DIR"/*ModelSnapshot.cs "$BACKUP_DIR/"
|
|
114
|
-
|
|
115
|
-
# Récupérer TOUTES les migrations de la branche parente
|
|
116
|
-
git fetch origin "$BASE_BRANCH" --quiet
|
|
117
|
-
|
|
118
|
-
# 1. Récupérer le ModelSnapshot
|
|
119
|
-
git checkout "origin/$BASE_BRANCH" -- "$MIGRATIONS_DIR"/*ModelSnapshot.cs
|
|
120
|
-
|
|
121
|
-
# 2. Récupérer les fichiers de migration de la branche parente
|
|
122
|
-
# (pour ne pas perdre les migrations déjà présentes sur develop/main)
|
|
123
|
-
for base_mig in $BASE_MIGRATIONS; do
|
|
124
|
-
base_file=$(basename "$base_mig")
|
|
125
|
-
base_name="${base_file%.cs}"
|
|
126
|
-
|
|
127
|
-
# Récupérer le fichier migration ET son Designer
|
|
128
|
-
git checkout "origin/$BASE_BRANCH" -- "$MIGRATIONS_DIR/${base_name}.cs" 2>/dev/null || true
|
|
129
|
-
git checkout "origin/$BASE_BRANCH" -- "$MIGRATIONS_DIR/${base_name}.Designer.cs" 2>/dev/null || true
|
|
130
|
-
done
|
|
131
|
-
|
|
132
|
-
echo "Récupéré depuis origin/$BASE_BRANCH:"
|
|
133
|
-
echo " - ModelSnapshot"
|
|
134
|
-
echo " - $(echo "$BASE_MIGRATIONS" | wc -l) migrations"
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
**Pourquoi c'est crucial:**
|
|
138
|
-
- Le snapshot de `$BASE_BRANCH` contient l'état VALIDÉ et COMPLET
|
|
139
|
-
- Les **migrations existantes** de `$BASE_BRANCH` doivent être conservées
|
|
140
|
-
- Les migrations parallèles sur d'autres branches sont incluses
|
|
141
|
-
- Évite la perte d'information de schéma (cf. [Bokio best practices](https://www.bokio.se/engineering-blog/how-to-squash-ef-core-migrations/))
|
|
142
|
-
|
|
143
|
-
**Résultat attendu:**
|
|
144
|
-
```
|
|
145
|
-
feature/multitenant après squash:
|
|
146
|
-
├── core_v1.8.0_001_InitialSchema.cs ← De develop (conservé)
|
|
147
|
-
├── core_v1.8.0_001_InitialSchema.Designer.cs
|
|
148
|
-
├── core_v1.9.0_001_MultitenantConsolidated.cs ← Squash de la feature (MCP)
|
|
149
|
-
├── core_v1.9.0_001_MultitenantConsolidated.Designer.cs
|
|
150
|
-
└── CoreDbContextModelSnapshot.cs ← De develop
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
⚠️ **ATTENTION:** Si le résultat ne montre pas les migrations de develop, le squash a échoué!
|
|
154
|
-
|
|
155
|
-
---
|
|
156
|
-
|
|
157
|
-
## STEP 5: Supprimer Migrations de la Branche (pas celles héritées)
|
|
158
|
-
|
|
159
|
-
```bash
|
|
160
|
-
# Supprimer UNIQUEMENT les migrations propres à cette branche
|
|
161
|
-
for mig in "${BRANCH_ONLY_MIGRATIONS[@]}"; do
|
|
162
|
-
rm -f "$MIGRATIONS_DIR"/${mig%.cs}.cs
|
|
163
|
-
rm -f "$MIGRATIONS_DIR"/${mig%.cs}.Designer.cs
|
|
164
|
-
done
|
|
165
|
-
|
|
166
|
-
echo "Supprimé: ${#BRANCH_ONLY_MIGRATIONS[@]} migrations"
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
---
|
|
170
|
-
|
|
171
|
-
## STEP 6: Créer Migration Consolidée
|
|
172
|
-
|
|
173
|
-
**OBLIGATOIRE: Utiliser le MCP pour le nommage conforme**
|
|
174
|
-
|
|
175
|
-
```bash
|
|
176
|
-
# Construire la description selon le contexte
|
|
177
|
-
case "$BRANCH_TYPE" in
|
|
178
|
-
feature)
|
|
179
|
-
BRANCH_NAME=$(echo "$CURRENT_BRANCH" | sed 's|feature/||' | sed 's/-/ /g')
|
|
180
|
-
DESCRIPTION="${BRANCH_NAME} Consolidated"
|
|
181
|
-
;;
|
|
182
|
-
release)
|
|
183
|
-
VERSION=$(echo "$CURRENT_BRANCH" | sed 's|release/||')
|
|
184
|
-
DESCRIPTION="Release ${VERSION} Initial"
|
|
185
|
-
;;
|
|
186
|
-
hotfix)
|
|
187
|
-
VERSION=$(echo "$CURRENT_BRANCH" | sed 's|hotfix/||')
|
|
188
|
-
DESCRIPTION="Hotfix ${VERSION} Fix"
|
|
189
|
-
;;
|
|
190
|
-
develop)
|
|
191
|
-
DESCRIPTION="Develop Consolidated"
|
|
192
|
-
;;
|
|
193
|
-
*)
|
|
194
|
-
DESCRIPTION="Consolidated"
|
|
195
|
-
;;
|
|
196
|
-
esac
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
**Appel MCP OBLIGATOIRE:**
|
|
200
|
-
|
|
201
|
-
```javascript
|
|
202
|
-
// $DESCRIPTION = construit ci-dessus (ex: "multitenant Consolidated")
|
|
203
|
-
// $DBCONTEXT_TYPE = "core" ou "extensions" (de detect_dbcontext)
|
|
204
|
-
|
|
205
|
-
mcp__smartstack__suggest_migration({
|
|
206
|
-
description: DESCRIPTION,
|
|
207
|
-
context: DBCONTEXT_TYPE // JAMAIS hardcodé!
|
|
208
|
-
})
|
|
209
|
-
|
|
210
|
-
// Résultat: core_v1.9.0_001_MultitenantConsolidated
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
> **INTERDIT :** Calculer le nom manuellement ou hardcoder le context.
|
|
214
|
-
|
|
215
|
-
**Puis créer la migration:**
|
|
216
|
-
|
|
217
|
-
```bash
|
|
218
|
-
# MIGRATION_NAME = résultat du MCP (ex: core_v1.9.0_001_MultitenantConsolidated)
|
|
219
|
-
# DBCONTEXT = CoreDbContext ou ExtensionsDbContext (de detect_dbcontext)
|
|
220
|
-
|
|
221
|
-
dotnet ef migrations add "$MIGRATION_NAME" \
|
|
222
|
-
--context "$DBCONTEXT" \
|
|
223
|
-
--project "$INFRA_PROJECT" \
|
|
224
|
-
--startup-project "$STARTUP_PROJECT" \
|
|
225
|
-
-o Persistence/Migrations \
|
|
226
|
-
--verbose
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
> **Convention:** `{context}_v{version}_{sequence}_{Description}` - Jamais de nom hardcodé
|
|
230
|
-
|
|
231
|
-
---
|
|
232
|
-
|
|
233
|
-
## STEP 7: Validation
|
|
234
|
-
|
|
235
|
-
```bash
|
|
236
|
-
# Build
|
|
237
|
-
dotnet build --no-restore
|
|
238
|
-
[ $? -ne 0 ] && { echo "Build FAILED - restauration backup"; cp "$BACKUP_DIR"/*.cs "$MIGRATIONS_DIR/"; exit 1; }
|
|
239
|
-
|
|
240
|
-
# Liste migrations
|
|
241
|
-
dotnet ef migrations list --no-build
|
|
242
|
-
|
|
243
|
-
# Générer script (validation)
|
|
244
|
-
dotnet ef migrations script --no-build --idempotent > /dev/null
|
|
245
|
-
[ $? -ne 0 ] && { echo "Script generation FAILED"; exit 1; }
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
---
|
|
249
|
-
|
|
250
|
-
## Résumé
|
|
251
|
-
|
|
252
|
-
```
|
|
253
|
-
SQUASH - {CURRENT_BRANCH}
|
|
254
|
-
Base: {BASE_BRANCH}
|
|
255
|
-
Backup: {BACKUP_DIR}
|
|
256
|
-
|
|
257
|
-
Récupéré de {BASE_BRANCH}:
|
|
258
|
-
- ModelSnapshot
|
|
259
|
-
- {BASE_MIGRATION_COUNT} migrations (conservées)
|
|
260
|
-
|
|
261
|
-
Consolidé:
|
|
262
|
-
- Avant: {MIGRATION_COUNT} migrations (propres à la branche)
|
|
263
|
-
- Après: 1 migration ({MIGRATION_NAME})
|
|
264
|
-
|
|
265
|
-
Total final: {BASE_MIGRATION_COUNT + 1} migrations
|
|
266
|
-
Conformité: MCP suggest_migration, EF Core CLI, Snapshot parent
|
|
267
|
-
|
|
268
|
-
Prochains: /efcore:db-reset, /efcore:db-deploy, /gitflow:3-commit
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
**Si échec:** Restaurer avec `cp $BACKUP_DIR/*.cs $MIGRATIONS_DIR/`
|
|
272
|
-
|
|
273
|
-
---
|
|
274
|
-
|
|
275
|
-
## Options
|
|
276
|
-
|
|
277
|
-
| Option | Description |
|
|
278
|
-
|--------|-------------|
|
|
279
|
-
| `--no-backup` | Sans backup (dangereux) |
|
|
280
|
-
| `--name <name>` | Forcer nom migration |
|
|
281
|
-
| `--dry-run` | Afficher sans exécuter |
|
|
282
|
-
| `--include-inherited` | Inclure migrations héritées (rare) |
|
|
283
|
-
|
|
284
|
-
---
|
|
285
|
-
|
|
286
|
-
## Matrice d'Utilisation
|
|
287
|
-
|
|
288
|
-
| Situation | Utiliser squash? | Alternative |
|
|
289
|
-
|-----------|------------------|-------------|
|
|
290
|
-
| Feature avec plusieurs migrations | OUI | `/efcore:rebase-snapshot` |
|
|
291
|
-
| Avant merge feature vers develop | OUI (recommandé) | - |
|
|
292
|
-
| Sur develop avant release | Créer release d'abord | `/gitflow:10-start release` |
|
|
293
|
-
| Sur release avant tag | OUI (idéal) | - |
|
|
294
|
-
| Hotfix urgent | OUI | - |
|
|
295
|
-
| Sur main/master | **JAMAIS** | BLOQUÉ automatiquement |
|
|
296
|
-
|
|
297
|
-
---
|
|
298
|
-
|
|
299
|
-
## Workflow Complet Recommandé
|
|
300
|
-
|
|
301
|
-
```
|
|
302
|
-
1. feature/* : développement avec N migrations
|
|
303
|
-
|
|
304
|
-
2. Avant merge sur develop:
|
|
305
|
-
/efcore:squash
|
|
306
|
-
→ Récupère snapshot develop
|
|
307
|
-
→ Consolide en 1 migration
|
|
308
|
-
|
|
309
|
-
3. Merge sur develop:
|
|
310
|
-
/gitflow:7-pull-request
|
|
311
|
-
/gitflow:9-merge
|
|
312
|
-
|
|
313
|
-
4. Avant release:
|
|
314
|
-
/gitflow:10-start release vX.Y.Z
|
|
315
|
-
/efcore:squash (sur release/*)
|
|
316
|
-
→ Récupère snapshot main
|
|
317
|
-
→ Consolide TOUT en Release_X_Y_Z_Initial
|
|
318
|
-
|
|
319
|
-
5. Finaliser:
|
|
320
|
-
/gitflow:11-finish
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
---
|
|
324
|
-
|
|
325
|
-
## Sources Best Practices
|
|
326
|
-
|
|
327
|
-
- [Microsoft - Managing Migrations](https://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations/managing)
|
|
328
|
-
- [Bokio - How to squash EF Core migrations](https://www.bokio.se/engineering-blog/how-to-squash-ef-core-migrations/)
|
|
329
|
-
- [Mitchel Sellers - Squashing EF Core Migrations Safely](https://www.mitchelsellers.com/blog/article/squashing-ef-core-migrations-safely)
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: EF Core Commands - Migration and database management
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# EF Core Commands
|
|
6
|
-
|
|
7
|
-
> **Ref:** Fonctions communes dans [efcore/_shared.md](efcore/_shared.md)
|
|
8
|
-
> **MCP:** `mcp__smartstack__check_migrations` pour analyse conflits
|
|
9
|
-
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
## Commandes Disponibles
|
|
13
|
-
|
|
14
|
-
### Migrations
|
|
15
|
-
|
|
16
|
-
| Commande | Description | Risque |
|
|
17
|
-
|----------|-------------|--------|
|
|
18
|
-
| `/efcore:migration` | Créer/recréer migration (1 par feature) | Low |
|
|
19
|
-
| `/efcore:db-status` | Afficher statut migrations | None |
|
|
20
|
-
| `/efcore:db-deploy` | Appliquer migrations | Low |
|
|
21
|
-
| `/efcore:db-seed` | Peupler avec données | Low |
|
|
22
|
-
| `/efcore:db-reset` | Drop + Recreate DB | **HIGH** |
|
|
23
|
-
|
|
24
|
-
### Cross-Branch
|
|
25
|
-
|
|
26
|
-
| Commande | Description | Risque |
|
|
27
|
-
|----------|-------------|--------|
|
|
28
|
-
| `/efcore:scan` | Scanner toutes les branches | None |
|
|
29
|
-
| `/efcore:conflicts` | Analyser conflits (BLOQUANT) | None |
|
|
30
|
-
| `/efcore:rebase-snapshot` | Rebaser ModelSnapshot sur develop | Medium |
|
|
31
|
-
| `/efcore:squash` | Fusionner migrations | **HIGH** |
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
## Règle d'Or: 1 Migration par Feature
|
|
36
|
-
|
|
37
|
-
Si modification du modèle: supprimer et recréer la migration.
|
|
38
|
-
|
|
39
|
-
---
|
|
40
|
-
|
|
41
|
-
## Workflow Typique
|
|
42
|
-
|
|
43
|
-
```
|
|
44
|
-
1. /gitflow:10-start feature xxx → Worktree + appsettings.Local.json
|
|
45
|
-
2. /efcore:db-deploy → Appliquer migrations existantes
|
|
46
|
-
3. ... modifications modèle ...
|
|
47
|
-
4. /efcore:migration → Créer LA migration
|
|
48
|
-
5. /efcore:db-deploy → Appliquer localement
|
|
49
|
-
6. /gitflow:3-commit → Commit
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
---
|
|
53
|
-
|
|
54
|
-
## Workflow Cross-Branch
|
|
55
|
-
|
|
56
|
-
```
|
|
57
|
-
1. /efcore:scan → Scanner branches actives
|
|
58
|
-
2. /efcore:conflicts → Vérifier conflits (BLOQUANT)
|
|
59
|
-
3. /efcore:rebase-snapshot → Si conflit, rebaser sur develop
|
|
60
|
-
4. /efcore:migration → Créer/recréer migration
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
---
|
|
64
|
-
|
|
65
|
-
## Sélection Environnement
|
|
66
|
-
|
|
67
|
-
Toutes les commandes affichent la base cible AVANT exécution.
|
|
68
|
-
|
|
69
|
-
| Priorité | Fichier |
|
|
70
|
-
|----------|---------|
|
|
71
|
-
| 1 | `--env {Environment}` flag |
|
|
72
|
-
| 2 | `appsettings.Local.json` (défaut) |
|
|
73
|
-
|
|
74
|
-
**Protection:** Commandes destructives bloquées si Production détecté.
|
|
75
|
-
|
|
76
|
-
---
|
|
77
|
-
|
|
78
|
-
## appsettings.Local.json
|
|
79
|
-
|
|
80
|
-
```json
|
|
81
|
-
{
|
|
82
|
-
"ConnectionStrings": {
|
|
83
|
-
"DefaultConnection": "Server=localhost;Database=MyApp;Trusted_Connection=true;TrustServerCertificate=true"
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
Créé automatiquement par `/gitflow:10-start`, ajouté à `.gitignore`.
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
## Prérequis
|
|
93
|
-
|
|
94
|
-
- .NET SDK installé
|
|
95
|
-
- EF Core Tools: `dotnet tool install --global dotnet-ef`
|
|
96
|
-
- SQL Server (ou provider configuré)
|