@atlashub/smartstack-cli 3.37.0 → 3.39.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.
Files changed (228) hide show
  1. package/dist/index.js +16 -24
  2. package/dist/index.js.map +1 -1
  3. package/dist/mcp-entry.mjs +235 -265
  4. package/dist/mcp-entry.mjs.map +1 -1
  5. package/package.json +1 -1
  6. package/scripts/extract-api-endpoints.ts +5 -5
  7. package/scripts/generate-doc-with-mock-ui.ts +10 -17
  8. package/templates/agents/ba-reader.md +9 -9
  9. package/templates/agents/ba-writer.md +12 -15
  10. package/templates/agents/code-reviewer.md +1 -1
  11. package/templates/agents/docs-context-reader.md +1 -1
  12. package/templates/agents/efcore/scan.md +3 -1
  13. package/templates/agents/gitflow/commit.md +74 -0
  14. package/templates/agents/gitflow/finish.md +5 -2
  15. package/templates/agents/gitflow/init-clone.md +3 -3
  16. package/templates/agents/gitflow/init-validate.md +3 -2
  17. package/templates/agents/gitflow/merge.md +5 -4
  18. package/templates/agents/gitflow/pr.md +5 -4
  19. package/templates/agents/gitflow/start.md +37 -5
  20. package/templates/hooks/hooks.json +11 -0
  21. package/templates/hooks/wsl-dotnet-cleanup.sh +24 -0
  22. package/templates/mcp-scaffolding/frontend/nav-routes.ts.hbs +20 -20
  23. package/templates/mcp-scaffolding/frontend/routes.tsx.hbs +16 -24
  24. package/templates/mcp-scaffolding/migrations/seed-roles.cs.hbs +2 -2
  25. package/templates/skills/_resources/mcp-validate-documentation-spec.md +3 -3
  26. package/templates/skills/_shared.md +15 -17
  27. package/templates/skills/ai-prompt/SKILL.md +1 -1
  28. package/templates/skills/ai-prompt/steps/step-00-init.md +47 -0
  29. package/templates/skills/apex/SKILL.md +3 -4
  30. package/templates/skills/apex/_shared.md +10 -20
  31. package/templates/skills/apex/references/analysis-methods.md +141 -0
  32. package/templates/skills/apex/references/challenge-questions.md +1 -21
  33. package/templates/skills/apex/references/core-seed-data.md +35 -58
  34. package/templates/skills/apex/references/examine-build-validation.md +82 -0
  35. package/templates/skills/apex/references/execution-frontend-gates.md +177 -0
  36. package/templates/skills/apex/references/execution-frontend-patterns.md +105 -0
  37. package/templates/skills/apex/references/execution-layer1-rules.md +96 -0
  38. package/templates/skills/apex/references/initialization-challenge-flow.md +110 -0
  39. package/templates/skills/apex/references/planning-layer-mapping.md +151 -0
  40. package/templates/skills/apex/references/post-checks.md +145 -40
  41. package/templates/skills/apex/references/smartstack-api.md +35 -51
  42. package/templates/skills/apex/references/smartstack-frontend.md +18 -18
  43. package/templates/skills/apex/references/smartstack-layers.md +38 -62
  44. package/templates/skills/apex/steps/step-00-init.md +14 -26
  45. package/templates/skills/apex/steps/step-01-analyze.md +10 -143
  46. package/templates/skills/apex/steps/step-02-plan.md +10 -92
  47. package/templates/skills/apex/steps/step-03-execute.md +45 -252
  48. package/templates/skills/apex/steps/step-04-examine.md +14 -78
  49. package/templates/skills/apex/steps/step-05-deep-review.md +2 -2
  50. package/templates/skills/apex/steps/step-08-run-tests.md +1 -0
  51. package/templates/skills/application/SKILL.md +241 -242
  52. package/templates/skills/application/references/backend-controller-hierarchy.md +16 -16
  53. package/templates/skills/application/references/backend-seeding-and-dto-output.md +83 -0
  54. package/templates/skills/application/references/backend-table-prefix-mapping.md +79 -0
  55. package/templates/skills/application/references/backend-verification.md +1 -1
  56. package/templates/skills/application/references/frontend-i18n-and-output.md +67 -0
  57. package/templates/skills/application/references/frontend-route-naming.md +117 -0
  58. package/templates/skills/application/references/frontend-route-wiring-app-tsx.md +107 -0
  59. package/templates/skills/application/references/frontend-verification.md +12 -12
  60. package/templates/skills/application/references/init-parameter-detection.md +121 -0
  61. package/templates/skills/application/references/migration-checklist-troubleshooting.md +100 -0
  62. package/templates/skills/application/references/nav-fallback-procedure.md +199 -200
  63. package/templates/skills/application/references/provider-template.md +2 -6
  64. package/templates/skills/application/references/roles-client-project-handling.md +55 -0
  65. package/templates/skills/application/references/roles-fallback-procedure.md +149 -0
  66. package/templates/skills/application/references/test-coverage-requirements.md +213 -0
  67. package/templates/skills/application/references/test-frontend.md +3 -3
  68. package/templates/skills/application/steps/step-00-init.md +130 -260
  69. package/templates/skills/application/steps/step-01-navigation.md +170 -170
  70. package/templates/skills/application/steps/step-02-permissions.md +196 -196
  71. package/templates/skills/application/steps/step-03-roles.md +182 -339
  72. package/templates/skills/application/steps/step-03b-provider.md +133 -134
  73. package/templates/skills/application/steps/step-04-backend.md +174 -265
  74. package/templates/skills/application/steps/step-05-frontend.md +18 -144
  75. package/templates/skills/application/steps/step-06-migration.md +12 -60
  76. package/templates/skills/application/steps/step-07-tests.md +9 -76
  77. package/templates/skills/application/templates-backend.md +29 -27
  78. package/templates/skills/application/templates-frontend.md +49 -49
  79. package/templates/skills/application/templates-seed.md +57 -131
  80. package/templates/skills/business-analyse/SKILL.md +27 -30
  81. package/templates/skills/business-analyse/_architecture.md +6 -6
  82. package/templates/skills/business-analyse/_shared.md +60 -88
  83. package/templates/skills/business-analyse/questionnaire/04-data.md +3 -3
  84. package/templates/skills/business-analyse/questionnaire/06-security.md +1 -1
  85. package/templates/skills/business-analyse/questionnaire/13-cross-module.md +1 -1
  86. package/templates/skills/business-analyse/react/application-viewer.md +12 -12
  87. package/templates/skills/business-analyse/react/components.md +8 -12
  88. package/templates/skills/business-analyse/react/schema.md +836 -836
  89. package/templates/skills/business-analyse/references/agent-module-prompt.md +2 -3
  90. package/templates/skills/business-analyse/references/analysis-semantic-checks.md +190 -0
  91. package/templates/skills/business-analyse/references/cache-warming-strategy.md +2 -2
  92. package/templates/skills/business-analyse/references/cadrage-challenge-patterns.md +41 -0
  93. package/templates/skills/business-analyse/references/cadrage-coverage-matrix.md +74 -0
  94. package/templates/skills/business-analyse/references/cadrage-shared-modules.md +69 -0
  95. package/templates/skills/business-analyse/references/cadrage-structure-cards.md +1 -1
  96. package/templates/skills/business-analyse/references/compilation-structure-cards.md +297 -0
  97. package/templates/skills/business-analyse/references/consolidation-structural-checks.md +2 -2
  98. package/templates/skills/business-analyse/references/deploy-modes.md +5 -5
  99. package/templates/skills/business-analyse/references/detection-strategies.md +7 -7
  100. package/templates/skills/business-analyse/references/handoff-file-templates.md +14 -22
  101. package/templates/skills/business-analyse/references/handoff-mappings.md +4 -4
  102. package/templates/skills/business-analyse/references/handoff-seeddata-generation.md +312 -0
  103. package/templates/skills/business-analyse/references/init-schema-deployment.md +3 -3
  104. package/templates/skills/business-analyse/references/naming-conventions.md +22 -24
  105. package/templates/skills/business-analyse/references/prd-generation.md +2 -2
  106. package/templates/skills/business-analyse/references/review-data-mapping.md +2 -2
  107. package/templates/skills/business-analyse/references/robustness-checks.md +1 -1
  108. package/templates/skills/business-analyse/references/spec-auto-inference.md +3 -3
  109. package/templates/skills/business-analyse/references/team-orchestration.md +49 -6
  110. package/templates/skills/business-analyse/references/ui-dashboard-spec.md +1 -1
  111. package/templates/skills/business-analyse/references/ui-resource-cards.md +18 -18
  112. package/templates/skills/business-analyse/references/validate-incremental-html.md +2 -2
  113. package/templates/skills/business-analyse/references/validation-checklist.md +2 -2
  114. package/templates/skills/business-analyse/schemas/application-schema.json +4 -5
  115. package/templates/skills/business-analyse/schemas/project-schema.json +1 -6
  116. package/templates/skills/business-analyse/schemas/sections/metadata-schema.json +2 -3
  117. package/templates/skills/business-analyse/schemas/sections/specification-schema.json +4 -4
  118. package/templates/skills/business-analyse/steps/step-00-init.md +8 -17
  119. package/templates/skills/business-analyse/steps/step-01-cadrage.md +35 -198
  120. package/templates/skills/business-analyse/steps/step-01b-applications.md +16 -20
  121. package/templates/skills/business-analyse/steps/step-02-decomposition.md +1 -1
  122. package/templates/skills/business-analyse/steps/step-03a1-setup.md +4 -4
  123. package/templates/skills/business-analyse/steps/step-03a2-analysis.md +1 -1
  124. package/templates/skills/business-analyse/steps/step-03b-ui.md +4 -4
  125. package/templates/skills/business-analyse/steps/step-03c-compile.md +66 -140
  126. package/templates/skills/business-analyse/steps/step-03d-validate.md +2 -2
  127. package/templates/skills/business-analyse/steps/step-04a-collect.md +2 -2
  128. package/templates/skills/business-analyse/steps/step-04b-analyze.md +42 -160
  129. package/templates/skills/business-analyse/steps/step-04c-decide.md +1 -1
  130. package/templates/skills/business-analyse/steps/step-05a-handoff.md +74 -104
  131. package/templates/skills/business-analyse/steps/step-05b-deploy.md +13 -11
  132. package/templates/skills/business-analyse/steps/step-06-review.md +3 -3
  133. package/templates/skills/business-analyse/templates/tpl-frd.md +13 -13
  134. package/templates/skills/business-analyse/templates/tpl-handoff.md +12 -12
  135. package/templates/skills/business-analyse/templates/tpl-progress.md +1 -1
  136. package/templates/skills/business-analyse/templates-frd.md +25 -25
  137. package/templates/skills/business-analyse/templates-react.md +15 -21
  138. package/templates/skills/controller/SKILL.md +1 -1
  139. package/templates/skills/controller/postman-templates.md +1 -1
  140. package/templates/skills/controller/references/controller-code-templates.md +2 -2
  141. package/templates/skills/controller/references/mcp-scaffold-workflow.md +209 -0
  142. package/templates/skills/controller/references/permission-sync-templates.md +13 -16
  143. package/templates/skills/controller/steps/step-00-init.md +11 -11
  144. package/templates/skills/controller/steps/step-03-generate.md +64 -103
  145. package/templates/skills/controller/templates.md +67 -71
  146. package/templates/skills/debug/SKILL.md +13 -218
  147. package/templates/skills/debug/steps/step-00-init.md +57 -0
  148. package/templates/skills/debug/steps/step-01-analyze.md +219 -0
  149. package/templates/skills/debug/steps/step-02-resolve.md +85 -0
  150. package/templates/skills/documentation/SKILL.md +49 -345
  151. package/templates/skills/documentation/data-schema.md +11 -8
  152. package/templates/skills/documentation/steps/step-00-init.md +70 -0
  153. package/templates/skills/documentation/steps/step-01-scan.md +113 -0
  154. package/templates/skills/documentation/steps/step-02-generate.md +231 -0
  155. package/templates/skills/documentation/steps/step-03-validate.md +238 -0
  156. package/templates/skills/documentation/templates.md +480 -322
  157. package/templates/skills/efcore/SKILL.md +1 -1
  158. package/templates/skills/efcore/references/both-contexts.md +32 -0
  159. package/templates/skills/efcore/references/database-operations.md +67 -0
  160. package/templates/skills/efcore/references/destructive-operations.md +38 -0
  161. package/templates/skills/efcore/references/reset-operations.md +81 -0
  162. package/templates/skills/efcore/references/seed-methods.md +86 -0
  163. package/templates/skills/efcore/references/shared-init-functions.md +250 -0
  164. package/templates/skills/efcore/references/sql-objects-injection.md +61 -0
  165. package/templates/skills/efcore/references/troubleshooting.md +81 -0
  166. package/templates/skills/efcore/steps/db/step-deploy.md +1 -32
  167. package/templates/skills/efcore/steps/db/step-reset.md +7 -103
  168. package/templates/skills/efcore/steps/db/step-seed.md +10 -132
  169. package/templates/skills/efcore/steps/db/step-status.md +5 -44
  170. package/templates/skills/efcore/steps/migration/step-02-create.md +1 -14
  171. package/templates/skills/efcore/steps/migration/step-03-validate.md +8 -62
  172. package/templates/skills/efcore/steps/rebase-snapshot/step-03-create.md +1 -57
  173. package/templates/skills/efcore/steps/shared/step-00-init.md +11 -254
  174. package/templates/skills/efcore/steps/squash/step-03-create.md +1 -58
  175. package/templates/skills/feature-full/SKILL.md +1 -1
  176. package/templates/skills/feature-full/steps/step-00-init.md +57 -0
  177. package/templates/skills/feature-full/steps/step-01-implementation.md +1 -1
  178. package/templates/skills/gitflow/SKILL.md +28 -5
  179. package/templates/skills/gitflow/_shared.md +109 -12
  180. package/templates/skills/gitflow/phases/abort.md +4 -0
  181. package/templates/skills/gitflow/phases/cleanup.md +4 -0
  182. package/templates/skills/gitflow/references/commit-message-generation.md +58 -0
  183. package/templates/skills/gitflow/references/commit-migration-validation.md +49 -0
  184. package/templates/skills/gitflow/references/finish-cleanup.md +55 -0
  185. package/templates/skills/gitflow/references/finish-version-bumping.md +45 -0
  186. package/templates/skills/gitflow/references/init-environment-detection.md +41 -0
  187. package/templates/skills/gitflow/references/init-questions.md +185 -0
  188. package/templates/skills/gitflow/references/init-structure-creation.md +75 -0
  189. package/templates/skills/gitflow/references/init-version-detection.md +21 -0
  190. package/templates/skills/gitflow/references/init-workspace-detection.md +43 -0
  191. package/templates/skills/gitflow/references/merge-ci-status.md +36 -0
  192. package/templates/skills/gitflow/references/merge-execution.md +62 -0
  193. package/templates/skills/gitflow/references/merge-pr-context.md +76 -0
  194. package/templates/skills/gitflow/references/pr-build-checks.md +60 -0
  195. package/templates/skills/gitflow/references/pr-generation.md +58 -0
  196. package/templates/skills/gitflow/references/start-branch-normalization.md +28 -0
  197. package/templates/skills/gitflow/references/start-worktree-creation.md +50 -0
  198. package/templates/skills/gitflow/references/sync-push-verify.md +44 -0
  199. package/templates/skills/gitflow/references/sync-rebase-conflicts.md +38 -0
  200. package/templates/skills/gitflow/steps/step-commit.md +12 -91
  201. package/templates/skills/gitflow/steps/step-finish.md +15 -159
  202. package/templates/skills/gitflow/steps/step-init.md +24 -326
  203. package/templates/skills/gitflow/steps/step-merge.md +17 -176
  204. package/templates/skills/gitflow/steps/step-pr.md +10 -116
  205. package/templates/skills/gitflow/steps/step-start.md +16 -109
  206. package/templates/skills/gitflow/steps/step-sync.md +6 -69
  207. package/templates/skills/ralph-loop/SKILL.md +6 -0
  208. package/templates/skills/ralph-loop/references/category-completeness.md +185 -0
  209. package/templates/skills/ralph-loop/references/compact-loop.md +1 -1
  210. package/templates/skills/ralph-loop/references/init-resume-recovery.md +127 -0
  211. package/templates/skills/ralph-loop/references/module-transition.md +151 -0
  212. package/templates/skills/ralph-loop/references/multi-module-queue.md +171 -0
  213. package/templates/skills/ralph-loop/references/parallel-execution.md +246 -0
  214. package/templates/skills/ralph-loop/references/task-transform-legacy.md +6 -9
  215. package/templates/skills/ralph-loop/references/team-orchestration.md +45 -3
  216. package/templates/skills/ralph-loop/steps/step-00-init.md +36 -109
  217. package/templates/skills/ralph-loop/steps/step-01-task.md +15 -163
  218. package/templates/skills/ralph-loop/steps/step-02-execute.md +8 -154
  219. package/templates/skills/ralph-loop/steps/step-04-check.md +20 -73
  220. package/templates/skills/review-code/references/owasp-api-top10.md +5 -5
  221. package/templates/skills/review-code/references/smartstack-conventions.md +568 -568
  222. package/templates/skills/validate-feature/references/api-smoke-tests.md +140 -0
  223. package/templates/skills/validate-feature/references/db-validation-checks.md +180 -0
  224. package/templates/skills/validate-feature/steps/step-01-compile.md +1 -3
  225. package/templates/skills/validate-feature/steps/step-04-api-smoke.md +34 -145
  226. package/templates/skills/validate-feature/steps/step-05-db-validation.md +74 -260
  227. package/templates/skills/workflow/SKILL.md +1 -1
  228. package/templates/skills/workflow/steps/step-00-init.md +57 -0
