@atlashub/smartstack-cli 1.17.0 → 1.18.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/package.json +1 -1
- package/templates/agents/efcore/db-deploy.md +5 -0
- package/templates/agents/efcore/db-reset.md +5 -0
- package/templates/agents/efcore/db-seed.md +5 -0
- package/templates/agents/efcore/db-status.md +5 -0
- package/templates/agents/efcore/migration.md +8 -0
- package/templates/agents/efcore/rebase-snapshot.md +9 -0
- package/templates/agents/efcore/squash.md +50 -20
- package/templates/commands/efcore/squash.md +24 -12
- package/templates/skills/efcore/SKILL.md +162 -0
- package/templates/skills/efcore/steps/db/step-deploy.md +208 -0
- package/templates/skills/efcore/steps/db/step-reset.md +259 -0
- package/templates/skills/efcore/steps/db/step-seed.md +244 -0
- package/templates/skills/efcore/steps/db/step-status.md +198 -0
- package/templates/skills/efcore/steps/migration/step-00-init.md +102 -0
- package/templates/skills/efcore/steps/migration/step-01-check.md +138 -0
- package/templates/skills/efcore/steps/migration/step-02-create.md +144 -0
- package/templates/skills/efcore/steps/migration/step-03-validate.md +203 -0
- package/templates/skills/efcore/steps/rebase-snapshot/step-00-init.md +173 -0
- package/templates/skills/efcore/steps/rebase-snapshot/step-01-backup.md +100 -0
- package/templates/skills/efcore/steps/rebase-snapshot/step-02-fetch.md +115 -0
- package/templates/skills/efcore/steps/rebase-snapshot/step-03-create.md +108 -0
- package/templates/skills/efcore/steps/rebase-snapshot/step-04-validate.md +157 -0
- package/templates/skills/efcore/steps/shared/step-00-init.md +266 -0
- package/templates/skills/efcore/steps/squash/step-00-init.md +141 -0
- package/templates/skills/efcore/steps/squash/step-01-backup.md +120 -0
- package/templates/skills/efcore/steps/squash/step-02-fetch.md +168 -0
- package/templates/skills/efcore/steps/squash/step-03-create.md +178 -0
- package/templates/skills/efcore/steps/squash/step-04-validate.md +174 -0
package/package.json
CHANGED
|
@@ -4,12 +4,17 @@ description: EF Core database deploy - apply pending migrations
|
|
|
4
4
|
color: green
|
|
5
5
|
model: haiku
|
|
6
6
|
tools: Bash, Glob
|
|
7
|
+
steps:
|
|
8
|
+
- steps/shared/step-00-init.md
|
|
9
|
+
- steps/db/step-deploy.md
|
|
7
10
|
---
|
|
8
11
|
|
|
9
12
|
# EF Core Database Deploy Agent
|
|
10
13
|
|
|
11
14
|
Applies pending migrations to the local database.
|
|
12
15
|
|
|
16
|
+
**Progressive Steps:** Load `steps/db/step-deploy.md` for detailed instructions.
|
|
17
|
+
|
|
13
18
|
## Workflow
|
|
14
19
|
|
|
15
20
|
1. **Verify** appsettings.Local.json exists
|
|
@@ -4,12 +4,17 @@ description: EF Core database reset - drop and recreate (DESTRUCTIVE)
|
|
|
4
4
|
color: red
|
|
5
5
|
model: sonnet
|
|
6
6
|
tools: Bash, Glob, Read
|
|
7
|
+
steps:
|
|
8
|
+
- steps/shared/step-00-init.md
|
|
9
|
+
- steps/db/step-reset.md
|
|
7
10
|
---
|
|
8
11
|
|
|
9
12
|
# EF Core Database Reset Agent
|
|
10
13
|
|
|
11
14
|
**WARNING: Destructive operation - deletes all data!**
|
|
12
15
|
|
|
16
|
+
**Progressive Steps:** Load `steps/db/step-reset.md` for detailed instructions.
|
|
17
|
+
|
|
13
18
|
> **CLAUDE INSTRUCTION:** The `AskUserQuestion({...})` blocks are instructions to use the `AskUserQuestion` tool **interactively**. You MUST execute the tool with these parameters to get the user's response BEFORE continuing.
|
|
14
19
|
|
|
15
20
|
## Workflow
|
|
@@ -4,12 +4,17 @@ description: EF Core database seed - populate test data
|
|
|
4
4
|
color: yellow
|
|
5
5
|
model: haiku
|
|
6
6
|
tools: Bash, Glob, Read
|
|
7
|
+
steps:
|
|
8
|
+
- steps/shared/step-00-init.md
|
|
9
|
+
- steps/db/step-seed.md
|
|
7
10
|
---
|
|
8
11
|
|
|
9
12
|
# EF Core Database Seed Agent
|
|
10
13
|
|
|
11
14
|
Populates the database with test data.
|
|
12
15
|
|
|
16
|
+
**Progressive Steps:** Load `steps/db/step-seed.md` for detailed instructions.
|
|
17
|
+
|
|
13
18
|
## Workflow
|
|
14
19
|
|
|
15
20
|
1. **Detect** available seeding method:
|
|
@@ -5,12 +5,17 @@ color: blue
|
|
|
5
5
|
model: haiku
|
|
6
6
|
tools: Bash, Glob
|
|
7
7
|
mcp: mcp__smartstack__check_migrations
|
|
8
|
+
steps:
|
|
9
|
+
- steps/shared/step-00-init.md
|
|
10
|
+
- steps/db/step-status.md
|
|
8
11
|
---
|
|
9
12
|
|
|
10
13
|
# EF Core Database Status Agent
|
|
11
14
|
|
|
12
15
|
Fast check of EF Core migration state using **SmartStack MCP**.
|
|
13
16
|
|
|
17
|
+
**Progressive Steps:** Load `steps/db/step-status.md` for detailed instructions.
|
|
18
|
+
|
|
14
19
|
## Workflow
|
|
15
20
|
|
|
16
21
|
1. **Invoke MCP** for migration list and naming validation
|
|
@@ -4,12 +4,20 @@ description: EF Core migration manager - orchestrates MCP for naming (1 per feat
|
|
|
4
4
|
color: magenta
|
|
5
5
|
model: sonnet
|
|
6
6
|
tools: Bash, Glob, Read, Edit
|
|
7
|
+
steps:
|
|
8
|
+
- steps/shared/step-00-init.md
|
|
9
|
+
- steps/migration/step-00-init.md
|
|
10
|
+
- steps/migration/step-01-check.md
|
|
11
|
+
- steps/migration/step-02-create.md
|
|
12
|
+
- steps/migration/step-03-validate.md
|
|
7
13
|
---
|
|
8
14
|
|
|
9
15
|
# EF Core Migration Agent
|
|
10
16
|
|
|
11
17
|
Orchestrates migration creation with the "1 migration per feature" rule.
|
|
12
18
|
|
|
19
|
+
**Progressive Steps:** Load `steps/migration/` for detailed instructions.
|
|
20
|
+
|
|
13
21
|
> **IMPORTANT:** Cet agent **ORCHESTRE** uniquement. Le nommage est **DÉLÉGUÉ AU MCP**.
|
|
14
22
|
|
|
15
23
|
> **CLAUDE INSTRUCTION:** The `AskUserQuestion({...})` blocks are instructions to use the `AskUserQuestion` tool **interactively**. You MUST execute the tool with these parameters to get the user's response BEFORE continuing.
|
|
@@ -4,12 +4,21 @@ description: EF Core snapshot rebaser - resync ModelSnapshot with develop
|
|
|
4
4
|
color: yellow
|
|
5
5
|
model: sonnet
|
|
6
6
|
tools: Bash, Glob, Read, Edit
|
|
7
|
+
steps:
|
|
8
|
+
- steps/shared/step-00-init.md
|
|
9
|
+
- steps/rebase-snapshot/step-00-init.md
|
|
10
|
+
- steps/rebase-snapshot/step-01-backup.md
|
|
11
|
+
- steps/rebase-snapshot/step-02-fetch.md
|
|
12
|
+
- steps/rebase-snapshot/step-03-create.md
|
|
13
|
+
- steps/rebase-snapshot/step-04-validate.md
|
|
7
14
|
---
|
|
8
15
|
|
|
9
16
|
# EF Core Rebase-Snapshot Agent
|
|
10
17
|
|
|
11
18
|
Rebases ModelSnapshot on develop to resolve conflicts.
|
|
12
19
|
|
|
20
|
+
**Progressive Steps:** Load `steps/rebase-snapshot/` for detailed instructions.
|
|
21
|
+
|
|
13
22
|
## Workflow
|
|
14
23
|
|
|
15
24
|
1. **Backup** all migrations
|
|
@@ -4,22 +4,33 @@ description: EF Core migration squasher - combine multiple migrations into one
|
|
|
4
4
|
color: magenta
|
|
5
5
|
model: sonnet
|
|
6
6
|
tools: Bash, Glob, Read
|
|
7
|
+
steps:
|
|
8
|
+
- steps/shared/step-00-init.md
|
|
9
|
+
- steps/squash/step-00-init.md
|
|
10
|
+
- steps/squash/step-01-backup.md
|
|
11
|
+
- steps/squash/step-02-fetch.md
|
|
12
|
+
- steps/squash/step-03-create.md
|
|
13
|
+
- steps/squash/step-04-validate.md
|
|
7
14
|
---
|
|
8
15
|
|
|
9
16
|
# EF Core Squash Agent
|
|
10
17
|
|
|
11
|
-
Consolide plusieurs migrations en une seule, en récupérant le ModelSnapshot de la branche parente.
|
|
18
|
+
Consolide plusieurs migrations en une seule, en récupérant le ModelSnapshot **ET les migrations** de la branche parente.
|
|
19
|
+
|
|
20
|
+
**Progressive Steps:** Load `steps/squash/` for detailed instructions.
|
|
12
21
|
|
|
13
22
|
## Principe Fondamental
|
|
14
23
|
|
|
15
24
|
```
|
|
16
|
-
RÈGLE D'OR:
|
|
25
|
+
RÈGLE D'OR: Récupérer SNAPSHOT + MIGRATIONS de la branche PARENTE
|
|
17
26
|
|
|
18
|
-
feature/* → snapshot de develop
|
|
19
|
-
develop → snapshot de main
|
|
20
|
-
release/* → snapshot de main
|
|
21
|
-
hotfix/* → snapshot de main
|
|
27
|
+
feature/* → snapshot + migrations de develop
|
|
28
|
+
develop → snapshot + migrations de main
|
|
29
|
+
release/* → snapshot + migrations de main
|
|
30
|
+
hotfix/* → snapshot + migrations de main
|
|
22
31
|
main → BLOQUÉ (jamais squash)
|
|
32
|
+
|
|
33
|
+
⚠️ Ne JAMAIS récupérer uniquement le snapshot sans les migrations!
|
|
23
34
|
```
|
|
24
35
|
|
|
25
36
|
## Workflow
|
|
@@ -28,16 +39,17 @@ main → BLOQUÉ (jamais squash)
|
|
|
28
39
|
2. **List**: Migrations propres à cette branche (pas héritées)
|
|
29
40
|
3. **Confirm**: Demander validation utilisateur
|
|
30
41
|
4. **Backup**: Sauvegarder tous les fichiers
|
|
31
|
-
5. **Fetch**: Récupérer ModelSnapshot de branche parente
|
|
32
|
-
6. **Delete**: Supprimer migrations de la branche
|
|
33
|
-
7. **Create**: Créer migration consolidée
|
|
42
|
+
5. **Fetch**: Récupérer **ModelSnapshot ET migrations** de branche parente (CRUCIAL!)
|
|
43
|
+
6. **Delete**: Supprimer migrations de la branche UNIQUEMENT
|
|
44
|
+
7. **Create**: Créer migration consolidée (MCP obligatoire)
|
|
34
45
|
8. **Validate**: Build + script OK
|
|
35
46
|
|
|
36
47
|
## Commandes Clés
|
|
37
48
|
|
|
38
49
|
```bash
|
|
39
|
-
# Déterminer branche parente
|
|
40
|
-
determine_base_branch
|
|
50
|
+
# Déterminer branche parente et DbContext
|
|
51
|
+
determine_base_branch # → BASE_BRANCH, BRANCH_TYPE
|
|
52
|
+
detect_efcore_project # → $DBCONTEXT, $DBCONTEXT_TYPE, $SCHEMA
|
|
41
53
|
|
|
42
54
|
# Identifier migrations propres à la branche
|
|
43
55
|
BASE_MIGS=$(git ls-tree -r --name-only "origin/$BASE_BRANCH" -- Migrations/ | grep "\.cs$" | grep -v "Designer\|Snapshot")
|
|
@@ -47,16 +59,24 @@ LOCAL_MIGS=$(find Migrations -name "*.cs" | grep -v Designer | grep -v Snapshot)
|
|
|
47
59
|
BACKUP_DIR=".claude/gitflow/backup/migrations/squash_$(date +%Y%m%d_%H%M%S)"
|
|
48
60
|
mkdir -p "$BACKUP_DIR" && cp Migrations/*.cs "$BACKUP_DIR/"
|
|
49
61
|
|
|
50
|
-
#
|
|
62
|
+
# ═══════════════════════════════════════════════════════════════════════════
|
|
63
|
+
# CRUCIAL: Récupérer SNAPSHOT + MIGRATIONS de la branche parente
|
|
64
|
+
# ═══════════════════════════════════════════════════════════════════════════
|
|
51
65
|
git fetch origin "$BASE_BRANCH"
|
|
66
|
+
|
|
67
|
+
# 1. Récupérer le ModelSnapshot
|
|
52
68
|
git checkout "origin/$BASE_BRANCH" -- Migrations/*ModelSnapshot.cs
|
|
69
|
+
echo "✅ Snapshot récupéré de origin/$BASE_BRANCH"
|
|
53
70
|
|
|
54
|
-
# Récupérer les migrations de la branche parente
|
|
71
|
+
# 2. Récupérer TOUTES les migrations de la branche parente
|
|
72
|
+
# ⚠️ OBLIGATOIRE: Sans ça, les migrations de develop/main seront perdues!
|
|
55
73
|
for base_mig in $BASE_MIGS; do
|
|
56
74
|
base_name=$(basename "${base_mig%.cs}")
|
|
57
75
|
git checkout "origin/$BASE_BRANCH" -- "Migrations/${base_name}.cs" 2>/dev/null || true
|
|
58
76
|
git checkout "origin/$BASE_BRANCH" -- "Migrations/${base_name}.Designer.cs" 2>/dev/null || true
|
|
77
|
+
echo " ✅ $base_name récupéré"
|
|
59
78
|
done
|
|
79
|
+
echo "✅ $(echo "$BASE_MIGS" | wc -l) migrations récupérées de origin/$BASE_BRANCH"
|
|
60
80
|
|
|
61
81
|
# Supprimer migrations de la branche uniquement
|
|
62
82
|
for mig in $BRANCH_ONLY_MIGRATIONS; do
|
|
@@ -64,10 +84,11 @@ for mig in $BRANCH_ONLY_MIGRATIONS; do
|
|
|
64
84
|
done
|
|
65
85
|
|
|
66
86
|
# Créer migration consolidée - UTILISER MCP OBLIGATOIRE
|
|
67
|
-
|
|
68
|
-
|
|
87
|
+
# $DBCONTEXT_TYPE = "core" ou "extensions" (de detect_efcore_project)
|
|
88
|
+
mcp__smartstack__suggest_migration({ description: "...", context: DBCONTEXT_TYPE })
|
|
89
|
+
# Résultat: core_v1.9.0_001_Description
|
|
69
90
|
|
|
70
|
-
dotnet ef migrations add "$MIGRATION_NAME_FROM_MCP"
|
|
91
|
+
dotnet ef migrations add "$MIGRATION_NAME_FROM_MCP" --context "$DBCONTEXT"
|
|
71
92
|
|
|
72
93
|
# Valider
|
|
73
94
|
dotnet build && dotnet ef migrations script --idempotent > /dev/null
|
|
@@ -79,7 +100,9 @@ dotnet build && dotnet ef migrations script --idempotent > /dev/null
|
|
|
79
100
|
- [ ] main/master = BLOQUÉ
|
|
80
101
|
- [ ] User confirmation obtenue
|
|
81
102
|
- [ ] Backup créé
|
|
82
|
-
- [ ] Snapshot parent
|
|
103
|
+
- [ ] **Snapshot parent récupéré** (origin/$BASE_BRANCH)
|
|
104
|
+
- [ ] **Migrations parent récupérées** (fichiers .cs ET .Designer.cs)
|
|
105
|
+
- [ ] Migrations de la branche supprimées (pas celles héritées!)
|
|
83
106
|
- [ ] Build OK après squash
|
|
84
107
|
- [ ] Script générable
|
|
85
108
|
|
|
@@ -87,9 +110,16 @@ dotnet build && dotnet ef migrations script --idempotent > /dev/null
|
|
|
87
110
|
|
|
88
111
|
```
|
|
89
112
|
SQUASH - {current_branch}
|
|
90
|
-
Base: {BASE_BRANCH}
|
|
91
|
-
|
|
92
|
-
|
|
113
|
+
Base: origin/{BASE_BRANCH}
|
|
114
|
+
|
|
115
|
+
Récupéré de {BASE_BRANCH}:
|
|
116
|
+
✅ ModelSnapshot
|
|
117
|
+
✅ {N} migrations (fichiers .cs + .Designer.cs)
|
|
118
|
+
|
|
119
|
+
Consolidé:
|
|
120
|
+
Avant: {M} migrations (propres à cette branche)
|
|
121
|
+
Après: 1 migration ({MIGRATION_NAME} via MCP)
|
|
122
|
+
|
|
93
123
|
Backup: .claude/gitflow/backup/migrations/squash_{timestamp}/
|
|
94
124
|
|
|
95
125
|
Prochains: /efcore:db-reset, /efcore:db-deploy
|
|
@@ -48,7 +48,10 @@ determine_base_branch # Voir _shared.md
|
|
|
48
48
|
```bash
|
|
49
49
|
CURRENT_BRANCH=$(git branch --show-current)
|
|
50
50
|
[ -n "$(git status --porcelain)" ] && { echo "Working directory non propre"; exit 1; }
|
|
51
|
-
detect_efcore_project
|
|
51
|
+
detect_efcore_project # Appelle detect_dbcontext() → $DBCONTEXT, $DBCONTEXT_TYPE, $SCHEMA
|
|
52
|
+
|
|
53
|
+
echo "DbContext: $DBCONTEXT ($DBCONTEXT_TYPE)"
|
|
54
|
+
echo "Schema: $SCHEMA"
|
|
52
55
|
|
|
53
56
|
# Compter migrations LOCALES uniquement (pas celles héritées)
|
|
54
57
|
git fetch origin "$BASE_BRANCH" --quiet
|
|
@@ -139,14 +142,16 @@ echo " - $(echo "$BASE_MIGRATIONS" | wc -l) migrations"
|
|
|
139
142
|
|
|
140
143
|
**Résultat attendu:**
|
|
141
144
|
```
|
|
142
|
-
feature
|
|
143
|
-
├──
|
|
144
|
-
├──
|
|
145
|
-
├── core_v1.
|
|
146
|
-
├── core_v1.
|
|
147
|
-
└── CoreDbContextModelSnapshot.cs
|
|
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
|
|
148
151
|
```
|
|
149
152
|
|
|
153
|
+
⚠️ **ATTENTION:** Si le résultat ne montre pas les migrations de develop, le squash a échoué!
|
|
154
|
+
|
|
150
155
|
---
|
|
151
156
|
|
|
152
157
|
## STEP 5: Supprimer Migrations de la Branche (pas celles héritées)
|
|
@@ -194,20 +199,27 @@ esac
|
|
|
194
199
|
**Appel MCP OBLIGATOIRE:**
|
|
195
200
|
|
|
196
201
|
```javascript
|
|
197
|
-
//
|
|
202
|
+
// $DESCRIPTION = construit ci-dessus (ex: "multitenant Consolidated")
|
|
203
|
+
// $DBCONTEXT_TYPE = "core" ou "extensions" (de detect_dbcontext)
|
|
204
|
+
|
|
198
205
|
mcp__smartstack__suggest_migration({
|
|
199
|
-
description: DESCRIPTION,
|
|
200
|
-
context:
|
|
206
|
+
description: DESCRIPTION,
|
|
207
|
+
context: DBCONTEXT_TYPE // JAMAIS hardcodé!
|
|
201
208
|
})
|
|
202
209
|
|
|
203
|
-
// Résultat: core_v1.
|
|
210
|
+
// Résultat: core_v1.9.0_001_MultitenantConsolidated
|
|
204
211
|
```
|
|
205
212
|
|
|
213
|
+
> **INTERDIT :** Calculer le nom manuellement ou hardcoder le context.
|
|
214
|
+
|
|
206
215
|
**Puis créer la migration:**
|
|
207
216
|
|
|
208
217
|
```bash
|
|
209
|
-
# MIGRATION_NAME = résultat du MCP (ex: core_v1.
|
|
218
|
+
# MIGRATION_NAME = résultat du MCP (ex: core_v1.9.0_001_MultitenantConsolidated)
|
|
219
|
+
# DBCONTEXT = CoreDbContext ou ExtensionsDbContext (de detect_dbcontext)
|
|
220
|
+
|
|
210
221
|
dotnet ef migrations add "$MIGRATION_NAME" \
|
|
222
|
+
--context "$DBCONTEXT" \
|
|
211
223
|
--project "$INFRA_PROJECT" \
|
|
212
224
|
--startup-project "$STARTUP_PROJECT" \
|
|
213
225
|
-o Persistence/Migrations \
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: efcore
|
|
3
|
+
description: EF Core Commands - Migration and database management
|
|
4
|
+
argument-hint: "<command> [options]"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<objective>
|
|
8
|
+
Manage EF Core migrations and database operations with progressive step loading, MCP validation, and DbContext auto-detection.
|
|
9
|
+
</objective>
|
|
10
|
+
|
|
11
|
+
<quick_start>
|
|
12
|
+
**Database operations:**
|
|
13
|
+
```bash
|
|
14
|
+
/efcore db-status # Check migration status
|
|
15
|
+
/efcore db-deploy # Apply pending migrations
|
|
16
|
+
/efcore db-reset # Drop + recreate database
|
|
17
|
+
/efcore db-seed # Populate with test data
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**Migration operations:**
|
|
21
|
+
```bash
|
|
22
|
+
/efcore migration # Create migration for current branch
|
|
23
|
+
/efcore squash # Consolidate branch migrations
|
|
24
|
+
/efcore rebase-snapshot # Sync snapshot with parent branch
|
|
25
|
+
/efcore scan # Scan for cross-branch conflicts
|
|
26
|
+
/efcore conflicts # Analyze migration conflicts
|
|
27
|
+
```
|
|
28
|
+
</quick_start>
|
|
29
|
+
|
|
30
|
+
<parameters>
|
|
31
|
+
|
|
32
|
+
<subcommands>
|
|
33
|
+
| Command | Description | Steps |
|
|
34
|
+
|---------|-------------|-------|
|
|
35
|
+
| `db-status` | Display migrations and database status | steps/db/status/ |
|
|
36
|
+
| `db-deploy` | Apply pending migrations | steps/db/deploy/ |
|
|
37
|
+
| `db-reset` | Drop + recreate database | steps/db/reset/ |
|
|
38
|
+
| `db-seed` | Populate with test data | steps/db/seed/ |
|
|
39
|
+
| `migration` | Create/recreate migration | steps/migration/ |
|
|
40
|
+
| `squash` | Consolidate migrations | steps/squash/ |
|
|
41
|
+
| `rebase-snapshot` | Sync snapshot with parent | steps/rebase-snapshot/ |
|
|
42
|
+
| `scan` | Scan for conflicts | (MCP-centric) |
|
|
43
|
+
| `conflicts` | Analyze conflicts | (MCP-centric) |
|
|
44
|
+
</subcommands>
|
|
45
|
+
|
|
46
|
+
<flags>
|
|
47
|
+
| Flag | Description |
|
|
48
|
+
|------|-------------|
|
|
49
|
+
| `--context <name>` | Specify DbContext (CoreDbContext/ExtensionsDbContext) |
|
|
50
|
+
| `--env <name>` | Use appsettings.{name}.json |
|
|
51
|
+
| `--verbose` | Show detailed output |
|
|
52
|
+
| `--force` | Skip confirmations |
|
|
53
|
+
| `--dry-run` | Preview without executing |
|
|
54
|
+
</flags>
|
|
55
|
+
|
|
56
|
+
</parameters>
|
|
57
|
+
|
|
58
|
+
<state_variables>
|
|
59
|
+
**Shared state across all steps:**
|
|
60
|
+
|
|
61
|
+
| Variable | Type | Description |
|
|
62
|
+
|----------|------|-------------|
|
|
63
|
+
| `{command}` | string | Current subcommand |
|
|
64
|
+
| `{dbcontext}` | string | CoreDbContext or ExtensionsDbContext |
|
|
65
|
+
| `{dbcontext_type}` | string | "core" or "extensions" |
|
|
66
|
+
| `{schema}` | string | Database schema |
|
|
67
|
+
| `{infra_project}` | string | Path to Infrastructure project |
|
|
68
|
+
| `{startup_project}` | string | Path to API/Web project |
|
|
69
|
+
| `{migrations_dir}` | string | Path to Migrations folder |
|
|
70
|
+
| `{base_branch}` | string | Parent branch (develop/main) |
|
|
71
|
+
| `{branch_type}` | string | feature/release/hotfix |
|
|
72
|
+
| `{auto_mode}` | boolean | Skip confirmations |
|
|
73
|
+
</state_variables>
|
|
74
|
+
|
|
75
|
+
<entry_point>
|
|
76
|
+
|
|
77
|
+
**ROUTING LOGIC:**
|
|
78
|
+
|
|
79
|
+
1. Parse command and flags from input
|
|
80
|
+
2. Load shared init step: `steps/shared/step-00-init.md`
|
|
81
|
+
3. Route to command-specific steps:
|
|
82
|
+
|
|
83
|
+
| Command | Route To |
|
|
84
|
+
|---------|----------|
|
|
85
|
+
| `db-status` | `steps/db/step-status.md` |
|
|
86
|
+
| `db-deploy` | `steps/db/step-deploy.md` |
|
|
87
|
+
| `db-reset` | `steps/db/step-reset.md` |
|
|
88
|
+
| `db-seed` | `steps/db/step-seed.md` |
|
|
89
|
+
| `migration` | `steps/migration/step-00-init.md` |
|
|
90
|
+
| `squash` | `steps/squash/step-00-init.md` |
|
|
91
|
+
| `rebase-snapshot` | `steps/rebase-snapshot/step-00-init.md` |
|
|
92
|
+
| `scan` | Use `commands/efcore/scan.md` (MCP-centric, no steps) |
|
|
93
|
+
| `conflicts` | Use `commands/efcore/conflicts.md` (MCP-centric, no steps) |
|
|
94
|
+
|
|
95
|
+
</entry_point>
|
|
96
|
+
|
|
97
|
+
<shared_functions>
|
|
98
|
+
**Always load first:** `steps/shared/step-00-init.md`
|
|
99
|
+
|
|
100
|
+
This step provides:
|
|
101
|
+
- `detect_efcore_project()` - Find EF Core project files
|
|
102
|
+
- `detect_dbcontext()` - Auto-detect Core vs Extensions
|
|
103
|
+
- `detect_environment()` - Load connection string
|
|
104
|
+
- `determine_base_branch()` - Find parent branch
|
|
105
|
+
- `block_production()` - Safety check
|
|
106
|
+
|
|
107
|
+
**MCP Integration:**
|
|
108
|
+
- `mcp__smartstack__suggest_migration` - Generate compliant names
|
|
109
|
+
- `mcp__smartstack__check_migrations` - Analyze conflicts
|
|
110
|
+
- `mcp__smartstack__validate_conventions` - Validate structure
|
|
111
|
+
</shared_functions>
|
|
112
|
+
|
|
113
|
+
<dual_dbcontext>
|
|
114
|
+
SmartStack uses **two separate DbContexts**:
|
|
115
|
+
|
|
116
|
+
| Context | DbContext | Schema | History Table |
|
|
117
|
+
|---------|-----------|--------|---------------|
|
|
118
|
+
| `core` | `CoreDbContext` | `core` | `core.__EFMigrationsHistory` |
|
|
119
|
+
| `extensions` | `ExtensionsDbContext` | `extensions` | `extensions.__EFMigrationsHistory` |
|
|
120
|
+
|
|
121
|
+
**Auto-detection priority:**
|
|
122
|
+
1. SmartStack.Domain exists → CoreDbContext
|
|
123
|
+
2. Client with SmartStack NuGet → ExtensionsDbContext
|
|
124
|
+
3. Code scan for DbContext classes
|
|
125
|
+
4. Ask user if ambiguous
|
|
126
|
+
</dual_dbcontext>
|
|
127
|
+
|
|
128
|
+
<naming_convention>
|
|
129
|
+
**Migration naming (MCP MANDATORY):**
|
|
130
|
+
|
|
131
|
+
Pattern: `{context}_v{version}_{sequence}_{Description}`
|
|
132
|
+
|
|
133
|
+
Examples:
|
|
134
|
+
- `core_v1.9.0_001_AddUserRoles`
|
|
135
|
+
- `extensions_v1.2.0_001_AddCustomFields`
|
|
136
|
+
|
|
137
|
+
**FORBIDDEN:** Manual name calculation. Always use MCP.
|
|
138
|
+
</naming_convention>
|
|
139
|
+
|
|
140
|
+
<safety_rules>
|
|
141
|
+
1. **Backup MANDATORY** for destructive operations
|
|
142
|
+
2. **Production BLOCKED** - Never run on production
|
|
143
|
+
3. **1 migration per feature** - Recreate, don't accumulate
|
|
144
|
+
4. **Snapshot + Migrations** - Always recover BOTH from parent
|
|
145
|
+
5. **MCP for naming** - Never hardcode migration names
|
|
146
|
+
</safety_rules>
|
|
147
|
+
|
|
148
|
+
<execution_rules>
|
|
149
|
+
- **Load one step at a time** - Progressive loading
|
|
150
|
+
- **State persists** - Variables carry across steps
|
|
151
|
+
- **Follow next_step** - Each step defines next
|
|
152
|
+
- **MCP validation** - Use SmartStack tools
|
|
153
|
+
- **Safety > Correctness > Speed**
|
|
154
|
+
</execution_rules>
|
|
155
|
+
|
|
156
|
+
<success_criteria>
|
|
157
|
+
- DbContext correctly detected
|
|
158
|
+
- Migrations created with MCP naming
|
|
159
|
+
- Database operations succeed
|
|
160
|
+
- Parent migrations preserved (for squash/rebase)
|
|
161
|
+
- Build passes after changes
|
|
162
|
+
</success_criteria>
|