RelationalSchemaBuilder
Class: RelationalSchemaBuilder
Defined in: packages/sql-schema/src/builder.ts:110
Builds the RelationalSchemaPlan of the models of a store from their compiled metadata
Pure: no database, no logging (warnings are returned in the plan), same input same plan. Rules:
- one table per model hierarchy (single-table inheritance,
__typediscriminator), unlesstablesnames one - one typed column per stored field (
Schemas.Stored),NOT NULLwhen required ModelParent/ModelLink: a column (one per key part for a composite key) with a foreign key,ON DELETE CASCADEfor a parent,NO ACTIONfor a link (until the delete policies of #798)ModelLinksSimpleArray/ModelLinksArray/ModelLinksMap: a junction table<table>_<attribute>ModelRelated/ModelsMapped: no storage- foreign keys only between models of the plan: a reference to another model gets a column and an index
Constructors
Constructor
new RelationalSchemaBuilder(
options?):RelationalSchemaBuilder
Defined in: packages/sql-schema/src/builder.ts:116
Parameters
options?
the builder options
Returns
RelationalSchemaBuilder
Methods
build()
build(
models):RelationalSchemaPlan
Defined in: packages/sql-schema/src/builder.ts:131
Build the plan
Parameters
models
Iterable<SchemaModelMetadata>
the models handled by the store, subclasses included
Returns
the plan
Throws
SchemaBuildError when the models cannot share their tables (primary keys or column types differ)