@@ -0,0 +1,81 @@
1
+ # EF Core Troubleshooting
2
+
3
+ ## Database Status
4
+
5
+ ### Troubleshooting (if connection fails)
6
+
7
+ ```
8
+ TROUBLESHOOTING
9
+ ├── SQL Server running?
10
+ ├── appsettings.Local.json configured?
11
+ ├── Database exists?
12
+ └── Commands: /efcore db-reset, /efcore db-deploy
13
+ ```
14
+
15
+ ## Deploy Errors
16
+
17
+ | Error | Resolution |
18
+ |-------|------------|
19
+ | Connection failed | Check SQL Server, credentials |
20
+ | Migration error | Review migration, consider reset |
21
+ | Constraint violation | Check data, may need seed |
22
+
23
+ ## Reset Protections
24
+
25
+ | Protection | Description |
26
+ |------------|-------------|
27
+ | Env Display | Shows database BEFORE confirmation |
28
+ | Confirmation | Explicit request with database NAME |
29
+ | Production Block | Blocks if Production detected |
30
+ | EF Core Only | No raw SQL |
31
+
32
+ ## Seed Setup Guide
33
+
34
+ If no seed methods detected, display guide:
35
+
36
+ ```
37
+ SEED SETUP GUIDE
38
+ ================
39
+
40
+ Option 1: HasData() in Configuration (RECOMMENDED)
41
+ --------------------------------------------------
42
+ // In UserConfiguration.cs
43
+ builder.HasData(new User {
44
+ Id = Guid.Parse("7f3c9a2e-8d1b-4e5f-a6c8-9b4d2f7e1a3c"),
45
+ Name = "Admin",
46
+ Email = "admin@example.com"
47
+ });
48
+
49
+ // Then run:
50
+ dotnet ef migrations add SeedData
51
+
52
+ Option 2: IDataSeeder Class
53
+ ---------------------------
54
+ public class UserSeeder : IDataSeeder
55
+ {
56
+ public async Task SeedAsync(DbContext context)
57
+ {
58
+ if (!await context.Users.AnyAsync())
59
+ {
60
+ context.Users.Add(new User { ... });
61
+ await context.SaveChangesAsync();
62
+ }
63
+ }
64
+ }
65
+
66
+ // Register in Program.cs and call via --seed argument
67
+ ```
68
+
69
+ ## Migration from SQL
70
+
71
+ ```csharp
72
+ // BEFORE (FORBIDDEN): scripts/seed.sql
73
+ INSERT INTO Users (Id, Name) VALUES (1, 'Admin');
74
+
75
+ // AFTER (CORRECT): UserConfiguration.cs
76
+ builder.HasData(new User {
77
+ Id = Guid.Parse("7f3c9a2e-8d1b-4e5f-a6c8-9b4d2f7e1a3c"),
78
+ Name = "Admin"
79
+ });
80
+ // Then: dotnet ef migrations add SeedData
81
+ ```
@@ -208,38 +208,7 @@ Next: /efcore db-status, /efcore db-seed
208
208
 
