Repository navigation
feat: Add Multi-Tenant Catalog With Closure Table And Money - #9
Merged
Merged
Conversation
Declare a catalog schema that uses composite (tenantId, id) identity, a closure table for category trees, integer minor-unit money, and soft delete with a partial unique index on live SKUs.
A null parent is a new forest root and cannot cycle. Binding parentId ?? id matched the depth-0 self-edge and always threw.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The catalog is the hard schema this repo was aiming at. Tenants, categories, a closure table, and products with integer money and a nullable deletedAt. Lookups go by (tenantId, id), so a category from another tenant is missing instead of attached. Reparent refuses a cycle by checking whether the new parent already sits in the subtree.
The DSL still emits single-column foreign keys, so same-tenant writes live in Catalog. Live SKU uniqueness is a partial unique index, which the DSL also cannot say, so applyCatalogSchema runs that CREATE UNIQUE INDEX after migrate. Money is minor units plus ISO 4217. allocateMoney uses largest remainder so a 100-unit split into three parts is 34, 33, 33.
Closes #8