@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.
Files changed (46) hide show
  1. package/dist/index.js +28 -32
  2. package/dist/index.js.map +1 -1
  3. package/dist/mcp-entry.mjs +29 -10
  4. package/dist/mcp-entry.mjs.map +1 -1
  5. package/package.json +1 -1
  6. package/templates/skills/apex/references/checks/seed-checks.sh +1 -1
  7. package/templates/skills/apex/references/core-seed-data.md +39 -21
  8. package/templates/skills/application/references/application-roles-template.md +14 -8
  9. package/templates/skills/application/references/provider-template.md +32 -20
  10. package/templates/skills/application/templates-frontend.md +294 -2
  11. package/templates/skills/application/templates-seed.md +23 -11
  12. package/templates/skills/audit-route/SKILL.md +107 -0
  13. package/templates/skills/audit-route/references/routing-pattern.md +129 -0
  14. package/templates/skills/audit-route/steps/step-00-init.md +128 -0
  15. package/templates/skills/audit-route/steps/step-01-inventory.md +157 -0
  16. package/templates/skills/audit-route/steps/step-02-conformity.md +193 -0
  17. package/templates/skills/audit-route/steps/step-03-report.md +201 -0
  18. package/templates/skills/dev-start/SKILL.md +12 -2
  19. package/templates/skills/efcore/SKILL.md +219 -67
  20. package/templates/agents/efcore/conflicts.md +0 -114
  21. package/templates/agents/efcore/db-deploy.md +0 -86
  22. package/templates/agents/efcore/db-reset.md +0 -98
  23. package/templates/agents/efcore/db-seed.md +0 -73
  24. package/templates/agents/efcore/db-status.md +0 -97
  25. package/templates/agents/efcore/scan.md +0 -124
  26. package/templates/skills/efcore/references/both-contexts.md +0 -32
  27. package/templates/skills/efcore/references/destructive-operations.md +0 -38
  28. package/templates/skills/efcore/steps/db/step-deploy.md +0 -217
  29. package/templates/skills/efcore/steps/db/step-reset.md +0 -186
  30. package/templates/skills/efcore/steps/db/step-seed.md +0 -166
  31. package/templates/skills/efcore/steps/db/step-status.md +0 -173
  32. package/templates/skills/efcore/steps/migration/step-00-init.md +0 -102
  33. package/templates/skills/efcore/steps/migration/step-01-check.md +0 -164
  34. package/templates/skills/efcore/steps/migration/step-02-create.md +0 -160
  35. package/templates/skills/efcore/steps/migration/step-03-validate.md +0 -168
  36. package/templates/skills/efcore/steps/rebase-snapshot/step-00-init.md +0 -173
  37. package/templates/skills/efcore/steps/rebase-snapshot/step-01-backup.md +0 -100
  38. package/templates/skills/efcore/steps/rebase-snapshot/step-02-fetch.md +0 -115
  39. package/templates/skills/efcore/steps/rebase-snapshot/step-03-create.md +0 -112
  40. package/templates/skills/efcore/steps/rebase-snapshot/step-04-validate.md +0 -157
  41. package/templates/skills/efcore/steps/shared/step-00-init.md +0 -131
  42. package/templates/skills/efcore/steps/squash/step-00-init.md +0 -141
  43. package/templates/skills/efcore/steps/squash/step-01-backup.md +0 -120
  44. package/templates/skills/efcore/steps/squash/step-02-fetch.md +0 -168
  45. package/templates/skills/efcore/steps/squash/step-03-create.md +0 -184
  46. package/templates/skills/efcore/steps/squash/step-04-validate.md +0 -174