209
209
  ## BOTH CONTEXTS:
210
210
 
211
- **If `RUN_BOTH=true` (auto-detected for client projects with SmartStack NuGet):**
212
-
213
- Run the full deploy sequence (steps 2-6) TWICE, in order:
214
-
215
- ```bash
216
- # 1. Deploy CoreDbContext first (system tables: Users, Roles, Tenants...)
217
- echo "=== Deploying CoreDbContext (core schema) ==="
218
- DBCONTEXT="CoreDbContext"
219
- SCHEMA="core"
220
- # Run steps 2-6 with CoreDbContext...
221
-
222
- dotnet ef database update \
223
- --context "CoreDbContext" \
224
- --project "$INFRA_PROJECT" \
225
- --startup-project "$STARTUP_PROJECT" \
226
- --verbose
227
-
228
- # 2. Then ExtensionsDbContext (client tables)
229
- echo ""
230
- echo "=== Deploying ExtensionsDbContext (extensions schema) ==="
231
- DBCONTEXT="ExtensionsDbContext"
232
- SCHEMA="extensions"
233
- # Run steps 2-6 with ExtensionsDbContext...
234
-
235
- dotnet ef database update \
236
- --context "ExtensionsDbContext" \
237
- --project "$INFRA_PROJECT" \
238
- --startup-project "$STARTUP_PROJECT" \
239
- --verbose
240
- ```
241
-
242
- **Order matters:** Core MUST be deployed first (Extensions may have foreign keys to Core tables).
211
+ Load: `references/both-contexts.md`
243
212
 
