@atlashub/smartstack-cli 4.37.0 → 4.38.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/mcp-entry.mjs +3 -17
- package/dist/mcp-entry.mjs.map +1 -1
- package/package.json +1 -1
- package/templates/agents/efcore/migration.md +4 -42
- package/templates/agents/efcore/rebase-snapshot.md +4 -38
- package/templates/agents/efcore/squash.md +6 -41
- package/templates/project/claude-md/infrastructure.CLAUDE.md.template +1 -1
- package/templates/skills/application/references/migration-checklist-troubleshooting.md +3 -15
- package/templates/skills/application/steps/step-06-migration.md +0 -4
- package/templates/skills/application/templates-seed.md +33 -27
- package/templates/skills/dev-start/SKILL.md +142 -20
- package/templates/skills/efcore/references/sql-objects-injection.md +12 -54
- package/templates/skills/gitflow/references/commit-migration-validation.md +4 -0
|
@@ -1,61 +1,19 @@
|
|
|
1
|
-
# SQL Objects
|
|
1
|
+
# SQL Objects Management
|
|
2
2
|
|
|
3
|
-
EF Core does NOT generate DDL for
|
|
4
|
-
SQL source scripts are in `Persistence/SqlObjects/` (Embedded Resources).
|
|
5
|
-
After a migration/squash/rebase, they must be re-injected into the consolidated migration.
|
|
3
|
+
EF Core does NOT generate DDL for TVFs, views, and stored procedures.
|
|
4
|
+
SQL source scripts are in `Persistence/SqlObjects/` (Embedded Resources, `CREATE OR ALTER`).
|
|
6
5
|
|
|
7
|
-
##
|
|
6
|
+
## Automatic Startup Deployment
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
# Check if SqlObjects folder exists with .sql files
|
|
11
|
-
SQL_OBJECTS_DIR="$INFRA_PROJECT_DIR/Persistence/SqlObjects"
|
|
12
|
-
SQL_FILES=$(find "$SQL_OBJECTS_DIR" -name "*.sql" 2>/dev/null | wc -l)
|
|
8
|
+
SQL objects are applied **automatically at application startup** via `SqlObjectHelper.ApplyAllAsync(dbContext)` in `SmartStackExtensions.InitializeSmartStackAsync()`, right after `MigrateAsync()`.
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
echo ""
|
|
16
|
-
echo "Found $SQL_FILES SQL object(s) in SqlObjects/"
|
|
17
|
-
echo "Injecting SqlObjectHelper.ApplyAll(migrationBuilder) into migration..."
|
|
10
|
+
**No migration injection is needed.** To add or modify a SQL object:
|
|
18
11
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
fi
|
|
24
|
-
if ! echo "$MIGRATION_FILE" | grep -qE '\.cs$'; then
|
|
25
|
-
echo "ERROR: Invalid migration file path (not .cs): $MIGRATION_FILE"
|
|
26
|
-
exit 1
|
|
27
|
-
fi
|
|
12
|
+
1. Create or edit the `.sql` file in `Persistence/SqlObjects/{Functions,Views,StoredProcedures}/`
|
|
13
|
+
2. Ensure it uses `CREATE OR ALTER` (idempotent)
|
|
14
|
+
3. Ensure `.csproj` has `<EmbeddedResource Include="Persistence\SqlObjects\**\*.sql" />`
|
|
15
|
+
4. Restart the application — the SQL object is deployed automatically
|
|
28
16
|
|
|
29
|
-
|
|
30
|
-
if ! grep -q "using SmartStack.Infrastructure.Persistence.SqlObjects;" "$MIGRATION_FILE"; then
|
|
31
|
-
sed -i '1s/^/using SmartStack.Infrastructure.Persistence.SqlObjects;\n/' "$MIGRATION_FILE"
|
|
32
|
-
fi
|
|
17
|
+
## Legacy Note
|
|
33
18
|
|
|
34
|
-
|
|
35
|
-
sed -i '/protected override void Up/,/^ }/ {
|
|
36
|
-
/^ }/ i\
|
|
37
|
-
\ // Apply SQL objects (TVF, Views, SP) from embedded resources\
|
|
38
|
-
\ SqlObjectHelper.ApplyAll(migrationBuilder);
|
|
39
|
-
}' "$MIGRATION_FILE"
|
|
40
|
-
|
|
41
|
-
# Verify injection succeeded (fallback to manual step if sed pattern didn't match)
|
|
42
|
-
if ! grep -q "SqlObjectHelper.ApplyAll" "$MIGRATION_FILE"; then
|
|
43
|
-
echo "WARNING: Automatic injection failed (indentation pattern may differ)"
|
|
44
|
-
echo ""
|
|
45
|
-
echo "MANUAL STEP REQUIRED: Add these lines inside the Up() method before the closing brace:"
|
|
46
|
-
echo ' using SmartStack.Infrastructure.Persistence.SqlObjects;'
|
|
47
|
-
echo ' ...'
|
|
48
|
-
echo ' SqlObjectHelper.ApplyAll(migrationBuilder);'
|
|
49
|
-
echo ""
|
|
50
|
-
echo "File: $MIGRATION_FILE"
|
|
51
|
-
else
|
|
52
|
-
echo " SqlObjectHelper.ApplyAll(migrationBuilder) injected"
|
|
53
|
-
fi
|
|
54
|
-
find "$SQL_OBJECTS_DIR" -name "*.sql" -exec basename {} \; | while read f; do
|
|
55
|
-
echo " - $f"
|
|
56
|
-
done
|
|
57
|
-
else
|
|
58
|
-
echo ""
|
|
59
|
-
echo "No SQL objects found in SqlObjects/ - skipping injection"
|
|
60
|
-
fi
|
|
61
|
-
```
|
|
19
|
+
Older migrations may still contain `SqlObjectHelper.ApplyAll(migrationBuilder)` calls. These are harmless (idempotent) but no longer required. New migrations should NOT include this call.
|
|
@@ -47,3 +47,7 @@ if [ "$HAS_MIGRATIONS" = "true" ]; then
|
|
|
47
47
|
}
|
|
48
48
|
fi
|
|
49
49
|
```
|
|
50
|
+
|
|
51
|
+
## SQL Objects Note
|
|
52
|
+
|
|
53
|
+
SQL objects (TVFs, views, stored procedures) are applied **automatically at application startup** via `SqlObjectHelper.ApplyAllAsync()`. No injection into migrations is needed. Migrations no longer need to contain `SqlObjectHelper.ApplyAll(migrationBuilder)` calls.
|