@atlashub/smartstack-cli 4.35.0 → 4.36.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 +28 -32
- package/dist/index.js.map +1 -1
- package/dist/mcp-entry.mjs +29 -10
- package/dist/mcp-entry.mjs.map +1 -1
- package/package.json +1 -1
- package/templates/skills/apex/references/checks/seed-checks.sh +1 -1
- package/templates/skills/apex/references/core-seed-data.md +39 -21
- package/templates/skills/application/references/application-roles-template.md +14 -8
- package/templates/skills/application/references/provider-template.md +32 -20
- package/templates/skills/application/templates-frontend.md +294 -2
- package/templates/skills/application/templates-seed.md +23 -11
- package/templates/skills/audit-route/SKILL.md +107 -0
- package/templates/skills/audit-route/references/routing-pattern.md +129 -0
- package/templates/skills/audit-route/steps/step-00-init.md +128 -0
- package/templates/skills/audit-route/steps/step-01-inventory.md +157 -0
- package/templates/skills/audit-route/steps/step-02-conformity.md +193 -0
- package/templates/skills/audit-route/steps/step-03-report.md +201 -0
- package/templates/skills/dev-start/SKILL.md +12 -2
- package/templates/skills/efcore/SKILL.md +219 -67
- package/templates/agents/efcore/conflicts.md +0 -114
- package/templates/agents/efcore/db-deploy.md +0 -86
- package/templates/agents/efcore/db-reset.md +0 -98
- package/templates/agents/efcore/db-seed.md +0 -73
- package/templates/agents/efcore/db-status.md +0 -97
- package/templates/agents/efcore/scan.md +0 -124
- package/templates/skills/efcore/references/both-contexts.md +0 -32
- package/templates/skills/efcore/references/destructive-operations.md +0 -38
- package/templates/skills/efcore/steps/db/step-deploy.md +0 -217
- package/templates/skills/efcore/steps/db/step-reset.md +0 -186
- package/templates/skills/efcore/steps/db/step-seed.md +0 -166
- package/templates/skills/efcore/steps/db/step-status.md +0 -173
- package/templates/skills/efcore/steps/migration/step-00-init.md +0 -102
- package/templates/skills/efcore/steps/migration/step-01-check.md +0 -164
- package/templates/skills/efcore/steps/migration/step-02-create.md +0 -160
- package/templates/skills/efcore/steps/migration/step-03-validate.md +0 -168
- package/templates/skills/efcore/steps/rebase-snapshot/step-00-init.md +0 -173
- package/templates/skills/efcore/steps/rebase-snapshot/step-01-backup.md +0 -100
- package/templates/skills/efcore/steps/rebase-snapshot/step-02-fetch.md +0 -115
- package/templates/skills/efcore/steps/rebase-snapshot/step-03-create.md +0 -112
- package/templates/skills/efcore/steps/rebase-snapshot/step-04-validate.md +0 -157
- package/templates/skills/efcore/steps/shared/step-00-init.md +0 -131
- package/templates/skills/efcore/steps/squash/step-00-init.md +0 -141
- package/templates/skills/efcore/steps/squash/step-01-backup.md +0 -120
- package/templates/skills/efcore/steps/squash/step-02-fetch.md +0 -168
- package/templates/skills/efcore/steps/squash/step-03-create.md +0 -184
- package/templates/skills/efcore/steps/squash/step-04-validate.md +0 -174
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: efcore-db-status
|
|
3
|
-
description: EF Core database status - fast migration state check
|
|
4
|
-
color: blue
|
|
5
|
-
model: haiku
|
|
6
|
-
tools: Bash, Glob
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# EF Core Database Status Agent
|
|
10
|
-
|
|
11
|
-
Fast check of EF Core migration state using **SmartStack MCP**.
|
|
12
|
-
|
|
13
|
-
## FORBIDDEN
|
|
14
|
-
|
|
15
|
-
- **NEVER** create, delete, modify, or recreate migrations
|
|
16
|
-
- **NEVER** modify the database (`dotnet ef database update/drop` is FORBIDDEN)
|
|
17
|
-
- This agent is READ-ONLY: it only checks status, never modifies anything
|
|
18
|
-
|
|
19
|
-
## WSL Preflight (MANDATORY - run BEFORE any git command)
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
# Repair worktree .git file if Windows path detected under WSL
|
|
23
|
-
if [ -f .git ] && grep -q '^gitdir: [A-Za-z]:' .git 2>/dev/null && grep -qi microsoft /proc/version 2>/dev/null; then
|
|
24
|
-
p=$(sed 's/^gitdir: //' .git | tr -d '\r\n'); d=$(echo "${p:0:1}" | tr A-Z a-z); r="${p:2}"; r="${r//\\//}"
|
|
25
|
-
printf 'gitdir: %s\n' "$(realpath -m --relative-to="$(pwd)" "/mnt/$d$r")" > .git
|
|
26
|
-
echo "Worktree .git path repaired for WSL"
|
|
27
|
-
fi
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Workflow
|
|
31
|
-
|
|
32
|
-
1. **Invoke MCP** for migration list and naming validation
|
|
33
|
-
2. **Test** DB connection with `dotnet ef`
|
|
34
|
-
3. **Count** applied vs pending
|
|
35
|
-
4. **Verify** 1 migration per feature rule
|
|
36
|
-
5. **Output** compact summary
|
|
37
|
-
|
|
38
|
-
## MCP Integration
|
|
39
|
-
|
|
40
|
-
**Primary method:** Get structured migration data
|
|
41
|
-
|
|
42
|
-
```
|
|
43
|
-
CALL mcp__smartstack__check_migrations WITH:
|
|
44
|
-
- branch: {current_branch}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
**Response fields used:**
|
|
48
|
-
- `migrations[]` - List with name, context, version, sequence
|
|
49
|
-
- `conflicts[]` - Any naming issues
|
|
50
|
-
|
|
51
|
-
## Fallback Commands (if MCP unavailable)
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
# Migrations
|
|
55
|
-
dotnet ef migrations list --no-build 2>/dev/null | grep -v "^Build"
|
|
56
|
-
|
|
57
|
-
# Branch
|
|
58
|
-
git branch --show-current
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## Output Format
|
|
62
|
-
|
|
63
|
-
```
|
|
64
|
-
================================================================================
|
|
65
|
-
EF CORE - DATABASE STATUS
|
|
66
|
-
================================================================================
|
|
67
|
-
|
|
68
|
-
CORE CONTEXT (CoreDbContext)
|
|
69
|
-
Schema: core
|
|
70
|
-
History: core.__EFMigrationsHistory
|
|
71
|
-
Migrations: {applied}/{total} | {pending} pending
|
|
72
|
-
|
|
73
|
-
EXTENSIONS CONTEXT (ExtensionsDbContext)
|
|
74
|
-
Schema: extensions
|
|
75
|
-
History: extensions.__EFMigrationsHistory
|
|
76
|
-
Migrations: {applied}/{total} | {pending} pending
|
|
77
|
-
|
|
78
|
-
BRANCH STATUS
|
|
79
|
-
Branch: {branch}
|
|
80
|
-
Core migrations: {n}
|
|
81
|
-
Extensions migrations: {n}
|
|
82
|
-
Naming: {ok|warnings}
|
|
83
|
-
1-migration rule: {ok|warning}
|
|
84
|
-
|
|
85
|
-
================================================================================
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
## Dual DbContext Notes
|
|
89
|
-
|
|
90
|
-
- **Core migrations** use `--context CoreDbContext`
|
|
91
|
-
- **Extensions migrations** use `--context ExtensionsDbContext`
|
|
92
|
-
- Each context has its own `__EFMigrationsHistory` table
|
|
93
|
-
- Check both contexts when verifying migration status
|
|
94
|
-
|
|
95
|
-
## Priority
|
|
96
|
-
|
|
97
|
-
Speed > Detail. Use MCP for structured data, dotnet ef for connection test.
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: efcore-scan
|
|
3
|
-
description: EF Core cross-branch migration scanner - detect conflicts before they happen
|
|
4
|
-
color: cyan
|
|
5
|
-
model: haiku
|
|
6
|
-
tools: Bash, Glob, Read
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# EF Core Scan Agent
|
|
10
|
-
|
|
11
|
-
Cross-branch scanner using **SmartStack MCP** to detect migrations across all active branches.
|
|
12
|
-
|
|
13
|
-
## WSL Preflight (MANDATORY - run BEFORE any git command)
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
# Repair worktree .git file if Windows path detected under WSL
|
|
17
|
-
if [ -f .git ] && grep -q '^gitdir: [A-Za-z]:' .git 2>/dev/null && grep -qi microsoft /proc/version 2>/dev/null; then
|
|
18
|
-
p=$(sed 's/^gitdir: //' .git | tr -d '\r\n'); d=$(echo "${p:0:1}" | tr A-Z a-z); r="${p:2}"; r="${r//\\//}"
|
|
19
|
-
printf 'gitdir: %s\n' "$(realpath -m --relative-to="$(pwd)" "/mnt/$d$r")" > .git
|
|
20
|
-
echo "Worktree .git path repaired for WSL"
|
|
21
|
-
fi
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Mission
|
|
25
|
-
|
|
26
|
-
1. **List** all active worktrees
|
|
27
|
-
2. **Invoke MCP** for each branch
|
|
28
|
-
3. **Aggregate** results into summary
|
|
29
|
-
4. **Analyze** conflict risks
|
|
30
|
-
5. **Recommend** optimal merge order
|
|
31
|
-
|
|
32
|
-
## Base Branch Determination
|
|
33
|
-
|
|
34
|
-
**BEFORE calling MCP, determine the correct base branch for each worktree:**
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
# For each branch, determine its base:
|
|
38
|
-
# feature/* → compareBranch: "develop"
|
|
39
|
-
# release/* → compareBranch: "main"
|
|
40
|
-
# hotfix/* → compareBranch: "main"
|
|
41
|
-
# develop → compareBranch: "main"
|
|
42
|
-
determine_compare_branch() {
|
|
43
|
-
case "$1" in
|
|
44
|
-
feature/*) echo "develop" ;;
|
|
45
|
-
release/*) echo "main" ;;
|
|
46
|
-
hotfix/*) echo "main" ;;
|
|
47
|
-
develop) echo "main" ;;
|
|
48
|
-
*) echo "develop" ;;
|
|
49
|
-
esac
|
|
50
|
-
}
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
## MCP Integration
|
|
54
|
-
|
|
55
|
-
**Primary method:** Loop through branches and call MCP with the **correct base branch**
|
|
56
|
-
|
|
57
|
-
```
|
|
58
|
-
FOR each branch in active_worktrees:
|
|
59
|
-
COMPARE_BRANCH = determine_compare_branch(branch)
|
|
60
|
-
CALL mcp__smartstack__check_migrations WITH:
|
|
61
|
-
- branch: {branch}
|
|
62
|
-
- compareBranch: {COMPARE_BRANCH}
|
|
63
|
-
STORE result
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
**Response structure:**
|
|
67
|
-
|
|
68
|
-
```typescript
|
|
69
|
-
{
|
|
70
|
-
hasConflicts: boolean;
|
|
71
|
-
migrations: MigrationInfo[];
|
|
72
|
-
conflicts: MigrationConflict[];
|
|
73
|
-
suggestions: string[];
|
|
74
|
-
}
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
## Fallback Commands (if MCP unavailable)
|
|
78
|
-
|
|
79
|
-
```bash
|
|
80
|
-
# List worktrees (run preflight_git_check first for cross-platform compatibility)
|
|
81
|
-
detect_platform
|
|
82
|
-
repair_worktree_paths "$(git rev-parse --git-common-dir 2>/dev/null || echo '.bare')"
|
|
83
|
-
git worktree list
|
|
84
|
-
|
|
85
|
-
# ModelSnapshot hash
|
|
86
|
-
md5sum Migrations/*ModelSnapshot.cs | cut -d' ' -f1
|
|
87
|
-
|
|
88
|
-
# Compare with develop
|
|
89
|
-
diff -q local/Snapshot.cs develop/Snapshot.cs
|
|
90
|
-
|
|
91
|
-
# Count migrations
|
|
92
|
-
find Migrations -name "*.cs" | grep -v Designer | grep -v Snapshot | wc -l
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
## Risk Levels
|
|
96
|
-
|
|
97
|
-
| MCP Conflict Type | Level | Action |
|
|
98
|
-
|-------------------|-------|--------|
|
|
99
|
-
| (none) | NONE | Direct merge OK |
|
|
100
|
-
| `naming` | LOW | Merge OK |
|
|
101
|
-
| `order` | MEDIUM | Attention to order |
|
|
102
|
-
| `dependency` | HIGH | Rebase required |
|
|
103
|
-
| `snapshot` | CRITICAL | Manual intervention |
|
|
104
|
-
|
|
105
|
-
## Output Format
|
|
106
|
-
|
|
107
|
-
```
|
|
108
|
-
================================================================================
|
|
109
|
-
EF CORE CROSS-BRANCH SCAN (via MCP)
|
|
110
|
-
================================================================================
|
|
111
|
-
|
|
112
|
-
BRANCHES (n)
|
|
113
|
-
{branch} | {migrations.length} | Risk: {level}
|
|
114
|
-
|
|
115
|
-
RECOMMENDED MERGE ORDER
|
|
116
|
-
1. {branch} (reason)
|
|
117
|
-
2. {branch} (reason)
|
|
118
|
-
|
|
119
|
-
================================================================================
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
## Priority
|
|
123
|
-
|
|
124
|
-
Speed > Accuracy. Read-only, no modifications.
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# Both Contexts Deployment
|
|
2
|
-
|
|
3
|
-
When `RUN_BOTH=true` (auto-detected for client projects with SmartStack NuGet):
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
# 1. Deploy CoreDbContext first (system tables: Users, Roles, Tenants...)
|
|
7
|
-
echo "=== Deploying CoreDbContext (core schema) ==="
|
|
8
|
-
DBCONTEXT="CoreDbContext"
|
|
9
|
-
SCHEMA="core"
|
|
10
|
-
# Run steps 2-6 with CoreDbContext...
|
|
11
|
-
|
|
12
|
-
dotnet ef database update \
|
|
13
|
-
--context "CoreDbContext" \
|
|
14
|
-
--project "$INFRA_PROJECT" \
|
|
15
|
-
--startup-project "$STARTUP_PROJECT" \
|
|
16
|
-
--verbose
|
|
17
|
-
|
|
18
|
-
# 2. Then ExtensionsDbContext (client tables)
|
|
19
|
-
echo ""
|
|
20
|
-
echo "=== Deploying ExtensionsDbContext (extensions schema) ==="
|
|
21
|
-
DBCONTEXT="ExtensionsDbContext"
|
|
22
|
-
SCHEMA="extensions"
|
|
23
|
-
# Run steps 2-6 with ExtensionsDbContext...
|
|
24
|
-
|
|
25
|
-
dotnet ef database update \
|
|
26
|
-
--context "ExtensionsDbContext" \
|
|
27
|
-
--project "$INFRA_PROJECT" \
|
|
28
|
-
--startup-project "$STARTUP_PROJECT" \
|
|
29
|
-
--verbose
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
**Order matters:** Core MUST be deployed first (Extensions may have foreign keys to Core tables).
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# Destructive Operations & Zero-Downtime Patterns
|
|
2
|
-
|
|
3
|
-
When a migration contains destructive operations (DropColumn, RenameColumn, AlterColumn, DropTable), consider zero-downtime patterns for production deployments.
|
|
4
|
-
|
|
5
|
-
## Detection
|
|
6
|
-
|
|
7
|
-
Migration Analysis counts:
|
|
8
|
-
- DropColumn
|
|
9
|
-
- RenameColumn
|
|
10
|
-
- AlterColumn
|
|
11
|
-
- DropTable
|
|
12
|
-
|
|
13
|
-
If any count > 0, display warning and reference this document.
|
|
14
|
-
|
|
15
|
-
## Zero-Downtime Patterns
|
|
16
|
-
|
|
17
|
-
For production deployments with destructive operations:
|
|
18
|
-
|
|
19
|
-
1. **Add → Populate → Migrate → Remove** (for column renames)
|
|
20
|
-
- Add new column
|
|
21
|
-
- Populate from old column
|
|
22
|
-
- Deploy migration
|
|
23
|
-
- Remove old column in next deployment window
|
|
24
|
-
|
|
25
|
-
2. **Feature Flags** (for table changes)
|
|
26
|
-
- Add feature flag
|
|
27
|
-
- Deploy new code path
|
|
28
|
-
- Migrate data
|
|
29
|
-
- Remove old code path after stabilization
|
|
30
|
-
|
|
31
|
-
3. **Gradual Rollout**
|
|
32
|
-
- Deploy to staging first
|
|
33
|
-
- Monitor for issues
|
|
34
|
-
- Gradually roll to production clusters
|
|
35
|
-
|
|
36
|
-
## Reference
|
|
37
|
-
|
|
38
|
-
See OWASP and database migration best practices for your platform.
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: step-deploy
|
|
3
|
-
description: Deploy pending migrations to database
|
|
4
|
-
next_step: null
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Database Deploy
|
|
8
|
-
|
|
9
|
-
## YOUR TASK:
|
|
10
|
-
|
|
11
|
-
Apply pending EF Core migrations to the local database.
|
|
12
|
-
|
|
13
|
-
**Requires:** `steps/shared/step-00-init.md` completed
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
## EXECUTION SEQUENCE:
|
|
18
|
-
|
|
19
|
-
### 1. Environment Check
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
# Validate required variables from step-00-init
|
|
23
|
-
for VAR_NAME in DBCONTEXT DBCONTEXT_TYPE INFRA_PROJECT STARTUP_PROJECT SELECTED_ENV; do
|
|
24
|
-
eval VAR_VALUE=\$$VAR_NAME
|
|
25
|
-
if [ -z "$VAR_VALUE" ]; then
|
|
26
|
-
echo "ERROR: Required variable $VAR_NAME is not set"
|
|
27
|
-
echo "Run step-00-init first"
|
|
28
|
-
exit 1
|
|
29
|
-
fi
|
|
30
|
-
done
|
|
31
|
-
|
|
32
|
-
echo "Deploy Configuration"
|
|
33
|
-
echo "===================="
|
|
34
|
-
echo ""
|
|
35
|
-
echo "DbContext: $DBCONTEXT ($DBCONTEXT_TYPE)"
|
|
36
|
-
echo "Environment: $SELECTED_ENV"
|
|
37
|
-
echo "Database: $DATABASE_NAME"
|
|
38
|
-
echo "Server: $SERVER_NAME"
|
|
39
|
-
|
|
40
|
-
# Block production
|
|
41
|
-
block_production
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
### 2. Check Pending Migrations
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
echo ""
|
|
48
|
-
echo "Checking pending migrations..."
|
|
49
|
-
|
|
50
|
-
EF_STDERR=$(mktemp)
|
|
51
|
-
PENDING=$(dotnet ef migrations list \
|
|
52
|
-
--context "$DBCONTEXT" \
|
|
53
|
-
--project "$INFRA_PROJECT" \
|
|
54
|
-
--startup-project "$STARTUP_PROJECT" 2>"$EF_STDERR" | \
|
|
55
|
-
grep -c "(Pending)" || echo "0")
|
|
56
|
-
|
|
57
|
-
# Check for real errors (not just build output)
|
|
58
|
-
if grep -qi "error\|exception\|failed" "$EF_STDERR" 2>/dev/null; then
|
|
59
|
-
echo "WARNING: EF Core reported errors:"
|
|
60
|
-
grep -i "error\|exception\|failed" "$EF_STDERR" | head -5
|
|
61
|
-
fi
|
|
62
|
-
rm -f "$EF_STDERR"
|
|
63
|
-
|
|
64
|
-
echo "Pending: $PENDING migration(s)"
|
|
65
|
-
|
|
66
|
-
if [ "$PENDING" -eq 0 ]; then
|
|
67
|
-
echo ""
|
|
68
|
-
echo "No pending migrations. Database is up to date."
|
|
69
|
-
echo ""
|
|
70
|
-
echo "Next steps:"
|
|
71
|
-
echo " /efcore migration # Create new migration"
|
|
72
|
-
echo " /efcore db-status # Check status"
|
|
73
|
-
exit 0
|
|
74
|
-
fi
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### 3. List Pending Migrations
|
|
78
|
-
|
|
79
|
-
```bash
|
|
80
|
-
echo ""
|
|
81
|
-
echo "Migrations to apply:"
|
|
82
|
-
|
|
83
|
-
dotnet ef migrations list \
|
|
84
|
-
--context "$DBCONTEXT" \
|
|
85
|
-
--project "$INFRA_PROJECT" \
|
|
86
|
-
--startup-project "$STARTUP_PROJECT" 2>/dev/null | \
|
|
87
|
-
grep "(Pending)" | while read line; do
|
|
88
|
-
echo " - $line"
|
|
89
|
-
done
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### 4. Confirmation (if not auto mode)
|
|
93
|
-
|
|
94
|
-
```yaml
|
|
95
|
-
AskUserQuestion:
|
|
96
|
-
header: "Deploy"
|
|
97
|
-
question: "Apply {PENDING} migration(s) to {DATABASE_NAME}?"
|
|
98
|
-
options:
|
|
99
|
-
- label: "Yes, apply"
|
|
100
|
-
description: "Deploy to {SELECTED_ENV} environment"
|
|
101
|
-
- label: "Cancel"
|
|
102
|
-
description: "Do not apply"
|
|
103
|
-
multiSelect: false
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### 5. Apply Migrations
|
|
107
|
-
|
|
108
|
-
```bash
|
|
109
|
-
echo ""
|
|
110
|
-
echo "Applying migrations..."
|
|
111
|
-
echo ""
|
|
112
|
-
|
|
113
|
-
dotnet ef database update \
|
|
114
|
-
--context "$DBCONTEXT" \
|
|
115
|
-
--project "$INFRA_PROJECT" \
|
|
116
|
-
--startup-project "$STARTUP_PROJECT" \
|
|
117
|
-
--verbose
|
|
118
|
-
EXIT_CODE=$?
|
|
119
|
-
|
|
120
|
-
if [ $EXIT_CODE -ne 0 ]; then
|
|
121
|
-
echo ""
|
|
122
|
-
echo "ERROR: Migration failed (exit code: $EXIT_CODE)"
|
|
123
|
-
echo ""
|
|
124
|
-
echo "Troubleshooting:"
|
|
125
|
-
echo " - Check database connection"
|
|
126
|
-
echo " - Review migration content"
|
|
127
|
-
echo " - Try: /efcore db-reset"
|
|
128
|
-
exit 1
|
|
129
|
-
fi
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
### 6. Verify
|
|
133
|
-
|
|
134
|
-
```bash
|
|
135
|
-
echo ""
|
|
136
|
-
echo "Verifying..."
|
|
137
|
-
|
|
138
|
-
NEW_PENDING=$(dotnet ef migrations list \
|
|
139
|
-
--context "$DBCONTEXT" \
|
|
140
|
-
--project "$INFRA_PROJECT" \
|
|
141
|
-
--startup-project "$STARTUP_PROJECT" 2>/dev/null | \
|
|
142
|
-
grep -c "(Pending)" || echo "0")
|
|
143
|
-
|
|
144
|
-
if [ "$NEW_PENDING" -eq 0 ]; then
|
|
145
|
-
echo "All migrations applied successfully."
|
|
146
|
-
else
|
|
147
|
-
echo "WARNING: $NEW_PENDING migrations still pending"
|
|
148
|
-
fi
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
### 7. Summary
|
|
152
|
-
|
|
153
|
-
```bash
|
|
154
|
-
echo ""
|
|
155
|
-
echo "==========================================="
|
|
156
|
-
echo "DEPLOY COMPLETE"
|
|
157
|
-
echo "==========================================="
|
|
158
|
-
echo ""
|
|
159
|
-
echo "Database: $DATABASE_NAME"
|
|
160
|
-
echo "Environment: $SELECTED_ENV"
|
|
161
|
-
echo "DbContext: $DBCONTEXT"
|
|
162
|
-
echo "Applied: $PENDING migration(s)"
|
|
163
|
-
echo ""
|
|
164
|
-
echo "==========================================="
|
|
165
|
-
echo ""
|
|
166
|
-
echo "Next steps:"
|
|
167
|
-
echo " /efcore db-status # Verify status"
|
|
168
|
-
echo " /efcore db-seed # Add test data"
|
|
169
|
-
echo ""
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
---
|
|
173
|
-
|
|
174
|
-
## OUTPUT FORMAT:
|
|
175
|
-
|
|
176
|
-
```
|
|
177
|
-
DEPLOY COMPLETE
|
|
178
|
-
===============
|
|
179
|
-
Database: {database_name}
|
|
180
|
-
Environment: {env}
|
|
181
|
-
DbContext: {dbcontext}
|
|
182
|
-
Applied: {N} migration(s)
|
|
183
|
-
|
|
184
|
-
Next: /efcore db-status, /efcore db-seed
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
---
|
|
188
|
-
|
|
189
|
-
## ERROR HANDLING:
|
|
190
|
-
|
|
191
|
-
| Error | Resolution |
|
|
192
|
-
|-------|------------|
|
|
193
|
-
| Connection failed | Check SQL Server, credentials |
|
|
194
|
-
| Migration error | Review migration, consider reset |
|
|
195
|
-
| Constraint violation | Check data, may need seed |
|
|
196
|
-
|
|
197
|
-
---
|
|
198
|
-
|
|
199
|
-
## OPTIONS:
|
|
200
|
-
|
|
201
|
-
| Option | Description |
|
|
202
|
-
|--------|-------------|
|
|
203
|
-
| `--env {name}` | Use appsettings.{name}.json |
|
|
204
|
-
| `--verbose` | Show SQL statements |
|
|
205
|
-
| `--context {name}` | Specify DbContext |
|
|
206
|
-
|
|
207
|
-
---
|
|
208
|
-
|
|
209
|
-
## BOTH CONTEXTS:
|
|
210
|
-
|
|
211
|
-
Load: `references/both-contexts.md`
|
|
212
|
-
|
|
213
|
-
---
|
|
214
|
-
|
|
215
|
-
## COMPLETION:
|
|
216
|
-
|
|
217
|
-
Migrations applied. Use `/efcore db-status` to verify.
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: step-reset
|
|
3
|
-
description: Reset database - drop and recreate
|
|
4
|
-
next_step: null
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Database Reset
|
|
8
|
-
|
|
9
|
-
## YOUR TASK:
|
|
10
|
-
|
|
11
|
-
Completely reset the database: drop, recreate, and apply all migrations.
|
|
12
|
-
|
|
13
|
-
**WARNING:** This is DESTRUCTIVE. All data will be lost!
|
|
14
|
-
|
|
15
|
-
**Requires:** `steps/shared/step-00-init.md` completed
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
## COMPLIANCE:
|
|
20
|
-
|
|
21
|
-
| FORBIDDEN | REQUIRED |
|
|
22
|
-
|-----------|----------|
|
|
23
|
-
| `sqlcmd` for DDL/DML | `dotnet ef database drop` |
|
|
24
|
-
| SQL scripts in repo | `dotnet ef database update` |
|
|
25
|
-
| INSERT via scripts | `HasData()` for seeding |
|
|
26
|
-
|
|
27
|
-
**Exception:** `sqlcmd` allowed ONLY for `BACKUP DATABASE`.
|
|
28
|
-
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
## EXECUTION SEQUENCE:
|
|
32
|
-
|
|
33
|
-
### 1. Environment Check
|
|
34
|
-
|
|
35
|
-
Load validation: `references/database-operations.md#check-required-variables`
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
echo "Reset Configuration"
|
|
39
|
-
echo "==================="
|
|
40
|
-
echo ""
|
|
41
|
-
echo "DbContext: $DBCONTEXT ($DBCONTEXT_TYPE)"
|
|
42
|
-
echo "Environment: $SELECTED_ENV"
|
|
43
|
-
echo "Database: $DATABASE_NAME"
|
|
44
|
-
echo "Server: $SERVER_NAME"
|
|
45
|
-
echo ""
|
|
46
|
-
echo "WARNING: ALL DATA WILL BE LOST!"
|
|
47
|
-
|
|
48
|
-
# Block production
|
|
49
|
-
block_production
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### 2. Confirmation (MANDATORY)
|
|
53
|
-
|
|
54
|
-
```yaml
|
|
55
|
-
AskUserQuestion:
|
|
56
|
-
header: "Reset DB"
|
|
57
|
-
question: "DANGER: Permanently delete '{DATABASE_NAME}'?
|
|
58
|
-
|
|
59
|
-
ALL DATA WILL BE LOST!
|
|
60
|
-
|
|
61
|
-
This action is IRREVERSIBLE."
|
|
62
|
-
options:
|
|
63
|
-
- label: "Yes, delete {DATABASE_NAME}"
|
|
64
|
-
description: "Drop + Recreate (IRREVERSIBLE)"
|
|
65
|
-
- label: "No, cancel"
|
|
66
|
-
description: "Keep database"
|
|
67
|
-
multiSelect: false
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
### 3. Optional Backup
|
|
71
|
-
|
|
72
|
-
```yaml
|
|
73
|
-
AskUserQuestion:
|
|
74
|
-
header: "Backup"
|
|
75
|
-
question: "Backup database before deletion?"
|
|
76
|
-
options:
|
|
77
|
-
- label: "Yes, backup (Recommended)"
|
|
78
|
-
description: "Create .bak via sqlcmd"
|
|
79
|
-
- label: "No"
|
|
80
|
-
description: "Dev data only - continue"
|
|
81
|
-
- label: "Manual backup"
|
|
82
|
-
description: "Via SSMS/Azure Portal (stops here)"
|
|
83
|
-
multiSelect: false
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
**If backup requested:**
|
|
87
|
-
|
|
88
|
-
Load: `references/database-operations.md#backup-command`
|
|
89
|
-
|
|
90
|
-
### 4. Drop Database
|
|
91
|
-
|
|
92
|
-
Load: `references/reset-operations.md#drop-database`
|
|
93
|
-
|
|
94
|
-
### 5. Recreate + Apply Migrations
|
|
95
|
-
|
|
96
|
-
Load: `references/reset-operations.md#recreate--apply-migrations`
|
|
97
|
-
|
|
98
|
-
### 6. Optional Seed
|
|
99
|
-
|
|
100
|
-
```yaml
|
|
101
|
-
AskUserQuestion:
|
|
102
|
-
header: "Seed"
|
|
103
|
-
question: "Populate with test data (HasData)?"
|
|
104
|
-
options:
|
|
105
|
-
- label: "Yes (recommended)"
|
|
106
|
-
description: "Apply HasData configurations"
|
|
107
|
-
- label: "No"
|
|
108
|
-
description: "Empty database"
|
|
109
|
-
multiSelect: false
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
**If seed requested:**
|
|
113
|
-
|
|
114
|
-
```bash
|
|
115
|
-
echo ""
|
|
116
|
-
echo "Running seed..."
|
|
117
|
-
|
|
118
|
-
# HasData is already applied via migrations
|
|
119
|
-
# For custom seeding:
|
|
120
|
-
dotnet run --project "$STARTUP_PROJECT" -- --seed 2>/dev/null || echo "No --seed argument supported"
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
### 7. Summary
|
|
124
|
-
|
|
125
|
-
Load: `references/reset-operations.md#summary-after-reset`
|
|
126
|
-
|
|
127
|
-
---
|
|
128
|
-
|
|
129
|
-
## OUTPUT FORMAT:
|
|
130
|
-
|
|
131
|
-
```
|
|
132
|
-
RESET COMPLETE
|
|
133
|
-
==============
|
|
134
|
-
Database: {database_name}
|
|
135
|
-
Environment: {env}
|
|
136
|
-
DbContext: {dbcontext}
|
|
137
|
-
|
|
138
|
-
Operations:
|
|
139
|
-
- Drop: OK
|
|
140
|
-
- Create: OK
|
|
141
|
-
- Migrations: {N} applied
|
|
142
|
-
- Backup: {path | none}
|
|
143
|
-
|
|
144
|
-
Compliance: EF Core CLI only
|
|
145
|
-
|
|
146
|
-
Next: /efcore db-status, /efcore db-seed
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
---
|
|
150
|
-
|
|
151
|
-
## PROTECTIONS:
|
|
152
|
-
|
|
153
|
-
Load: `references/troubleshooting.md#reset-protections`
|
|
154
|
-
|
|
155
|
-
---
|
|
156
|
-
|
|
157
|
-
## BOTH CONTEXTS:
|
|
158
|
-
|
|
159
|
-
If "Both" selected:
|
|
160
|
-
|
|
161
|
-
```bash
|
|
162
|
-
# Drop + Recreate CoreDbContext
|
|
163
|
-
DBCONTEXT="CoreDbContext"
|
|
164
|
-
# ... execute reset ...
|
|
165
|
-
|
|
166
|
-
# Then ExtensionsDbContext
|
|
167
|
-
DBCONTEXT="ExtensionsDbContext"
|
|
168
|
-
# ... execute reset ...
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
---
|
|
172
|
-
|
|
173
|
-
## OPTIONS:
|
|
174
|
-
|
|
175
|
-
| Option | Description |
|
|
176
|
-
|--------|-------------|
|
|
177
|
-
| `--env {name}` | Use appsettings.{name}.json |
|
|
178
|
-
| `--no-backup` | Skip backup step |
|
|
179
|
-
| `--context {name}` | Specify DbContext |
|
|
180
|
-
| `--seed` | Auto-seed after reset |
|
|
181
|
-
|
|
182
|
-
---
|
|
183
|
-
|
|
184
|
-
## COMPLETION:
|
|
185
|
-
|
|
186
|
-
Database reset complete. Fresh state with all migrations applied.
|