244
213
  ---
245
214
 
@@ -32,17 +32,9 @@ Completely reset the database: drop, recreate, and apply all migrations.
32
32
 
33
33
  ### 1. Environment Check
34
34
 
35
- ```bash
36
- # Validate required variables from step-00-init
37
- for VAR_NAME in DBCONTEXT DBCONTEXT_TYPE INFRA_PROJECT STARTUP_PROJECT SELECTED_ENV; do
38
- eval VAR_VALUE=\$$VAR_NAME
39
- if [ -z "$VAR_VALUE" ]; then
40
- echo "ERROR: Required variable $VAR_NAME is not set"
41
- echo "Run step-00-init first"
42
- exit 1
43
- fi
44
- done
35
+ Load validation: `references/database-operations.md#check-required-variables`
45
36
 
37
+ ```bash
46
38
  echo "Reset Configuration"
47
39
  echo "==================="
48
40
  echo ""
@@ -93,66 +85,15 @@ AskUserQuestion:
93
85
 
94
86
  **If backup requested:**
95
87
 
96
- ```bash
97
- BACKUP_DIR=".claude/gitflow/backup/database"
98
- mkdir -p "$BACKUP_DIR"
99
-
100
- BACKUP_FILE="$BACKUP_DIR/${DATABASE_NAME}_$(date +%Y%m%d_%H%M%S).bak"
101
-
102
- echo "Creating backup: $BACKUP_FILE"
103
-
104
- sqlcmd -S "$SERVER_NAME" -E -Q "BACKUP DATABASE [$DATABASE_NAME] TO DISK='$BACKUP_FILE'"
105
-
106
- if [ $? -eq 0 ]; then
107
- echo "Backup created: $BACKUP_FILE"
108
- else
109
- echo "WARNING: Backup failed. Continue anyway?"
110
- fi
111
- ```
88
+ Load: `references/database-operations.md#backup-command`
112
89
 
