[DMS-938] Emit Project Schemas + Resource/Extension Tables + Abstract Identity Tables/Views#840
[DMS-938] Emit Project Schemas + Resource/Extension Tables + Abstract Identity Tables/Views#840simpat-adam wants to merge 28 commits intomainfrom
Conversation
There was a problem hiding this comment.
This is the big guy. Emit schemas, tables, indexes, views, triggers
There was a problem hiding this comment.
Not sure why these didn't get alphabetized until my branch. Same goes for all the files under Old.Postgresql
| /// nullable optional parameters. | ||
| /// </summary> | ||
| public enum DbTriggerKind | ||
| public abstract record TriggerKindParameters |
There was a problem hiding this comment.
Yay Discriminated union
There was a problem hiding this comment.
Lots of changes in this file. Summary of DeriveTriggerInventoryPass changes:
The major change here is correcting the IdentityPropagationFallback trigger placement to align with the design specification in reference/design/backend-redesign/epics/01-relational-model/07-index-and-trigger-inventory.md (lines 97-102):
"For eligible targets (abstract targets and concrete targets with allowIdentityUpdates=true), inventory emits one propagation trigger per referenced table (TriggerTable) with deterministic referrer fan-out actions."
Before (incorrect): Triggers were placed on the referrer table (e.g., TR_Enrollment_Propagation_School on Enrollment). This resulted in N triggers for N referrers pointing to the same target.
After (per design): A single trigger is placed on the referenced table (e.g., TR_School_PropagateIdentity on School) that fans out to update all referrer tables. This is more efficient and matches where identity changes originate.
Other changes:
- Replaced DbTriggerKind enum with TriggerKindParameters discriminated union to carry trigger-specific metadata (identity elements, column mappings, referrer updates) needed for DDL emission
- Added BuildReverseReferenceIndex to collect all referrers per target resource
- Enhanced ReferentialIdentityMaintenance and AbstractIdentityMaintenance triggers with UUIDv5 computation metadata (resource key IDs, identity element mappings, superclass alias info)
The test changes reflect the corrected trigger placement — assertions now expect triggers on the referenced table with ReferrerUpdates containing the fan-out targets.
…Identity Tables/Views - Emit schemas, tables, indexes, views, and triggers from derived relational model - Support abstract identity tables and union views - Implement all four trigger kinds: DocumentStamping, ReferentialIdentityMaintenance, AbstractIdentityMaintenance, and IdentityPropagationFallback - Add FK-support index emission - Add comprehensive golden file tests for DDL emission - Use ISqlDialect.RenderColumnType for type rendering - Apply dialect-specific identifier shortening Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ctIdentity triggers
…IdentityElementMappings
… computed-column safety
…L computed-column safety
…ffers from canonical
…rentialIdentity and AbstractIdentity triggers
…f guessing from JSON paths
…oject duplicate name check
9457288 to
320f02c
Compare
Summary
This PR implements the DDL emission infrastructure for the relational model backend redesign, enabling generation of database schemas for PostgreSQL and MSSQL dialects.
Key Features
edfi,sample,tpdm)TriggerKindParameters) for trigger variants:DocumentStamping- timestamp maintenance triggersReferentialIdentityMaintenance- referential identity sync triggersAbstractIdentityMaintenance- abstract identity table maintenanceIdentityPropagationFallback- fallback propagation triggersTechnical Changes
RelationalModelDdlEmitter- Main DDL emitter usingSqlWriterfor phased emissionDeriveTriggerInventoryPass- Derives trigger inventory with proper reverse reference trackingKeyUnificationPass- Implements column aliasing and identity propagationDerivedModelSetManifestEmitter- JSON manifest emission for derived model setPageDocumentIdSqlCompiler- SQL compiler for paginated document queriesTesting
Test plan
dotnet testin backend projects🤖 Generated with Claude Code