@atlashub/smartstack-cli 4.35.0 → 4.37.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 +54 -100
- package/dist/index.js.map +1 -1
- package/dist/mcp-entry.mjs +54 -11
- package/dist/mcp-entry.mjs.map +1 -1
- package/package.json +1 -1
- package/templates/agents/efcore/migration.md +43 -0
- package/templates/agents/efcore/rebase-snapshot.md +36 -0
- package/templates/agents/efcore/squash.md +36 -0
- 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,164 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: step-01-check
|
|
3
|
-
description: Check for existing migration and decide action
|
|
4
|
-
next_step: step-02-create.md
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Step 1: Check Existing Migration
|
|
8
|
-
|
|
9
|
-
## YOUR TASK:
|
|
10
|
-
|
|
11
|
-
Search for existing migrations for this branch and decide whether to recreate or skip.
|
|
12
|
-
|
|
13
|
-
**Previous step:** `step-00-init.md`
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
## EXECUTION SEQUENCE:
|
|
18
|
-
|
|
19
|
-
### 0. Validate Required Variables
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
# Validate required variables from step-00-init
|
|
23
|
-
for VAR_NAME in DBCONTEXT DBCONTEXT_TYPE MIGRATIONS_DIR INFRA_PROJECT STARTUP_PROJECT CURRENT_BRANCH BRANCH_TYPE; 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
|
-
|
|
33
|
-
### 1. Build Search Pattern
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
# Extract branch name for pattern
|
|
37
|
-
case "$BRANCH_TYPE" in
|
|
38
|
-
feature)
|
|
39
|
-
BRANCH_SHORT=$(echo "$CURRENT_BRANCH" | sed 's|feature/||' | tr '-' '_')
|
|
40
|
-
;;
|
|
41
|
-
release)
|
|
42
|
-
BRANCH_SHORT=$(echo "$CURRENT_BRANCH" | sed 's|release/||' | tr '.' '_')
|
|
43
|
-
;;
|
|
44
|
-
hotfix)
|
|
45
|
-
BRANCH_SHORT=$(echo "$CURRENT_BRANCH" | sed 's|hotfix/||' | tr '.' '_')
|
|
46
|
-
;;
|
|
47
|
-
*)
|
|
48
|
-
BRANCH_SHORT=""
|
|
49
|
-
;;
|
|
50
|
-
esac
|
|
51
|
-
|
|
52
|
-
echo "Searching for existing migrations..."
|
|
53
|
-
echo " Pattern: *${BRANCH_SHORT}*"
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### 2. Find Existing Migrations
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
# Sanitize branch name: only allow alphanumeric, underscore (prevent regex/shell injection)
|
|
60
|
-
BRANCH_SHORT_SAFE=$(echo "$BRANCH_SHORT" | sed 's/[^a-zA-Z0-9_]//g')
|
|
61
|
-
if [ -z "$BRANCH_SHORT_SAFE" ]; then
|
|
62
|
-
echo "ERROR: Invalid branch name (no alphanumeric characters after sanitization)"
|
|
63
|
-
exit 1
|
|
64
|
-
fi
|
|
65
|
-
|
|
66
|
-
# Search for migrations matching this branch (-F = fixed-string, prevents regex injection)
|
|
67
|
-
EXISTING_MIGRATIONS=$(find "$MIGRATIONS_DIR" -name "*.cs" ! -name "*Designer.cs" ! -name "*Snapshot.cs" -type f 2>/dev/null | \
|
|
68
|
-
xargs -I{} basename {} | \
|
|
69
|
-
grep -iF "$BRANCH_SHORT_SAFE" || echo "")
|
|
70
|
-
|
|
71
|
-
EXISTING_COUNT=$(echo "$EXISTING_MIGRATIONS" | grep -c "^[^ ]" 2>/dev/null || echo "0")
|
|
72
|
-
|
|
73
|
-
echo ""
|
|
74
|
-
if [ "$EXISTING_COUNT" -gt 0 ]; then
|
|
75
|
-
echo "Found $EXISTING_COUNT existing migration(s):"
|
|
76
|
-
echo "$EXISTING_MIGRATIONS" | while read mig; do
|
|
77
|
-
echo " - $mig"
|
|
78
|
-
done
|
|
79
|
-
else
|
|
80
|
-
echo "No existing migration for this branch."
|
|
81
|
-
fi
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### 3. Decide Action
|
|
85
|
-
|
|
86
|
-
**If migrations exist and NOT force mode:**
|
|
87
|
-
|
|
88
|
-
```yaml
|
|
89
|
-
AskUserQuestion:
|
|
90
|
-
header: "Migration"
|
|
91
|
-
question: "Found {EXISTING_COUNT} existing migration(s). What do you want to do?"
|
|
92
|
-
options:
|
|
93
|
-
- label: "Recreate (Recommended)"
|
|
94
|
-
description: "Delete existing and create new"
|
|
95
|
-
- label: "Keep and add new"
|
|
96
|
-
description: "Add another migration (not recommended)"
|
|
97
|
-
- label: "Cancel"
|
|
98
|
-
description: "Do nothing"
|
|
99
|
-
multiSelect: false
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
**Handle response:**
|
|
103
|
-
|
|
104
|
-
```javascript
|
|
105
|
-
if (answer === "Recreate (Recommended)" || force_mode) {
|
|
106
|
-
// Delete existing migrations
|
|
107
|
-
ACTION = "recreate";
|
|
108
|
-
} else if (answer === "Keep and add new") {
|
|
109
|
-
ACTION = "add";
|
|
110
|
-
// Warning: violates 1-migration-per-feature rule
|
|
111
|
-
} else {
|
|
112
|
-
// Cancel
|
|
113
|
-
exit(0);
|
|
114
|
-
}
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### 4. Delete Existing (If Recreate)
|
|
118
|
-
|
|
119
|
-
```bash
|
|
120
|
-
if [ "$ACTION" = "recreate" ]; then
|
|
121
|
-
echo ""
|
|
122
|
-
echo "Removing existing migrations..."
|
|
123
|
-
|
|
124
|
-
for mig in $EXISTING_MIGRATIONS; do
|
|
125
|
-
mig_name="${mig%.cs}"
|
|
126
|
-
|
|
127
|
-
rm -f "$MIGRATIONS_DIR/${mig_name}.cs"
|
|
128
|
-
rm -f "$MIGRATIONS_DIR/${mig_name}.Designer.cs"
|
|
129
|
-
|
|
130
|
-
# Verify deletion succeeded
|
|
131
|
-
if [ -f "$MIGRATIONS_DIR/${mig_name}.cs" ]; then
|
|
132
|
-
echo " ERROR: Failed to delete ${mig_name}.cs"
|
|
133
|
-
exit 1
|
|
134
|
-
fi
|
|
135
|
-
|
|
136
|
-
echo " Removed: $mig_name"
|
|
137
|
-
done
|
|
138
|
-
|
|
139
|
-
echo ""
|
|
140
|
-
echo "Existing migrations removed."
|
|
141
|
-
fi
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
---
|
|
145
|
-
|
|
146
|
-
## STATE OUTPUT:
|
|
147
|
-
|
|
148
|
-
| Variable | Description |
|
|
149
|
-
|----------|-------------|
|
|
150
|
-
| `{existing_migrations}` | List of existing migrations |
|
|
151
|
-
| `{existing_count}` | Number found |
|
|
152
|
-
| `{action}` | "recreate", "add", or "cancel" |
|
|
153
|
-
|
|
154
|
-
---
|
|
155
|
-
|
|
156
|
-
## SUCCESS CRITERIA:
|
|
157
|
-
|
|
158
|
-
- Existing migrations identified
|
|
159
|
-
- User decision captured
|
|
160
|
-
- Old migrations removed (if recreate)
|
|
161
|
-
|
|
162
|
-
## NEXT STEP:
|
|
163
|
-
|
|
164
|
-
→ `step-02-create.md`
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: step-02-create
|
|
3
|
-
description: Create migration with MCP naming
|
|
4
|
-
next_step: step-03-validate.md
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Step 2: Create Migration
|
|
8
|
-
|
|
9
|
-
## YOUR TASK:
|
|
10
|
-
|
|
11
|
-
Get migration description from user, call MCP for compliant name, and create migration.
|
|
12
|
-
|
|
13
|
-
**MANDATORY:** Use MCP `suggest_migration` for naming. NEVER hardcode.
|
|
14
|
-
|
|
15
|
-
**Previous step:** `step-01-check.md`
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
## EXECUTION SEQUENCE:
|
|
20
|
-
|
|
21
|
-
### 1. Get Description from User
|
|
22
|
-
|
|
23
|
-
**If NOT force mode with predefined description:**
|
|
24
|
-
|
|
25
|
-
```yaml
|
|
26
|
-
AskUserQuestion:
|
|
27
|
-
header: "Description"
|
|
28
|
-
question: "Short description for the migration (e.g., 'Add User Roles'):"
|
|
29
|
-
options:
|
|
30
|
-
- label: "Add..."
|
|
31
|
-
description: "Adding tables/columns"
|
|
32
|
-
- label: "Update..."
|
|
33
|
-
description: "Modifying structure"
|
|
34
|
-
- label: "Fix..."
|
|
35
|
-
description: "Schema correction"
|
|
36
|
-
- label: "Remove..."
|
|
37
|
-
description: "Deleting elements"
|
|
38
|
-
multiSelect: false
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
**User can also provide free text (Other option).**
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
# DESCRIPTION = user response or predefined value
|
|
45
|
-
# Examples: "Add User Roles", "Update Tenant Schema", "Fix Foreign Keys"
|
|
46
|
-
|
|
47
|
-
echo ""
|
|
48
|
-
echo "Description: $DESCRIPTION"
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### 2. Verify MCP Availability
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
# Check MCP cache before calling suggest_migration
|
|
55
|
-
MCP_STATUS_FILE=".claude/mcp-status.json"
|
|
56
|
-
|
|
57
|
-
if [ -f "$MCP_STATUS_FILE" ]; then
|
|
58
|
-
MCP_STATUS=$(cat "$MCP_STATUS_FILE" | grep -o '"status":"[^"]*"' | head -1 | cut -d'"' -f4)
|
|
59
|
-
if [ "$MCP_STATUS" = "error" ]; then
|
|
60
|
-
echo "ERROR: MCP server is unavailable (status: error)"
|
|
61
|
-
echo "Run: /mcp healthcheck to diagnose"
|
|
62
|
-
exit 1
|
|
63
|
-
fi
|
|
64
|
-
fi
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### 3. Call MCP for Migration Name (MANDATORY)
|
|
68
|
-
|
|
69
|
-
```javascript
|
|
70
|
-
// DESCRIPTION = from user input (e.g., "Add User Roles")
|
|
71
|
-
// DBCONTEXT_TYPE = "core" or "extensions" (from detect_dbcontext)
|
|
72
|
-
|
|
73
|
-
const result = await mcp__smartstack__suggest_migration({
|
|
74
|
-
description: DESCRIPTION,
|
|
75
|
-
context: DBCONTEXT_TYPE // NEVER hardcode!
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// Result example: core_v1.8.0_001_AddUserRoles
|
|
79
|
-
MIGRATION_NAME = result.migrationName;
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
**FORBIDDEN:**
|
|
83
|
-
- Calculating name manually
|
|
84
|
-
- Hardcoding context as "core"
|
|
85
|
-
- Using wrong version format
|
|
86
|
-
|
|
87
|
-
### 4. Display Migration Name
|
|
88
|
-
|
|
89
|
-
```bash
|
|
90
|
-
echo ""
|
|
91
|
-
echo "Migration name: $MIGRATION_NAME"
|
|
92
|
-
echo "Context: $DBCONTEXT"
|
|
93
|
-
echo ""
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### 5. Create Migration
|
|
97
|
-
|
|
98
|
-
```bash
|
|
99
|
-
echo "Creating migration..."
|
|
100
|
-
echo ""
|
|
101
|
-
|
|
102
|
-
dotnet ef migrations add "$MIGRATION_NAME" \
|
|
103
|
-
--context "$DBCONTEXT" \
|
|
104
|
-
--project "$INFRA_PROJECT" \
|
|
105
|
-
--startup-project "$STARTUP_PROJECT" \
|
|
106
|
-
-o Persistence/Migrations \
|
|
107
|
-
--verbose
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
### 6. Verify Creation
|
|
111
|
-
|
|
112
|
-
```bash
|
|
113
|
-
# Check files were created
|
|
114
|
-
MIGRATION_FILE="$MIGRATIONS_DIR/${MIGRATION_NAME}.cs"
|
|
115
|
-
DESIGNER_FILE="$MIGRATIONS_DIR/${MIGRATION_NAME}.Designer.cs"
|
|
116
|
-
|
|
117
|
-
if [ ! -f "$MIGRATION_FILE" ]; then
|
|
118
|
-
echo ""
|
|
119
|
-
echo "ERROR: Migration file not created"
|
|
120
|
-
echo "Expected: $MIGRATION_FILE"
|
|
121
|
-
exit 1
|
|
122
|
-
fi
|
|
123
|
-
|
|
124
|
-
echo ""
|
|
125
|
-
echo "Migration created:"
|
|
126
|
-
echo " $MIGRATION_FILE"
|
|
127
|
-
echo " $DESIGNER_FILE"
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
---
|
|
131
|
-
|
|
132
|
-
## STATE OUTPUT:
|
|
133
|
-
|
|
134
|
-
| Variable | Description |
|
|
135
|
-
|----------|-------------|
|
|
136
|
-
| `{description}` | User-provided description |
|
|
137
|
-
| `{migration_name}` | Name from MCP |
|
|
138
|
-
| `{migration_file}` | Path to .cs file |
|
|
139
|
-
|
|
140
|
-
---
|
|
141
|
-
|
|
142
|
-
## ERROR HANDLING:
|
|
143
|
-
|
|
144
|
-
| Error | Resolution |
|
|
145
|
-
|-------|------------|
|
|
146
|
-
| MCP unavailable | Check connection, retry |
|
|
147
|
-
| Creation fails | Check dotnet ef output |
|
|
148
|
-
| File not created | Verify paths and permissions |
|
|
149
|
-
|
|
150
|
-
---
|
|
151
|
-
|
|
152
|
-
## SUCCESS CRITERIA:
|
|
153
|
-
|
|
154
|
-
- Description captured
|
|
155
|
-
- MCP called successfully
|
|
156
|
-
- Migration files created
|
|
157
|
-
|
|
158
|
-
## NEXT STEP:
|
|
159
|
-
|
|
160
|
-
→ `step-03-validate.md`
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: step-03-validate
|
|
3
|
-
description: Validate migration and optionally deploy
|
|
4
|
-
next_step: null
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Step 3: Validate Migration
|
|
8
|
-
|
|
9
|
-
## YOUR TASK:
|
|
10
|
-
|
|
11
|
-
Validate the created migration and optionally apply it to the local database.
|
|
12
|
-
|
|
13
|
-
**Previous step:** `step-02-create.md`
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
## EXECUTION SEQUENCE:
|
|
18
|
-
|
|
19
|
-
### 1. Build Project
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
echo "Building project..."
|
|
23
|
-
echo ""
|
|
24
|
-
|
|
25
|
-
dotnet build "$INFRA_PROJECT" --no-restore
|
|
26
|
-
|
|
27
|
-
if [ $? -ne 0 ]; then
|
|
28
|
-
echo ""
|
|
29
|
-
echo "ERROR: Build failed"
|
|
30
|
-
echo "Please fix compilation errors and retry."
|
|
31
|
-
exit 1
|
|
32
|
-
fi
|
|
33
|
-
|
|
34
|
-
echo "Build: OK"
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### 2. Show Migration Content Summary
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
echo ""
|
|
41
|
-
echo "Migration content:"
|
|
42
|
-
echo ""
|
|
43
|
-
|
|
44
|
-
# Count operations in migration
|
|
45
|
-
UP_TABLES=$(grep -c "CreateTable" "$MIGRATION_FILE" || echo "0")
|
|
46
|
-
UP_COLUMNS=$(grep -c "AddColumn" "$MIGRATION_FILE" || echo "0")
|
|
47
|
-
UP_INDEXES=$(grep -c "CreateIndex" "$MIGRATION_FILE" || echo "0")
|
|
48
|
-
UP_FOREIGN=$(grep -c "AddForeignKey" "$MIGRATION_FILE" || echo "0")
|
|
49
|
-
|
|
50
|
-
echo " Tables: $UP_TABLES"
|
|
51
|
-
echo " Columns: $UP_COLUMNS"
|
|
52
|
-
echo " Indexes: $UP_INDEXES"
|
|
53
|
-
echo " Foreign Keys:$UP_FOREIGN"
|
|
54
|
-
|
|
55
|
-
# Detect destructive operations
|
|
56
|
-
DROP_COL=$(grep -c "DropColumn" "$MIGRATION_FILE" || echo "0")
|
|
57
|
-
RENAME_COL=$(grep -c "RenameColumn" "$MIGRATION_FILE" || echo "0")
|
|
58
|
-
ALTER_COL=$(grep -c "AlterColumn" "$MIGRATION_FILE" || echo "0")
|
|
59
|
-
DROP_TABLE=$(grep -c "DropTable" "$MIGRATION_FILE" || echo "0")
|
|
60
|
-
DESTRUCTIVE=$((DROP_COL + RENAME_COL + ALTER_COL + DROP_TABLE))
|
|
61
|
-
|
|
62
|
-
if [ "$DESTRUCTIVE" -gt 0 ]; then
|
|
63
|
-
echo ""
|
|
64
|
-
echo "WARNING: Destructive operations detected:"
|
|
65
|
-
[ "$DROP_COL" -gt 0 ] && echo " DropColumn: $DROP_COL"
|
|
66
|
-
[ "$RENAME_COL" -gt 0 ] && echo " RenameColumn: $RENAME_COL"
|
|
67
|
-
[ "$ALTER_COL" -gt 0 ] && echo " AlterColumn: $ALTER_COL"
|
|
68
|
-
[ "$DROP_TABLE" -gt 0 ] && echo " DropTable: $DROP_TABLE"
|
|
69
|
-
echo ""
|
|
70
|
-
echo "For production deployments, consider zero-downtime migration patterns."
|
|
71
|
-
echo "See: references/zero-downtime-patterns.md"
|
|
72
|
-
fi
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### 3. Ask User to Validate
|
|
76
|
-
|
|
77
|
-
**If NOT auto mode:**
|
|
78
|
-
|
|
79
|
-
```yaml
|
|
80
|
-
AskUserQuestion:
|
|
81
|
-
header: "Validation"
|
|
82
|
-
question: "Migration created. What do you want to do?"
|
|
83
|
-
options:
|
|
84
|
-
- label: "Apply to local DB"
|
|
85
|
-
description: "Run /efcore db-deploy now"
|
|
86
|
-
- label: "Keep without applying"
|
|
87
|
-
description: "Apply later manually"
|
|
88
|
-
- label: "Delete and retry"
|
|
89
|
-
description: "Remove migration, start over"
|
|
90
|
-
multiSelect: false
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
See: `references/destructive-operations.md` for zero-downtime patterns.
|
|
94
|
-
|
|
95
|
-
### 4. Handle Response
|
|
96
|
-
|
|
97
|
-
```javascript
|
|
98
|
-
if (answer === "Apply to local DB") {
|
|
99
|
-
// Apply migration
|
|
100
|
-
ACTION = "deploy";
|
|
101
|
-
} else if (answer === "Keep without applying") {
|
|
102
|
-
ACTION = "keep";
|
|
103
|
-
} else {
|
|
104
|
-
// Delete and start over
|
|
105
|
-
ACTION = "delete";
|
|
106
|
-
}
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
### 5. Execute Action
|
|
110
|
-
|
|
111
|
-
**If deploy:**
|
|
112
|
-
|
|
113
|
-
```bash
|
|
114
|
-
echo ""
|
|
115
|
-
echo "Applying migration..."
|
|
116
|
-
|
|
117
|
-
dotnet ef database update \
|
|
118
|
-
--context "$DBCONTEXT" \
|
|
119
|
-
--project "$INFRA_PROJECT" \
|
|
120
|
-
--startup-project "$STARTUP_PROJECT" \
|
|
121
|
-
--verbose
|
|
122
|
-
|
|
123
|
-
if [ $? -eq 0 ]; then
|
|
124
|
-
echo ""
|
|
125
|
-
echo "Migration applied successfully."
|
|
126
|
-
else
|
|
127
|
-
echo ""
|
|
128
|
-
echo "ERROR: Migration failed to apply."
|
|
129
|
-
echo "Database may need reset: /efcore db-reset"
|
|
130
|
-
fi
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
**If delete:**
|
|
134
|
-
|
|
135
|
-
```bash
|
|
136
|
-
echo ""
|
|
137
|
-
echo "Removing migration..."
|
|
138
|
-
|
|
139
|
-
dotnet ef migrations remove \
|
|
140
|
-
--context "$DBCONTEXT" \
|
|
141
|
-
--project "$INFRA_PROJECT" \
|
|
142
|
-
--startup-project "$STARTUP_PROJECT" \
|
|
143
|
-
--force
|
|
144
|
-
|
|
145
|
-
echo "Migration removed. Run /efcore migration to start over."
|
|
146
|
-
exit 0
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
### 6. Final Summary
|
|
150
|
-
|
|
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
|
|
157
|
-
|
|
158
|
-
---
|
|
159
|
-
|
|
160
|
-
## SUCCESS CRITERIA:
|
|
161
|
-
|
|
162
|
-
- Build passes
|
|
163
|
-
- Migration content reviewed
|
|
164
|
-
- User action executed
|
|
165
|
-
|
|
166
|
-
## COMPLETION:
|
|
167
|
-
|
|
168
|
-
Migration workflow complete.
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: step-00-init
|
|
3
|
-
description: Initialize rebase-snapshot - verify prerequisites
|
|
4
|
-
next_step: step-01-backup.md
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Step 0: Initialize Rebase-Snapshot
|
|
8
|
-
|
|
9
|
-
## YOUR TASK:
|
|
10
|
-
|
|
11
|
-
Verify prerequisites for rebase-snapshot operation.
|
|
12
|
-
|
|
13
|
-
**Requires:** `steps/shared/step-00-init.md` completed (provides {dbcontext}, {base_branch}, etc.)
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
## WHEN TO USE:
|
|
18
|
-
|
|
19
|
-
| Situation | Action |
|
|
20
|
-
|-----------|--------|
|
|
21
|
-
| `/efcore conflicts` shows HIGH | Use rebase-snapshot |
|
|
22
|
-
| ModelSnapshot merge conflict | Use rebase-snapshot |
|
|
23
|
-
| Multiple migrations to consolidate | Use rebase-snapshot |
|
|
24
|
-
| Snapshot diverged from parent | Use rebase-snapshot |
|
|
25
|
-
|
|
26
|
-
---
|
|
27
|
-
|
|
28
|
-
## EXECUTION SEQUENCE:
|
|
29
|
-
|
|
30
|
-
### 1. Verify Branch Type
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
case "$BRANCH_TYPE" in
|
|
34
|
-
feature|release|hotfix)
|
|
35
|
-
echo "Branch type: $BRANCH_TYPE (OK)"
|
|
36
|
-
;;
|
|
37
|
-
develop|main|master)
|
|
38
|
-
echo "ERROR: Cannot rebase-snapshot on $BRANCH_TYPE branch"
|
|
39
|
-
exit 1
|
|
40
|
-
;;
|
|
41
|
-
*)
|
|
42
|
-
echo "WARNING: Unknown branch type: $BRANCH_TYPE"
|
|
43
|
-
;;
|
|
44
|
-
esac
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
### 2. Verify Clean Working Directory
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
if [ -n "$(git status --porcelain)" ]; then
|
|
51
|
-
echo "ERROR: Working directory not clean"
|
|
52
|
-
git status --short
|
|
53
|
-
exit 1
|
|
54
|
-
fi
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
### 3. Display Context
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
echo ""
|
|
61
|
-
echo "Rebase-Snapshot Context"
|
|
62
|
-
echo "======================="
|
|
63
|
-
echo ""
|
|
64
|
-
echo "Branch: $CURRENT_BRANCH"
|
|
65
|
-
echo "Parent: $BASE_BRANCH"
|
|
66
|
-
echo "DbContext: $DBCONTEXT ($DBCONTEXT_TYPE)"
|
|
67
|
-
echo "Schema: $SCHEMA"
|
|
68
|
-
echo "Migrations: $MIGRATIONS_DIR"
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### 4. Identify Branch Migrations
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
# Fetch parent
|
|
75
|
-
git fetch origin "$BASE_BRANCH" --quiet
|
|
76
|
-
|
|
77
|
-
# Get migrations from parent
|
|
78
|
-
PARENT_MIGRATIONS=$(git ls-tree -r --name-only "origin/$BASE_BRANCH" -- "$MIGRATIONS_DIR" 2>/dev/null | grep "\.cs$" | grep -v "Designer\|Snapshot" || echo "")
|
|
79
|
-
|
|
80
|
-
# Get local migrations
|
|
81
|
-
LOCAL_MIGRATIONS=$(find "$MIGRATIONS_DIR" -name "*.cs" 2>/dev/null | grep -v "Designer\|Snapshot" | xargs -I{} basename {} 2>/dev/null || echo "")
|
|
82
|
-
|
|
83
|
-
# Find branch-only migrations (exact match, not substring)
|
|
84
|
-
BRANCH_MIGRATIONS=()
|
|
85
|
-
for mig in $LOCAL_MIGRATIONS; do
|
|
86
|
-
if ! echo "$PARENT_MIGRATIONS" | grep -qx "$(basename "$mig")"; then
|
|
87
|
-
BRANCH_MIGRATIONS+=("$mig")
|
|
88
|
-
fi
|
|
89
|
-
done
|
|
90
|
-
|
|
91
|
-
BRANCH_MIG_COUNT=${#BRANCH_MIGRATIONS[@]}
|
|
92
|
-
|
|
93
|
-
echo ""
|
|
94
|
-
echo "Branch migrations: $BRANCH_MIG_COUNT"
|
|
95
|
-
for mig in "${BRANCH_MIGRATIONS[@]}"; do
|
|
96
|
-
echo " - $mig"
|
|
97
|
-
done
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
### 5. Check Snapshot Divergence
|
|
101
|
-
|
|
102
|
-
```bash
|
|
103
|
-
echo ""
|
|
104
|
-
echo "Checking snapshot divergence..."
|
|
105
|
-
|
|
106
|
-
PARENT_SNAPSHOT=$(git show "origin/$BASE_BRANCH:$MIGRATIONS_DIR/${DBCONTEXT}ModelSnapshot.cs" 2>/dev/null || echo "")
|
|
107
|
-
LOCAL_SNAPSHOT=$(cat "$MIGRATIONS_DIR/${DBCONTEXT}ModelSnapshot.cs" 2>/dev/null || echo "")
|
|
108
|
-
|
|
109
|
-
if [ -n "$PARENT_SNAPSHOT" ] && [ -n "$LOCAL_SNAPSHOT" ]; then
|
|
110
|
-
DIFF_LINES=$(diff <(echo "$PARENT_SNAPSHOT") <(echo "$LOCAL_SNAPSHOT") 2>/dev/null | wc -l)
|
|
111
|
-
echo " Snapshot difference: $DIFF_LINES lines"
|
|
112
|
-
|
|
113
|
-
if [ "$DIFF_LINES" -eq 0 ]; then
|
|
114
|
-
echo ""
|
|
115
|
-
echo "Snapshot is already synchronized with $BASE_BRANCH."
|
|
116
|
-
echo "Nothing to do."
|
|
117
|
-
|
|
118
|
-
if [ "$FORCE_FLAG" != "true" ]; then
|
|
119
|
-
exit 0
|
|
120
|
-
fi
|
|
121
|
-
fi
|
|
122
|
-
else
|
|
123
|
-
echo " WARNING: Could not compare snapshots"
|
|
124
|
-
DIFF_LINES="unknown"
|
|
125
|
-
fi
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
### 6. Confirmation
|
|
129
|
-
|
|
130
|
-
**If NOT auto mode:**
|
|
131
|
-
|
|
132
|
-
```yaml
|
|
133
|
-
AskUserQuestion:
|
|
134
|
-
header: "Rebase"
|
|
135
|
-
question: "Rebase snapshot from {BASE_BRANCH}?
|
|
136
|
-
|
|
137
|
-
This will:
|
|
138
|
-
1. Backup all migration files
|
|
139
|
-
2. Reset ModelSnapshot to {BASE_BRANCH}
|
|
140
|
-
3. Delete {BRANCH_MIG_COUNT} branch migrations
|
|
141
|
-
4. Create ONE consolidated migration
|
|
142
|
-
|
|
143
|
-
Snapshot difference: {DIFF_LINES} lines"
|
|
144
|
-
options:
|
|
145
|
-
- label: "Yes, rebase"
|
|
146
|
-
description: "Proceed with rebase-snapshot"
|
|
147
|
-
- label: "Cancel"
|
|
148
|
-
description: "Do nothing"
|
|
149
|
-
multiSelect: false
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
---
|
|
153
|
-
|
|
154
|
-
## STATE OUTPUT:
|
|
155
|
-
|
|
156
|
-
| Variable | Description |
|
|
157
|
-
|----------|-------------|
|
|
158
|
-
| `{branch_migrations}` | Array of migrations to remove |
|
|
159
|
-
| `{branch_mig_count}` | Number of branch migrations |
|
|
160
|
-
| `{diff_lines}` | Snapshot divergence (lines) |
|
|
161
|
-
|
|
162
|
-
---
|
|
163
|
-
|
|
164
|
-
## SUCCESS CRITERIA:
|
|
165
|
-
|
|
166
|
-
- Branch type is feature/release/hotfix
|
|
167
|
-
- Working directory clean
|
|
168
|
-
- Branch migrations identified
|
|
169
|
-
- User confirmed
|
|
170
|
-
|
|
171
|
-
## NEXT STEP:
|
|
172
|
-
|
|
173
|
-
→ `step-01-backup.md`
|