113
90
  ### 4. Drop Database
114
91
 
115
- ```bash
116
- echo ""
117
- echo "Dropping database..."
118
-
119
- dotnet ef database drop \
120
- --context "$DBCONTEXT" \
121
- --project "$INFRA_PROJECT" \
122
- --startup-project "$STARTUP_PROJECT" \
123
- --force
124
- EXIT_CODE=$?
125
-
126
- if [ $EXIT_CODE -ne 0 ]; then
127
- echo "ERROR: Drop failed (exit code: $EXIT_CODE)"
128
- echo "Database may be in use. Close connections and retry."
129
- exit 1
130
- fi
131
-
132
- echo "Database dropped."
133
- ```
92
+ Load: `references/reset-operations.md#drop-database`
134
93
 
135
94
  ### 5. Recreate + Apply Migrations
136
95
 
137
- ```bash
138
- echo ""
139
- echo "Recreating database with migrations..."
140
-
141
- dotnet ef database update \
142
- --context "$DBCONTEXT" \
143
- --project "$INFRA_PROJECT" \
144
- --startup-project "$STARTUP_PROJECT" \
145
- --verbose
146
- EXIT_CODE=$?
147
-
148
- if [ $EXIT_CODE -ne 0 ]; then
149
- echo ""
150
- echo "ERROR: Recreation failed (exit code: $EXIT_CODE)"
151
- exit 1
152
- fi
153
-
154
- echo "Database recreated."
155
- ```
96
+ Load: `references/reset-operations.md#recreate--apply-migrations`
156
97
 
157
98
  ### 6. Optional Seed
158
99
 
@@ -181,39 +122,7 @@ dotnet run --project "$STARTUP_PROJECT" -- --seed 2>/dev/null || echo "No --seed
181
122
 
182
123
  ### 7. Summary
183
124
 
184
- ```bash
185
- MIGRATION_COUNT=$(dotnet ef migrations list \
186
- --context "$DBCONTEXT" \
187
- --project "$INFRA_PROJECT" \
188
- --startup-project "$STARTUP_PROJECT" 2>/dev/null | \
189
- grep -c "^[0-9]" || echo "0")
190
-
191
- echo ""
192
- echo "==========================================="
193
- echo "RESET COMPLETE"
194
- echo "==========================================="
195
- echo ""
196
- echo "Database: $DATABASE_NAME"
197
- echo "Environment: $SELECTED_ENV"
198
- echo "DbContext: $DBCONTEXT"
199
- echo ""
200
- echo "Operations:"
201
- echo " - Drop: OK"
202
- echo " - Create: OK"
203
- echo " - Migrations: $MIGRATION_COUNT applied"
204
- if [ -n "$BACKUP_FILE" ]; then
205
- echo " - Backup: $BACKUP_FILE"
206
- fi
207
- echo ""
208
- echo "Compliance: EF Core CLI only"
209
- echo ""
210
- echo "==========================================="
211
- echo ""
212
- echo "Next steps:"
213
- echo " /efcore db-status # Verify status"
214
- echo " /efcore db-seed # Add test data"
215
- echo ""
216
- ```
125
+ Load: `references/reset-operations.md#summary-after-reset`
217
126
 
218
127
  ---
219
128
 
@@ -241,12 +150,7 @@ Next: /efcore db-status, /efcore db-seed
241
150
 
242
151
  ## PROTECTIONS:
243
152
 
244
- | Protection | Description |
245
- |------------|-------------|
246
- | Env Display | Shows database BEFORE confirmation |
247
- | Confirmation | Explicit request with database NAME |
248
- | Production Block | Blocks if Production detected |
249
- | EF Core Only | No raw SQL |
153
+ Load: `references/troubleshooting.md#reset-protections`
250
154
 
251
155
  ---