@@ -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`
@@ -1,100 +0,0 @@
1
- ---
2
- name: step-01-backup
3
- description: Create backup of migration files
4
- next_step: step-02-fetch.md
5
- ---
6
-
7
- # Step 1: Backup
8
-
9
- ## YOUR TASK:
10
-
11
- Create a complete backup before modifying migration files.
12
-
13
- **Previous step:** `step-00-init.md`
14
-
15
- ---
16
-
17
- ## EXECUTION SEQUENCE:
18
-
19
- ### 1. Create Backup Directory
20
-
21
- ```bash
22
- TIMESTAMP=$(date +%Y%m%d_%H%M%S)
23
- BACKUP_DIR=".claude/gitflow/backup/migrations/rebase_${TIMESTAMP}"
24
-
25
- mkdir -p "$BACKUP_DIR"
26
- echo "Backup directory: $BACKUP_DIR"
27
- ```
28
-
29
- ### 2. Backup All Migration Files
30
-
31
- ```bash
32
- cp "$MIGRATIONS_DIR"/*.cs "$BACKUP_DIR/" 2>/dev/null || {
33
- echo "ERROR: No migration files to backup"
34
- exit 1
35
- }
36
-
37
- BACKUP_COUNT=$(ls -1 "$BACKUP_DIR"/*.cs 2>/dev/null | wc -l)
38
- echo "Backed up: $BACKUP_COUNT files"
39
- ```
40
-
41
- ### 3. Create Manifest
42
-
43
- ```bash
44
- cat > "$BACKUP_DIR/MANIFEST.md" << EOF
45
- # Rebase-Snapshot Backup Manifest
46
-
47
- **Created:** $(date -Iseconds)
48
- **Branch:** $CURRENT_BRANCH
49
- **Parent:** $BASE_BRANCH
50
- **DbContext:** $DBCONTEXT
51
-
52
- ## Branch Migrations (to be replaced)
53
-
54
- $(for mig in "${BRANCH_MIGRATIONS[@]}"; do echo "- $mig"; done)
55
-
56
- ## Restore Command
57
-
58
- \`\`\`bash
59
- cp "$BACKUP_DIR"/*.cs "$MIGRATIONS_DIR/"
60
- \`\`\`
61
- EOF
62
- ```
63
-
64
- ### 4. Verify Backup
65
-
66
- ```bash
67
- echo ""
68
- echo "Backup complete:"
69
- echo " Directory: $BACKUP_DIR"
70
- echo " Files: $BACKUP_COUNT"
71
- ```
72
-
73
- ---
74
-
75
- ## STATE OUTPUT:
76
-
77
- | Variable | Description |
78
- |----------|-------------|
79
- | `{backup_dir}` | Backup directory path |
80
- | `{backup_count}` | Number of files backed up |
81
-
82
- ---
83
-
84
- ## RECOVERY:
85
-
86
- ```bash
87
- cp "{BACKUP_DIR}"/*.cs "{MIGRATIONS_DIR}/"
88
- ```
89
-
90
- ---
91
-
92
- ## SUCCESS CRITERIA:
93
-
94
- - Backup directory created
95
- - All files copied
96
- - Manifest created
97
-
98
- ## NEXT STEP:
99
-
100
- → `step-02-fetch.md`
@@ -1,115 +0,0 @@
1
- ---
2
- name: step-02-fetch
3
- description: Reset snapshot to parent and delete branch migrations
4
- next_step: step-03-create.md
5
- ---
6
-
7
- # Step 2: Fetch Parent Snapshot
8
-
9
- ## YOUR TASK:
10
-
11
- Reset the ModelSnapshot to the parent branch state and remove branch-specific migrations.
12
-
13
- **Previous step:** `step-01-backup.md`
14
-
15
- ---
16
-
17
- ## EXECUTION SEQUENCE:
18
-
19
- ### 1. Fetch Latest Parent
20
-
21
- ```bash
22
- echo "Fetching origin/$BASE_BRANCH..."
23
- git fetch origin "$BASE_BRANCH" --quiet
24
- ```
25
-
26
- ### 2. Reset ModelSnapshot
27
-
28
- ```bash
29
- echo ""
30
- echo "Resetting ModelSnapshot from origin/$BASE_BRANCH..."
31
-
32
- SNAPSHOT_FILE="$MIGRATIONS_DIR/${DBCONTEXT}ModelSnapshot.cs"
33
-
34
- git checkout "origin/$BASE_BRANCH" -- "$SNAPSHOT_FILE" 2>/dev/null
35
-
36
- if [ $? -eq 0 ]; then
37
- echo " Snapshot reset to origin/$BASE_BRANCH"
38
- else
39
- echo " WARNING: Could not fetch snapshot from origin/$BASE_BRANCH"
40
- echo " Using local snapshot (may cause issues)"
41
- fi
42
- ```
43
-
44
- ### 3. Delete Branch Migrations
45
-
46
- ```bash
47
- echo ""
48
- echo "Removing branch-specific migrations..."
49
-
50
- for mig in "${BRANCH_MIGRATIONS[@]}"; do
51
- mig_name="${mig%.cs}"
52
-
53
- rm -f "$MIGRATIONS_DIR/${mig_name}.cs"
54
- rm -f "$MIGRATIONS_DIR/${mig_name}.Designer.cs"
55
-
56
- echo " Removed: $mig_name"
57
- done
58
-
59
- echo ""
60
- echo "Removed: ${#BRANCH_MIGRATIONS[@]} migration(s)"
61
- ```
62
-
63
- ### 4. Verify State
64
-
65
- ```bash
66
- echo ""
67
- echo "Current migrations after reset:"
68
-
69
- REMAINING=$(find "$MIGRATIONS_DIR" -name "*.cs" 2>/dev/null | grep -v "Designer\|Snapshot" | wc -l)
70
-
71
- echo " Remaining: $REMAINING (from $BASE_BRANCH)"
72
- ```
73
-
74
- ---
75
-
76
- ## EXPECTED STATE:
77
-
78
- ```
79
- After step-02-fetch:
80
- ├── {parent_migration_1}.cs ← From parent (unchanged)
81
- ├── {parent_migration_1}.Designer.cs
82
- ├── ...
83
- └── {DbContext}ModelSnapshot.cs ← Reset to parent state
84
-
85
- Branch migrations: DELETED
86
- ```
87
-
88
- ---
89
-
90
- ## STATE OUTPUT:
91
-
92
- | Variable | Description |
93
- |----------|-------------|
94
- | `{snapshot_reset}` | true if reset successful |
95
- | `{remaining_migrations}` | Count after deletion |
96
-
97
- ---
98
-
99
- ## ERROR HANDLING:
100
-
101
- If snapshot fetch fails:
102
- - Continue with local snapshot
103
- - Migration may contain more changes than expected
104
- - Warn user
105
-
106
- ---
107
-
108
- ## SUCCESS CRITERIA:
109
-
110
- - Snapshot reset to parent
111
- - Branch migrations removed
112
-
113
- ## NEXT STEP:
114
-
115
- → `step-03-create.md`