Docs / Reference
Claim contract: TypeORM models
The environment assumptions and claim contract of the TypeORM model extractor (ADR
0064) as recorded when it was designed (task T018g6, internal record).
docs/extract/schema-typeorm.md and the code table in internal/extract/models/typeorm
must equal them (TestTypeORMContract).
Environment (assumptions, part of the contract)
- TO-V1 Pins. The
typeormversion in the package's lockfile (pins: {"typeorm": "<v>", "typescript": "<v>"}) created the database and thetypescriptversion compiled the entities. - TO-V2 Schema deployed. The database was created by
synchronizefor the reached entities or by migrations that match them (TypeORM migration classes are not read, TO-U1). seerr: production runs its migrations (synchronize: false,migrationsRunin dev Postgres); the 55 SQLite and 20 Postgres migrations give the synchronize catalog except generated constraint names. - TO-V3 Decorator metadata. The entities are compiled by
tsc(the pinnedtypescript) withexperimentalDecoratorsandemitDecoratorMetadataas the nearest tsconfig chain states them, andstrictNullChecksas that chain states it (strictimplies it). Without both decorator flags proventrue, every design-type inferred type is unknown; withexperimentalDecoratorsnottrue, the group is D (TypeORM 0.3 needs legacy decorators). - TO-V4 Dialect. The database is of the DataSource's literal
type; when the options are selected at run time among several literal option objects (seerr: five objects,sqliteandpostgres), the dialect is one of that set (open point O1). - TO-V5 Modules load. Entity module side effects do not change the
metadata beyond what is read (no
getMetadataArgsStorage()mutation, no decorator applied conditionally or in a loop), and when anentitiesglob is read, the process runs with the package directory as working directory (cwd-relative globs) and a compiled output mirrors the source tree (__dirnameglobs). NestJS (TO-K4): an import declaration loads its module (TypeScript elides an import used only as a type; such a module is still counted), and a module loaded only by a dynamicimport()is not seen (it leaves a list incomplete only when no root reaches theforFeaturefile). - TO-V6 Mapped dialects. MySQL, MariaDB and MSSQL facts follow
TypeORM 0.3.31's driver source (
driver/mysql/MysqlDriver.js,driver/sqlserver/SqlServerDriver.js) as cited (neveroracle). - TO-V7 Schemas exist. An entity
schemaon Postgres names a schema that exists:synchronizedoes not create it. - TO-V9 Verified versions (TA3). The rules were verified at TypeORM 0.3.22, 0.3.31, 1.1.2 and 1.1.3 (oracle) and TypeScript 5.4.5, 5.8.3, 5.9.3 and 6.0.3; a pin of another 0.3.x or 1.x version is read with the per-major rules and this assumption shown (open point O14).
- TO-V10 Naming-strategy package (TA3, only with TO-K6). The
typeorm-naming-strategiesversion in the lockfile is 4.x (verified at 4.1.0, the latest; its peer range names TypeORM 0.2/0.3, and under 1.x it is installed past that range and behaves the same). - TO-V8 Config namespaces load (TA2, only with TO-K5). A
registerAsnamespace read throughconfigService.get('<token>')is in theConfigModuleload list at run time (nest-admin:load: [...Object.values(config)],src/app.module.ts:39).
Claim contract
Finalised from the inventory and the oracle (the investigation). Row kinds: K
scope and naming; E entity forms; C columns; X indexes and
constraints; R relations; P provable failures and refusals;
U unread tool folders; V assumptions; D the single default
branch. Every form the corpus uses has exactly one row (counts per row:
the T018g6 inventory (internal record)); forms only the fixture uses come from
the same oracle runs (scratch probes). The contract test keeps
docs/extract/schema-typeorm.md, the Go table and the code 1:1 (plan,
shared piece 4). 30 rows: 29 rows plus D (21 from the investigation; TO-K3, K4,
K5, E3, C6 and X4 added for Revision 1 and the NestJS
corpus, TO-K5 accepted by Revision 2 O9; TO-K6, K7 and K8 added pending open points O15 and O16; TA3 also wrote the
TypeORM 1.x rules into the rows, marked 1.x, and corrected TO-K2
and TO-R1 for both majors); TO-P1 and TO-P2 only
refuse, TO-R3 claims nothing (inverse sides are counted), TO-U1 only
marks, TO-V has no branch. Citations are to the npm package
[email protected] (files under its root) and [email protected]
(lib/typescript.js); 1.x citations are to [email protected] (equal
to 1.1.2 in every cited function), written 0.3.31 line / 1.1.3 line
where both are given (full table: "TypeORM 1.x comparison" in the TA3
section).
Dialect rule (developer decision 2026-11-13):
- postgres:
verification: "oracle":synchronizeon a scratch Postgres 17, catalog read. - sqlite: the same oracle on a scratch SQLite file through
sqlite3(sqlite_master,pragma table_xinfo,index_list,index_info,foreign_key_list; constraint names from theCREATE TABLEtext). - mysql, mariadb, mssql:
verification: "mapped", TO-V6, fromdriver/mysql/MysqlDriver.js(normalizeType:578-640,normalizeDefault:642,getColumnLength:684-700,createFullType:707, date defaultsCURRENT_TIMESTAMP(6):178-182) anddriver/sqlserver/SqlServerDriver.js(normalizeType:481-520,normalizeDefault:523, lengths :558-561,createFullType:567, date defaultsgetdate():125-127). MariaDB'suuidtype depends on the server version detected at connect (uuidColumnTypeSuported,MysqlDriver.js:594): unknown. - Several dialects (TO-V4, seerr): provider-independent facts are
claimed with the verification of the weakest dialect of the set;
dialect-dependent facts (type, default text, enum representation,
generation) are claimed per dialect through the kit's per-dialect
fields (Revision 1 O1, ADR 0065), each with its own
verification. - SQLite family (Revision 1 O8):
better-sqlite3issqlite(the shareddriver/sqlite-abstract/AbstractSqliteDriver.js; TA2 ran the oracle through both drivers with identical catalogs), so its compared forms areoracle;sqljs,capacitor,cordova,expo,nativescript,react-nativefollow the same rules asmapped. - TypeORM 1.x (TA3): the same labels; SQLite means
better-sqlite3and the other SQLite-family types (1.x has nosqlitetype, A32), and its oracle runs throughbetter-sqlite3(open point O20). - MySQL types (TA2): the mapped list for
mysqlandmariadbis stated in TO-C2; a type outside it is unknown. - Unknown in every dialect: generated constraint and index names, collations, comments, sequence options, column order.
Provider-independent facts (table and column names, column set, nullability, primary-key columns, unique column sets, index column sets and uniqueness, foreign-key columns, target table and columns, actions) were equal on both oracle dialects for every seerr and probe table.
| id | form | claim | refusal / unknown | assumptions |
|---|---|---|---|---|
| TO-K1 | scope (Discovery above): package dependency on typeorm 0.3.x or 1.x, lockfile pins, the module-level new DataSource(<options>) with the candidate rule, ormconfig when no DataSource, the entities option (class references; the glob subset), the dialect set, tsconfig decorator flags |
the group (set: models/typeorm/<file>), pins, dialect (one type) or the dialect set, the reached entity classes, table_list complete when every entities element is read |
non-literal or unequal scope options, an unread entities element, an unreached @Entity class: may_be_incomplete / not claimed (markers); namingStrategy other than TO-K6, another major, other dialects: D; 1.x: a candidate type: "sqlite" is TO-P1 (7) (the sqlite3 driver is removed, driver/DriverFactory.js:43 / :39-72); ormconfig files are D (1.x reads them nowhere: globals.js keeps only getMetadataArgsStorage); globs as in 0.3 (tinyglobby instead of glob, util/DirectoryExportedClassesLoader.js:32 / :39; same files on the oracle's glob run); both majors: join(...)/resolve(...) imported by name from path count as path.join/path.resolve (aqualink, A40) |
TO-V1, TO-V3, TO-V4, TO-V5, TO-V9 |
| TO-K2 | naming: table name: @Entity literal name, else snakeCase(className) (naming-strategy/DefaultNamingStrategy.js:26-28, util/StringUtils.js:29-36), prefixed by entityPrefix (every table, explicit names and junction tables too); schema: the entity's schema, else the options' schema (postgres); column name: the literal name option, else the property name (DefaultNamingStrategy.js:37-42); join column: the @JoinColumn name, else camelCase(relationProperty + "_" + referencedColumnProperty) (:114-116, metadata-builder/RelationJoinColumnBuilder.js:137: the referenced column's property name); junction: @JoinTable name, else snakeCase(ownerTable + "_" + property + "_" + targetTable) of the unprefixed names (:117-123), columns camelCase(table + "_" + referencedColumnDatabaseName) (:127-129: joinTableColumnName(table, property, databaseName) prefers the database name; TA3 corrected the investigation's text, which named the property), _1/_2 appended when both are equal (:124-126, metadata-builder/JunctionEntityMetadataBuilder.js:272-275); Postgres enum type: enumName, else <table>_<lower(column)>_enum in the table's schema (driver/postgres/PostgresQueryRunner.js:2597-2612); 1.x: the same rules (DefaultNamingStrategy.js:13-15, :19-24, :96-115, PostgresQueryRunner.js:2961 at 1.1.3; oracle: equal names on every probe, seerr and nest-admin table); with TO-K6 the SnakeNamingStrategy names replace these |
the names | a non-literal name, prefix or schema: that name unknown (the table or column unknown when its name is); an empty-string @Entity/@JoinTable name (0.3 falls back, 1.x keeps ""): unknown; database option on an entity: D |
TO-V1, TO-V9 |
| TO-K3 | NestJS root options (Revision 1 O2; @nestjs/typeorm at the lockfile pin, cited at 11.0.0 under dist/): TypeOrmModule.forRoot(<options>) with <options> read as TO-K1 reads DataSource options; TypeOrmModule.forRootAsync({useFactory, inject?, imports?, name?, dataSourceFactory?}) whose useFactory is a non-async arrow or function expression whose every return is an object literal (Revision 3 addendum 2: its block may hold try statements, body, catch and finally kept as statements, read only when none of them returns, so every path reaches the same later return; nest-admin src/shared/database/database.module.ts:22-38); dataSourceFactory absent or (o) => new DataSource(o) (optionally .initialize()d; the default, typeorm-core.module.js:160-165), async or not, or the async block async (o) => { const x = await new DataSource(o).initialize(); return x } (nest-admin :41-44; Revision 3 addendum 2); one group per data source name (name literal, default default, common/typeorm.utils.js:58-66), group root the file of the call |
the group, pins, dialect from the literal type, the scope options as TO-K1 |
a spread or a non-literal value among the options: the keys it can supply are unknown, and since a spread can carry namingStrategy, entityPrefix or type, every name and dialect fact of the group is unknown (marker naming the spread) unless TO-K5 resolves it; useClass/useExisting (createTypeOrmOptions(), typeorm-core.module.js:143-149), forRoot() without options, any other dataSourceFactory: the group's options unknown (marker; open point O9); @nestjs/typeorm 12.x (1.x apps): forRoot(options, name) with a literal second argument names the group (dist/typeorm.module.js:25-26 at 12.0.3) |
TO-V1, TO-V3, TO-V4, TO-V5 |
| TO-K4 | NestJS entity reach: TypeOrmModule.forFeature([<identifiers>], <data source name literal>?) in package files other than tests (*.spec.*, *.test.*, *.e2e-spec.*, files under test/ or __tests__/), each identifier resolving to an @Entity class; autoLoadEntities: true (literal) in the TO-K3 options |
reached entities: the options' entities (TO-K1 element rules) when it is an array, plus every forFeature entity registered for that data source name in a file the root's application loads through static imports (from the root module file and from every entry file of the package, a non-test file no other package file imports, whose imports reach the root file: import declarations and export ... from clauses, resolved by the module resolver, recursively; package imports are not followed) (typeorm.module.js:23-25, entities-metadata.storage.js:5-28, typeorm-core.module.js:166-183); a non-array entities option is replaced by the forFeature list (:176-179; in 12.x an object-map entities keeps its values and the forFeature list is appended, typeorm-core.module.js:182-186 at 12.0.3; a string entities with autoLoadEntities: may_be_incomplete on every version); without autoLoadEntities, forFeature reaches no table (repositories only) |
a non-identifier element or a non-literal name: may_be_incomplete; an @Entity class registered only from test files: not claimed; a forFeature call in a file the root's application does not reach: not counted for that root, and the root's list may_be_incomplete when its import graph is open (a relative specifier that resolves to no file, a require call) or no root module of the package reaches that file (a dynamic import may load it) (Revision 4 A4) |
TO-V5 |
| TO-K5 | (Revision 2: O9 accepted) configService.get('<token>') / get<T>('<token>') (ConfigService from @nestjs/config) spread into or returned as TO-K3 options, when the package has exactly one registerAs(<the same token: a string literal or a module-level const bound to one>, () => <options TO-K1 can read>) |
the registered options, read as if written in place | no or several matching registerAs, a non-literal token, a factory with statements other than one return: TO-K3's unknown |
TO-V8 |
| TO-K6 | (Revision 2 O11, TA3) namingStrategy: new SnakeNamingStrategy() in the scope options (TO-K1, TO-K3, TO-K5 readers), the class imported by name from typeorm-naming-strategies (4.x in the lockfile), no arguments |
every TO-K2 name through the strategy (snake-naming.strategy.js at 4.1.0): table the literal name, else snakeCase(className) (:7-9); column the literal name verbatim, else snakeCase(property) (:10-13); join column the @JoinColumn name, else snakeCase(relationProperty + "_" + referencedColumnProperty) (:17-19); junction table snakeCase(ownerTable + "_" + property + "_" + targetTable) of the unprefixed names (:20-26); junction columns snakeCase(table + "_" + referencedColumnDatabaseName) (:27-29), _1/_2 and entityPrefix inherited; Postgres enum types from the snake column name; generated names as TO-X4 over the snake names; snakeCase is TypeORM's own (util/StringUtils.js:29-36 / :32-39) |
another namingStrategy value (a subclass, a project re-export, an instance from a variable, a call with arguments, another package): D (decision 2026-11-13 as amended by Revision 2 O11) |
TO-V1, TO-V9, TO-V10 |
| TO-K7 | (pending open point O15, TA3) new DataSource(X) or TypeOrmModule.forRoot(X) where X is an identifier imported (default or named) from a package module in which it is bound to a module-level const whose initializer is an object literal (a type annotation allowed) |
the options, read as if written in place (Maintainerr src/app/config/typeOrmConfig.ts:4, used at src/app/app.module.ts:49) |
a re-export chain the resolver cannot follow, a let, a mutated object, a non-literal initializer: TO-K1's unknown options (marker) |
TO-V5 |
| TO-K8 | (pending open point O16, TA3) a spread ...Y in the options object literal where Y resolves to a module-level const whose initializer is an object literal, a conditional of object literals, or an object literal with &&-guarded spreads of object literals, recursively, and none of those literals has a scope key (type, entities, entityPrefix, schema, namingStrategy, name, autoLoadEntities) or a computed key |
the spread adds no scope option; the other keys read as TO-K1 (aqualink ormconfig.ts:15-34: {url} or {host, port, database, username, password}) |
any other spread argument, a scope key or computed key inside it: TO-K1's unknown options (marker) | TO-V5 |
| TO-E1 | @Entity(), @Entity("name"), @Entity({name, schema, synchronize}) (from typeorm) on a module-level class (plain, export, export default, or class X with export default X) reached by TO-K1; members with no table fact: @RelationId, @RelationCount, @VirtualColumn, entity listeners (@AfterLoad, @BeforeInsert, ... @AfterRecover), undecorated members, methods, constructors; option orderBy has no table fact |
a model (table); synchronize: false: the table and its columns claimed with verification: "mapped" under the shown assumption "TypeORM does not create this table; this is the shape the code expects" (Revision 1 O4) |
other entity options (database, withoutRowid, engine, expression): the table's facts they could change unknown (partial); @Entity from another module than typeorm: D; 1.x: @RelationCount no longer exists (index.js:55 at 0.3.31, absent at 1.1.3): an entity module using it fails to load, TO-P1 (8) |
TO-V2, TO-V5 |
| TO-E2 | class inheritance: extends an identifier resolving to a class of a reached module (abstract or not, decorated or not), recursively, and extends BaseEntity (from typeorm: no columns) |
inherited columns, relations, indexes and uniques, base-class members first | a base that does not resolve (a mixin call, an external package class other than BaseEntity): the column set unknown (partial) |
TO-V5 |
| TO-E3 | member decorators from packages that never touch TypeORM metadata: @nestjs/swagger, class-transformer, class-validator (TA2: at nest-admin's lockfile versions 11.1.1, 0.5.1, 0.14.1 no file of these packages mentions typeorm, and none depends on it) |
no table fact: the member is read as if the decorator were absent | any other package: TO-P2 | TO-V5 |
| TO-C1 | column decorators from typeorm: @Column(type?, options?), @PrimaryColumn(type?, options?), @PrimaryGeneratedColumn(strategy?, options?) with strategy "increment" (default), "uuid", "identity" (postgres), @Column({primary: true}), @Column({generated}) |
the column; primary-key columns in member order (composite allowed); generation: postgres increment a nextval sequence default (serial), identity GENERATED BY DEFAULT, uuid default uuid_generate_v4(); sqlite increment on the single integer primary key INTEGER PRIMARY KEY AUTOINCREMENT, uuid no default |
an entity without a primary column: TO-P1; strategy rowid or a non-literal strategy: generation unknown; @ObjectIdColumn: D |
TO-V2 |
| TO-C2 | column type: the explicit literal type (positional first argument or type option) from the per-dialect list the oracle ran (the investigation: int, int4, integer, varchar, character varying, text, bigint, int8, smallint, int2, boolean, bool, decimal, numeric, float, double precision, float8, real, float4, date, time, timestamp, timestamptz, uuid, json, jsonb, character, char, simple-array, simple-json on postgres; int, integer, varchar, text, bigint, smallint, boolean, decimal, numeric, float, double precision, real, date, time, datetime, character, simple-array, simple-json on sqlite), rendered by the driver (driver/postgres/PostgresDriver.js:732-789, driver/sqlite-abstract/AbstractSqliteDriver.js:433-461); else the design type of the annotation (Column.js:25-33) when it is exactly string, number, boolean or Date (TypeScript's serializer, typescript.js:95540-95683): String varchar / character varying, Number integer, Boolean boolean, Date datetime / timestamp without time zone; length (literal) as (n); precision/scale (literals) as (p,s), a precision alone as (p) on sqlite and (p,0) with scale 0 on postgres, mysql and mariadb (their catalogs report NUMERIC(p) and DECIMAL(p) so; TOB5 oracle); array: true (postgres) as []; simple-array and simple-json are text; mysql/mariadb (mapped, TA2, MysqlDriver.normalizeType, getColumnLength, createFullType): int, integer (int), tinyint, smallint, bigint, varchar (varchar(255) without length), text, datetime, date, boolean/bool (tinyint), decimal, float, double, json; design types String varchar(255), Number int, Boolean tinyint, Date datetime |
type per dialect | a non-literal type or length (a project call such as seerr's resolveDbType('datetime'), 10 sites), a type outside the list, unsigned, zerofill, width, charset, collation, spatialFeatureType, srid, hstoreType, generatedType/asExpression: type unknown; any other annotation (union with null/undefined, type references to aliases, enums, classes, interfaces, Promise, arrays, missing annotation): type unknown, never inferred (A1, A13); a type the dialect does not support: TO-P1 |
TO-V3, TO-V6 |
| TO-C3 | special columns: @CreateDateColumn, @UpdateDateColumn, @DeleteDateColumn, @VersionColumn |
type without an explicit one: postgres timestamp without time zone (PostgresDriver.js:170-176), sqlite datetime (AbstractSqliteDriver.js:125-131), version integer; create/update default now() (postgres) / datetime('now') (sqlite) unless the column states a default; delete-date columns nullable (metadata/ColumnMetadata.js:269); create/update/version not null |
an explicit non-literal type: as TO-C2; precision on date columns: type unknown (mapped dialects excepted, cited); an explicit falsy literal default (0, "", false) on a create or update date column: default unknown (0.3 replaces it with the driver default, metadata/ColumnMetadata.js:240-241; 1.x keeps it, :228, ??=; open point O19) |
TO-V2 |
| TO-C4 | column facts of literal options: nullable (default false: not null), default (string, number, boolean, null, a () => "<sql>" arrow with a literal body, a member of a TypeScript enum captured by S8 and resolved by the resolver), unique, name; keys with no table fact: select, insert, update, transformer, comment (not compared), cascade, eager, lazy, persistence |
nullability (primary keys not null); default per dialect and type family: postgres normalizeDefault (PostgresDriver.js:793-830), sqlite (AbstractSqliteDriver.js:465-483), mysql (MysqlDriver.js:642-670); a string '<value>' on a character, text (not MySQL's TEXT) or enum column only; on a boolean column a boolean string (true/false, t/f, yes/no, y/n, on/off, 1/0, any case) and a number 1/0 as postgres stores them (true/false) and on sqlite as written; a number as written on postgres integer, numeric and character columns (quoted on enum columns) and on sqlite, quoted (toFixed) on mysql number, boolean, character and enum columns; a boolean true/false on a postgres boolean column, 1/0 on sqlite and on mysql boolean and number columns; a function default as its text, except on postgres a text containing CURRENT_TIMESTAMP, CURRENT_DATE, CURRENT_TIME, LOCALTIMESTAMP or LOCALTIME, where exactly CURRENT_TIMESTAMP is now() and any other such text is unknown (PostgresDriver.js:1270-1304; 1.x rewrites only a whole keyword with an optional precision, :1455-1486 at 1.1.3, so the same claim holds and other texts stay unknown); unique: true a single-column unique constraint (Column.js:54-58); a default's verification is its dialect's only for a form the oracle fixture compares on that dialect (oracleDefaultForms), else mapped |
a non-literal value: that fact unknown; a string default on a date or time, uuid, number, json or other column (the database stores its own rendering) or on a column whose type is not known, a boolean on a postgres column that is not boolean, a number on a postgres date or time, uuid or other column, a number other than 1/0 or another string on a boolean column: unknown (Revision 4 A1, A2; the texts the database rejects are TO-P1 (10) to (12)); a string default containing ' (not escaped) or a fractional number default on an integer column on postgres: TO-P1 (both majors: PostgresDriver.js:806 / :931); an object default (json, jsonb) containing ': unknown (1.x doubles the quote, :937; 0.3 does not, :816) |
TO-V2 |
| TO-C5 | enum columns: type: "enum" (postgres, mysql, mariadb) or "simple-enum" with enum: an array literal of strings/numbers or an identifier resolving to an S8 enum (values: the non-numeric keys' values, metadata/ColumnMetadata.js:184), enumName literal |
postgres: an enum type (TO-K2 name) with the labels in order (numbers as strings); sqlite: varchar with a CHECK (col IN (...)) (labels claimed, constraint unnamed); mysql/mariadb ENUM(...) (mapped) |
enum non-literal or an unread enum: type and labels unknown; enum on sqlite: TO-P1 |
TO-V2 |
| TO-C6 | (Revision 1 O3) project wrapper decorators: a decorator imported from a package module whose declaration is a module-level function F(options) (or a const arrow) whose last statement is return Column(options) (or PrimaryColumn, CreateDateColumn, UpdateDateColumn, DeleteDateColumn from typeorm), all earlier statements only assigning options.type or options.default (seerr DbAwareColumn, server/utils/DbColumnHelper.ts:15, 15 sites) |
the column as the inner decorator with the call's literal options: name, nullability, unique and primary claimed; type and default unknown when the wrapper assigns them | any other body (renames, loops, conditionals over other keys), a wrapper from another package, a non-literal options argument: TO-P2 | TO-V2, TO-V5 |
| TO-X1 | @Index() on a property (a column or a @ManyToOne/@OneToOne owner: its join columns), @Index("name"), @Index({unique, where}), class @Index(["a", "b"], opts?), @Index("name", ["a", "b"], opts?) with property names (relations: their join columns) |
an index: columns in order, unique, partial (where present), explicit name; junction tables: one index per side |
function form @Index((e) => [...]), synchronize: false (TypeORM never creates the index; aqualink 2 sites), 1.x type (decorator/Index.js:44, metadata/IndexMetadata.js:49-52 at 1.1.3), spatial, fulltext, parser, sparse, background, expireAfterSeconds, a non-literal element: that index unknown (partial); predicate text and generated names: never claimed |
TO-V2 |
| TO-X2 | class @Unique(["a", "b"]), @Unique("name", ["a", "b"]) (relation properties: their join columns), column unique: true (TO-C4), the one-to-one owner's unique join columns (TO-R2) |
a unique constraint: columns, explicit name | non-literal fields: that constraint unknown; deferrable: D |
TO-V2 |
| TO-X3 | class @Check("<sql>"), @Check("name", "<sql>") |
a check constraint; explicit name claimed; the expression text as written (not compared: the database rewrites it) | non-literal: unknown; a property-level @Check (aqualink 1 site) and @Exclusion: D |
TO-V2 |
| TO-X4 | (Revision 1 O5) generated constraint and index names: PK_, UQ_, REL_, FK_, IDX_, CHK_ + sha1 of the table and sorted column names (naming-strategy/DefaultNamingStrategy.js:46-113) for constraints and indexes without an explicit name; the hash is per major: 0.3.x SHA-1 of encodeURIComponent(key) (util/RandomGenerator.js:17-43), 1.x standard SHA-1 of the key (util/StringUtils.js:98-99, DefaultNamingStrategy.js:124-126 at 1.1.3); they differ when the key holds a character encodeURIComponent escapes (a partial index where, a check expression) |
the name, under the shown assumption "schema made by synchronize" | the data source has a migrations option or a migrations folder is found (seerr, nest-admin): unknown |
TO-V2 |
| TO-R1 | @ManyToOne(() => T, inverse?, options?) with T a reached entity, optional @JoinColumn({name, referencedColumnName, foreignKeyConstraintName}) or @JoinColumn([{...}, ...]); lazy (Promise<T>) and eager alike |
join columns (TO-K2 names) referencing the target's primary columns or the named ones (RelationJoinColumnBuilder.js:103-118), each typed as the referenced column (integer for an increment key, uuid/varchar for a uuid key, length kept); nullable unless nullable: false or primary (metadata/RelationMetadata.js:173-174); a foreign key unless createForeignKeyConstraints: false (:178-179, RelationJoinColumnBuilder.js:62-67) with onDelete/onUpdate as written (upper case), else NO ACTION (metadata/ForeignKeyMetadata.js:32-33); explicit foreignKeyConstraintName claimed; a join column whose name equals the database name of an explicit column of the same entity reuses that column: its own nullability, default and uniqueness stay, its type becomes the referenced column's (RelationJoinColumnBuilder.js:141, :186-190 / :163, :205-209; Maintainerr 9, aqualink 12 sites); explicit composite @JoinColumn([...]) columns in array order (0.3.x) or 1.x in the target's primary-key order (:129-137 at 1.1.3); on a MySQL-only group, an index on the foreign key's columns named as the foreign key (mapped) when no declared index, unique constraint or the primary key leads with them (InnoDB creates it: MySQL reference manual, "FOREIGN KEY Constraints"; TypeORM names every constraint and reads an index named like a referential constraint as the foreign key's, driver/mysql/MysqlQueryRunner.js:1507-1520, :1881) |
an unresolved or string target, a referenced column that is unknown or not found: the join column and foreign key unknown (partial); an explicit same-named column the rules cannot read (TO-P2): the join column unknown; deferrable, orphanedRowAction (no table fact), primary (removed in 0.3): D; on MariaDB, or with MySQL and another dialect in the set, such a foreign key's index leaves the constraint set partial (its name on MariaDB, or its absence on the other dialects, is not read), as does a foreign key on primary key columns the primary key may not lead with |
TO-V2 |
| TO-R2 | @OneToOne(() => T, inverse?, options?) with @JoinColumn(...) (the owner side) |
as TO-R1, plus a unique constraint on the join columns unless they are all primary or no foreign key is created (RelationJoinColumnBuilder.js:81-95) |
as TO-R1 | TO-V2 |
| TO-R3 | inverse sides: @OneToMany(() => T, inverse, options?), @OneToOne without @JoinColumn, @ManyToMany without @JoinTable |
no table fact (counted; the owner side's row claims) | an inverse side whose owner is not read: nothing to claim | - |
| TO-R4 | @ManyToMany(() => T, inverse?, options?) with @JoinTable() or @JoinTable({name, joinColumn: {name, referencedColumnName}, inverseJoinColumn: {...}}) |
a junction table (TO-K2 names): one column per primary (or named referenced) column of each side, typed as referenced, not null, together the primary key; two foreign keys: the owner side's with the relation's onDelete/onUpdate, else CASCADE; the inverse side's with the inverse relation's onDelete/onUpdate when the owner names an inverse property (NO ACTION when that relation states none), else CASCADE (JunctionEntityMetadataBuilder.js:162-198); 1.x: the inverse relation's onDelete/onUpdate each, CASCADE when it states none (?? "CASCADE", :177-190 at 1.1.3), composite sides in primary-key order (:241, :273); one index per side |
joinColumns/inverseJoinColumns arrays, synchronize: false, schema/database on @JoinTable, an unresolved side: the junction unknown (marker) |
TO-V2 |
| TO-P1 | failures DataSource.initialize() or synchronize would hit, provable from the source: (1) an entity without a primary column (metadata-builder/EntityMetadataValidator.js:48); (2) an explicit type the dialect does not support, e.g. datetime on postgres, timestamp or char on sqlite (:89; the driver's supportedDataTypes, PostgresDriver.js:50-126, AbstractSqliteDriver.js:37-70); (3) a design type proven Object: @Column() without an explicit type on a property without an annotation (typescript.js:95541-95543), or with a union containing null/undefined and a non-null member when the tsconfig chain proves strictNullChecks (:95667-95677), or any/unknown/object-literal types, except on a column that merges with a join column (TO-R1: its type is replaced before validation; aqualink 3 sites); (4) a string default containing '; (5) a fractional number default on an integer column on postgres; (6) enum on sqlite; 1.x: (7) a candidate type: "sqlite" (MissingDriverError from the DataSource constructor, driver/DriverFactory.js:72), (8) an entity module using @RelationCount (TypeError at class evaluation), (9) an @Index with a non-empty string literal type option on any dialect but postgres (Unsupported index type from the IndexMetadata constructor, metadata/IndexMetadata.js:49-52 at 1.1.2 and 1.1.3: only PostgresDriver has supportedIndexTypes; Revision 3 addendum 3 OP1; on postgres the index stays a TO-X1 refusal); Revision 4: (10) postgres: a string default CURRENT_TIMESTAMP, CURRENT_DATE, CURRENT_TIME, LOCALTIMESTAMP or LOCALTIME (any case, an optional precision) on a date or time column (PG17: invalid input syntax for type timestamp); (11) postgres: a string default containing ( on a uuid column (PG17: invalid input syntax for type uuid); (12) mysql: a string default CURRENT_TIMESTAMP, CURRENT_TIMESTAMP(n) or NOW() on a date or time column (quoted, MysqlDriver.js:646-649: a string literal that is no date, ER_INVALID_DEFAULT; MySQL reference manual, "Data Type Default Values"; mapped); (13) a length on a type outside the driver's withLengthColumnTypes (postgres PostgresDriver.js:138-148, sqlite AbstractSqliteDriver.js:78-88, mysql and mariadb MysqlDriver.js:124-131): EntityMetadataValidator.js:89-92 (1.1.3 :92-94) "does not support length property" (int on every dialect, text on postgres and mysql); (14) postgres: a precision without a length on integer, smallint, bigint, text, boolean, uuid, date, double precision, real, json or jsonb (createFullType writes integer(5), PostgresDriver.js:850-864 / 1.1.3 :1011-1025; PG17: syntax error, or type modifier is not allowed) |
diagnostic schema_model_import_failure (row named); no claim for any table of the group on that dialect: validation runs for every entity before any DDL, and the schema build runs in one transaction that is rolled back (schema-builder/RdbmsSchemaBuilder.js:52-78) |
other failures: assumed absent (TO-V2) | TO-V2, TO-V3 |
| TO-P2 | project decorators and helpers not covered by TO-C6 or TO-E3: a decorator on an entity member not imported from typeorm or a TO-E3 package, a project call as an option value |
refused: the member's column (name, type and every fact) unknown and the table's column set partial, reason naming the wrapper; a helper value: that fact unknown |
always refused | - |
| TO-U1 | the migrations option's globs and directories |
unread_tools entry (found, not read yet) |
always unread | - |
| TO-V | assumptions TO-V1..TO-V7 attached to every record of the group | stated, never claimed as facts | - | - |
| D | anything else: TypeORM majors other than 0.3 and 1, EntitySchema, a custom namingStrategy other than TO-K6 (decision 2026-11-13, Revision 2 O11), 1.x-only deferrable on relations and exclusions, @TableInheritance/@ChildEntity, @ViewEntity/@ViewColumn, @Tree/@TreeChildren/@TreeParent/@TreeLevelColumn, embedded @Column(() => X), @ObjectIdColumn/mongodb, @Generated, @ForeignKey, @Exclusion, generated columns, dialects outside the five and the SQLite family, NestJS forms outside TO-K3-K5 (useClass/useExisting options, custom dataSourceFactory, forRoot() without options), metadata mutations, option objects not read |
no claim; marker diagnostic schema_model_unread with tool: "typeorm" and the form |
- | - |
Rows TO-R3, TO-U1 and TO-V exist so the inventory can count every form and the contract test can name them. The claim-side rows are TO-K1, K2, K3, K4, K5, K6, K7, K8, E1, E2, C1, C2, C3, C4, C5, C6, X1, X2, X3, X4, R1, R2, R4 (twenty-three; TO-E3 only removes a refusal and claims nothing itself; TO-K7 and TO-K8 only widen which options TO-K1 reads).
Report a problem with this pageSource: docs/contract/claims/typeorm-models.md