252
156
 
@@ -28,17 +28,9 @@ Populate the database with test or initial data using EF Core conventions.
28
28
 
29
29
  ### 1. Environment Check
30
30
 
31
- ```bash
32
- # Validate required variables from step-00-init
33
- for VAR_NAME in DBCONTEXT DBCONTEXT_TYPE INFRA_PROJECT STARTUP_PROJECT SELECTED_ENV; do
34
- eval VAR_VALUE=\$$VAR_NAME
35
- if [ -z "$VAR_VALUE" ]; then
36
- echo "ERROR: Required variable $VAR_NAME is not set"
37
- echo "Run step-00-init first"
38
- exit 1
39
- fi
40
- done
31
+ Load validation: `references/database-operations.md#check-required-variables`
41
32
 
33
+ ```bash
42
34
  echo "Seed Configuration"
43
35
  echo "=================="
44
36
  echo ""
@@ -52,41 +44,7 @@ block_production
52
44
 
53
45
  ### 2. Detect Available Seed Methods
54
46
 
55
- ```bash
56
- echo ""
57
- echo "Detecting seed methods..."
58
-
59
- SEED_METHODS=""
60
-
61
- # HasData() in configurations (RECOMMENDED)
62
- if grep -rq "\.HasData(" . --include="*.cs" 2>/dev/null; then
63
- SEED_METHODS+=" hasdata"
64
- echo " - HasData(): Found"
65
- fi
66
-
67
- # IDataSeeder classes
68
- if grep -rq "IDataSeeder\|class.*Seeder" . --include="*.cs" 2>/dev/null; then
69
- SEED_METHODS+=" seeder-class"
70
- echo " - Seeder classes: Found"
71
- fi
72
-
73
- # --seed CLI argument
74
- if grep -q "\-\-seed" ./src/*/Program.cs 2>/dev/null; then
75
- SEED_METHODS+=" cli-argument"
76
- echo " - CLI --seed: Found"
77
- fi
78
-
79
- # WARNING: SQL scripts detected
80
- if [ -f "./scripts/seed.sql" ] || find . -name "seed*.sql" 2>/dev/null | grep -q .; then
81
- echo ""
82
- echo "WARNING: SQL seed scripts detected - FORBIDDEN by conventions"
83
- echo "Migrate to HasData() or IDataSeeder"
84
- fi
85
-
86
- if [ -z "$SEED_METHODS" ]; then
87
- echo " No seed methods found"
88
- fi
89
- ```
47
+ Load: `references/seed-methods.md#detect-available-seed-methods`
90
48
 
91
49
  ### 3. Select Method
92
50
 
@@ -108,52 +66,15 @@ AskUserQuestion:
108
66
 
109
67
  ### 4. Execute Seed
110
68
 
111
- **HasData method:**
112
-
113
- ```bash
114
- echo ""
115
- echo "HasData is applied via migrations."
116
- echo "Running database update to ensure all HasData is applied..."
117
-
118
- dotnet ef database update \
119
- --context "$DBCONTEXT" \
120
- --project "$INFRA_PROJECT" \
121
- --startup-project "$STARTUP_PROJECT"
122
- ```
123
-
124
- **Seeder Class method:**
125
-
126
- ```bash
127
- echo ""
128
- echo "Running seeder class..."
69
+ Load execution methods from: `references/seed-methods.md#execute-seed-*`
129
70
 
130
- dotnet run --project "$STARTUP_PROJECT" -- --seed
131
- EXIT_CODE=$?
132
-
133
- if [ $EXIT_CODE -ne 0 ]; then
134
- echo "Seed command failed or not supported (exit code: $EXIT_CODE)"
135
- echo "Check if --seed argument is implemented in Program.cs"
136
- fi
137
- ```
138
-
139
- **CLI argument method:**
140
-
141
- ```bash
142
- echo ""
143
- echo "Running application with --seed..."
144
-
145
- dotnet run --project "$STARTUP_PROJECT" -- --seed
146
- ```
71
+ - HasData: `references/seed-methods.md#execute-seed---hasdata`
72
+ - Seeder Class: `references/seed-methods.md#execute-seed---seeder-class`
73
+ - CLI Argument: `references/seed-methods.md#execute-seed---cli-argument`
147
74
 
148
75
  ### 5. Verify (Optional)
149
76
 
150
- ```bash
151
- echo ""
152
- echo "Verifying seed data..."
153
-
154
- # Quick check - count records in key tables
155
- # This is application-specific
156
- ```
77
+ Load: `references/seed-methods.md#verify-seed-data`
157
78
 
158
79
  ### 6. Summary
159
80
 
@@ -197,56 +118,13 @@ Next: /efcore db-status, dotnet run
197
118
 
198
119
  ## NO SEED METHODS FOUND:
199
120
 
200
- If no seed methods detected, display guide:
201
-
202
- ```
203
- SEED SETUP GUIDE
204
- ================
205
-
206
- Option 1: HasData() in Configuration (RECOMMENDED)
207
- --------------------------------------------------
208
- // In UserConfiguration.cs
209
- builder.HasData(new User {
210
- Id = Guid.Parse("7f3c9a2e-8d1b-4e5f-a6c8-9b4d2f7e1a3c"),
211
- Name = "Admin",
212
- Email = "admin@example.com"
213
- });
214
-
215
- // Then run:
216
- dotnet ef migrations add SeedData
217
-
218
- Option 2: IDataSeeder Class
219
- ---------------------------
220
- public class UserSeeder : IDataSeeder
221
- {
222
- public async Task SeedAsync(DbContext context)
223
- {
224
- if (!await context.Users.AnyAsync())
225
- {
226
- context.Users.Add(new User { ... });
227
- await context.SaveChangesAsync();
228
- }
229
- }
230
- }
231
-
232
- // Register in Program.cs and call via --seed argument
233
- ```
121
+ Load: `references/troubleshooting.md#seed-setup-guide`
234
122
 
235
123
  ---
236
124
 
237
125
  ## MIGRATION FROM SQL:
238
126
 
239
- ```csharp
240
- // BEFORE (FORBIDDEN): scripts/seed.sql
241
- INSERT INTO Users (Id, Name) VALUES (1, 'Admin');
242
-
243
- // AFTER (CORRECT): UserConfiguration.cs
244
- builder.HasData(new User {
245
- Id = Guid.Parse("7f3c9a2e-8d1b-4e5f-a6c8-9b4d2f7e1a3c"),
246
- Name = "Admin"
247
- });
248
- // Then: dotnet ef migrations add SeedData
249
- ```
127
+ Load: `references/troubleshooting.md#migration-from-sql`
250
128
 
251
129
  ---
252
130
 
@@ -20,17 +20,7 @@ Display comprehensive status of EF Core migrations and database connection.
20
20
 
21
21
  ### 0. Validate Required Variables
22
22
 
23
- ```bash
24
- # Validate required variables from step-00-init
25
- for VAR_NAME in DBCONTEXT DBCONTEXT_TYPE INFRA_PROJECT STARTUP_PROJECT SELECTED_ENV; do
26
- eval VAR_VALUE=\$$VAR_NAME
27
- if [ -z "$VAR_VALUE" ]; then
28
- echo "ERROR: Required variable $VAR_NAME is not set"
29
- echo "Run step-00-init first"
30
- exit 1
31
- fi
32
- done
33
- ```
23
+ Load: `references/database-operations.md#check-required-variables`
34
24
 
35
25
  ### 1. Display Configuration
36
26
 
@@ -48,23 +38,7 @@ echo "Config: $CONFIG_FILE"
48
38
 
49
39
  ### 2. Test Database Connection
50
40
 
51
- ```bash
52
- echo ""
53
- echo "Testing connection..."
54
-
55
- CONNECTION_TEST=$(dotnet ef database list \
56
- --context "$DBCONTEXT" \
57
- --project "$INFRA_PROJECT" \
58
- --startup-project "$STARTUP_PROJECT" 2>&1)
59
-
60
- if [ $? -eq 0 ]; then
61
- echo "Connection: OK"
62
- else
63
- echo "Connection: FAILED"
64
- echo ""
65
- echo "$CONNECTION_TEST"
66
- fi
67
- ```
41
+ Load: `references/database-operations.md#connection-test`
68
42
 
69
43
  ### 3. List Migrations
70
44
 
@@ -80,16 +54,9 @@ dotnet ef migrations list \
80
54
 
81
55
  ### 4. Count Applied vs Pending
82
56
 
83
- ```bash
84
- MIGRATION_OUTPUT=$(dotnet ef migrations list \
85
- --context "$DBCONTEXT" \
86
- --project "$INFRA_PROJECT" \
87
- --startup-project "$STARTUP_PROJECT" 2>/dev/null)
88
-
89
- APPLIED=$(echo "$MIGRATION_OUTPUT" | grep -v "(Pending)" | grep -c "^[0-9]" || echo "0")
90
- PENDING=$(echo "$MIGRATION_OUTPUT" | grep -c "(Pending)" || echo "0")
91
- TOTAL=$((APPLIED + PENDING))
57
+ Load: `references/database-operations.md#migration-count-utilities`
92
58
 
59
+ ```bash
93
60
  echo ""
94
61
  echo "Summary:"
95
62
  echo " Total: $TOTAL migrations"
@@ -187,13 +154,7 @@ Next: /efcore db-deploy
187
154
 
188
155
  ## TROUBLESHOOTING (if connection fails):
189
156
 
190
- ```
191
- TROUBLESHOOTING
192
- ├── SQL Server running?
193
- ├── appsettings.Local.json configured?
194
- ├── Database exists?
195
- └── Commands: /efcore db-reset, /efcore db-deploy
196
- ```
157
+ Load: `references/troubleshooting.md#database-status`
197
158
 
198
159
  ---
199
160
 
@@ -107,20 +107,7 @@ dotnet ef migrations add "$MIGRATION_NAME" \
107
107
  --verbose
108
108
  ```
109
109
 
110
- ### 6. Cleanup EF Core Design-Time Artifacts
111
-
112
- ```bash
113
- # EF Core's Roslyn BuildHost creates corrupted bin folders on Windows (U+F05C instead of backslash)
114
- # Clean up any bin*Debug folders that are NOT the normal bin/Debug path
115
- for d in src/*/bin?Debug; do
116
- if [ -d "$d" ]; then
117
- echo "Removing corrupted EF Core artifact: $d"
118
- rm -rf "$d"
119
- fi
120
- done
121
- ```
122
-
123
- ### 7. Verify Creation
110
+ ### 6. Verify Creation
124
111
 
125
112
  ```bash
126
113
  # Check files were created
@@ -90,6 +90,8 @@ AskUserQuestion:
90
90
  multiSelect: false
91
91
  ```
92
92
 
93
+ See: `references/destructive-operations.md` for zero-downtime patterns.
94
+
93
95
  ### 4. Handle Response
94
96
 
95
97
  ```javascript
@@ -146,68 +148,12 @@ exit 0
146
148
 
147
149
  ### 6. Final Summary
148
150
 
149
- ```bash
150
- echo ""
151
- echo "==========================================="
152
- echo "MIGRATION COMPLETE"
153
- echo "==========================================="
154
- echo ""
155
- echo "Branch: $CURRENT_BRANCH"
156
- echo "DbContext: $DBCONTEXT ($DBCONTEXT_TYPE)"
157
- echo ""
158
- echo "Migration: $MIGRATION_NAME"
159
- echo "Files:"
160
- echo " - ${MIGRATION_NAME}.cs"
161
- echo " - ${MIGRATION_NAME}.Designer.cs"
162
- echo " - ${DBCONTEXT}ModelSnapshot.cs (updated)"
163
- echo ""
164
- echo "Content:"
165
- echo " Tables: $UP_TABLES"
166
- echo " Columns: $UP_COLUMNS"
167
- echo " Indexes: $UP_INDEXES"
168
- echo " Foreign Keys:$UP_FOREIGN"
169
- echo ""
170
- if [ "$ACTION" = "deploy" ]; then
171
- echo "Status: Applied to local database"
172
- else
173
- echo "Status: Created (not applied)"
174
- echo " Run /efcore db-deploy to apply"
175
- fi
176
- echo ""
177
- echo "==========================================="
178
- echo ""
179
- echo "Next steps:"
180
- echo " /gitflow commit # Commit changes"
181
- echo " /efcore db-status # Check database status"
182
- echo ""
183
- ```
184
-
185
- ---
186
-
187
- ## OUTPUT FORMAT:
188
-
189
- ```
190
- MIGRATION COMPLETE
191
- ==================
192
- Branch: {current_branch}
193
- DbContext: {dbcontext} ({dbcontext_type})
194
-
195
- Migration: {migration_name}
196
- Files:
197
- - {migration_name}.cs
198
- - {migration_name}.Designer.cs
199
- - {dbcontext}ModelSnapshot.cs (updated)
200
-
201
- Content:
202
- Tables: {count}
203
- Columns: {count}
204
- Indexes: {count}
205
- Foreign Keys:{count}
206
-
207
- Status: {Applied | Created (not applied)}
208
-
209
- Next: /gitflow commit, /efcore db-status
210
- ```
151
+ Create summary output showing:
152
+ - Branch, DbContext, DbContext Type
153
+ - Migration name and files
154
+ - Content statistics (tables, columns, indexes, foreign keys)
155
+ - Status (Applied or Created)
156
+ - Next steps
211
157
 
212
158
  ---
213
159
 
@@ -89,63 +89,7 @@ echo " $DESIGNER_FILE"
89
89
 
90
90
  ### 5. Inject SQL Objects (Functions, Views, SP)
91
91
 
92
- EF Core does NOT generate DDL for TVF, views, and stored procedures.
93
- SQL source scripts are in `Persistence/SqlObjects/` (Embedded Resources).
94
- After a rebase-snapshot, they must be re-injected into the consolidated migration.
95
-
96
- ```bash
97
- # Check if SqlObjects folder exists with .sql files
98
- SQL_OBJECTS_DIR="$INFRA_PROJECT_DIR/Persistence/SqlObjects"
99
- SQL_FILES=$(find "$SQL_OBJECTS_DIR" -name "*.sql" 2>/dev/null | wc -l)
100
-
101
- if [ "$SQL_FILES" -gt 0 ]; then
102
- echo ""
103
- echo "Found $SQL_FILES SQL object(s) in SqlObjects/"
104
- echo "Injecting SqlObjectHelper.ApplyAll(migrationBuilder) into migration..."
105
-
106
- # Validate migration file path before sed operations
107
- if [ ! -f "$MIGRATION_FILE" ]; then
108
- echo "ERROR: Migration file not found: $MIGRATION_FILE"
109
- exit 1
110
- fi
111
- if ! echo "$MIGRATION_FILE" | grep -qE '\.cs$'; then
112
- echo "ERROR: Invalid migration file path (not .cs): $MIGRATION_FILE"
113
- exit 1
114
- fi
115
-
116
- # Add using directive if not present
117
- if ! grep -q "using SmartStack.Infrastructure.Persistence.SqlObjects;" "$MIGRATION_FILE"; then
118
- sed -i '1s/^/using SmartStack.Infrastructure.Persistence.SqlObjects;\n/' "$MIGRATION_FILE"
119
- fi
120
-
121
- # Add SqlObjectHelper.ApplyAll at the end of Up() method
122
- sed -i '/protected override void Up/,/^ }/ {
123
- /^ }/ i\
124
- \ // Apply SQL objects (TVF, Views, SP) from embedded resources\
125
- \ SqlObjectHelper.ApplyAll(migrationBuilder);
126
- }' "$MIGRATION_FILE"
127
-
128
- # Verify injection succeeded (fallback to manual step if sed pattern didn't match)
129
- if ! grep -q "SqlObjectHelper.ApplyAll" "$MIGRATION_FILE"; then
130
- echo "WARNING: Automatic injection failed (indentation pattern may differ)"
131
- echo ""
132
- echo "MANUAL STEP REQUIRED: Add these lines inside the Up() method before the closing brace:"
133
- echo ' using SmartStack.Infrastructure.Persistence.SqlObjects;'
134
- echo ' ...'
135
- echo ' SqlObjectHelper.ApplyAll(migrationBuilder);'
136
- echo ""
137
- echo "File: $MIGRATION_FILE"
138
- else
139
- echo " SqlObjectHelper.ApplyAll(migrationBuilder) injected"
140
- fi
141
- find "$SQL_OBJECTS_DIR" -name "*.sql" -exec basename {} \; | while read f; do
142
- echo " - $f"
143
- done
144
- else
145
- echo ""
146
- echo "No SQL objects found in SqlObjects/ - skipping injection"
147
- fi
148
- ```
92
+ Load: `references/sql-objects-injection.md`
149
93
 
150
94
  ---
151
95