API reference › @evolu/common › local‑first/Schema
Database schema definition and validation.
Core
| Name | Description |
|---|---|
| SystemColumns | System columns that are implicitly defined by Evolu. |
| AnyStandardSchemaV1 | Any Standard Schema V1 declaration. |
| EvoluSchema | Defines the schema of an Evolu database. |
| TableSchema | A table schema: column names mapped to Standard Schema validators. |
| systemColumns | Names of SystemColumns. |
| SystemColumns | System columns that are implicitly defined by Evolu. |
| systemColumnsWithId | Names of SystemColumns together with id. |
Queries
| Name | Description |
|---|---|
| CreateQuery | Typed query factory returned by createQueryBuilder. |
| QuarantineOrigin | Whether a quarantined message was stamped by this database for a local mutation or received from sync. Persisted codes: names may change, but numbers must not be reassigned. |
| QuarantineReason | Why a message is stored in evolu_message_quarantine instead of being applied to its table. Persisted codes: names may change, but numbers must not be reassigned. |
| kysely | Kysely instance that only compiles queries to SQL. It never executes them; Evolu runs the compiled SQL itself. |
| QuarantineOrigin | Whether a quarantined message was stamped by this database for a local mutation or received from sync. Persisted codes: names may change, but numbers must not be reassigned. |
| QuarantineReason | Why a message is stored in evolu_message_quarantine instead of being applied to its table. Persisted codes: names may change, but numbers must not be reassigned. |
| createQueryBuilder | Creates a query builder from a EvoluSchema. |
Mutations
| Name | Description |
|---|---|
| MutationChange | Database change produced by a Mutation, attributed to the OwnerId that owns the row. |
| MutationOptions | Options accepted by every Mutation. |
| InsertValues | Insert values: id omitted (auto-generated), nullable columns optional, non-nullable columns required. |
| Mutation | Mutation function type. Accepts already-validated values — validation is the caller's responsibility using any Standard Schema library (Evolu Type, Zod, Valibot, ArkType, etc.). |
| MutationKind | Kind of a Mutation: insert, update, or upsert. |
| MutationValues | Derives the expected values type for a mutation from a table's column schemas and a MutationKind. |
| NullableColumnsToOptional | Makes columns whose output type includes null optional. |
| OptionalColumnKeys | Column names whose output type includes null. |
| RequiredColumnKeys | Column names whose output type excludes null. |
| UpdateValues | Update values: id required, all other columns optional. Includes isDeleted for soft deletes. |
| UpsertValues | Upsert values: id required, nullable columns optional, non-nullable columns required. Includes isDeleted for soft deletes. |
Validation
| Type Alias | Description |
|---|---|
| SchemaValidationError | Schema validation error that shows clear, readable messages |
| ValidateColumnTypes | Requires every column output type to be compatible with SQLite. |
| ValidateIdColumnType | Requires every id column output type to extend Id. |
| ValidateNoSystemColumns | Rejects tables that define system column names. |
| ValidateSchema | Validates an EvoluSchema at compile time, returning the first error found as a readable string literal type. This approach provides much clearer and more actionable TypeScript errors than the default, which are often hard to read. |
| ValidateSchemaHasId | Requires an id column in every table. |
SQLite
| Name | Description |
|---|---|
| SqliteSchemaDep | Dependency wrapper for SqliteSchema. |
| IndexesConfig | Defines SQLite indexes with Kysely's index builder. |
| ensureSqliteSchema | Creates missing tables, columns, and indexes, and drops indexes that the new schema no longer defines. |
| evoluSchemaToSqliteSchema | Derives SqliteSchema tables and indexes from an EvoluSchema. |
| getEvoluSqliteSchema | Reads the current application SqliteSchema, excluding Evolu's internal indexes. |
Testing
| Name | Description |
|---|---|
| TestEvoluSchema | Schema type of testEvoluSchema. |
| TestProjectId | Project ID Type for testEvoluSchema. |
| TestTodoId | Todo ID Type for testEvoluSchema. |
| testEvoluSchema | Todo and project schema for tests and examples. A todo can belong to a project or have no project. Use an explicit schema when teaching schema definition. |
| testLocalOnlyEvoluSchema | App-owner registry schema with local tables for tests and examples. |
| testProjectId | Deterministic TestProjectId for tests and examples. |
| TestProjectId | Project ID Type for testEvoluSchema. |
| testTodoId | Deterministic TestTodoId for tests and examples. |
| TestTodoId | Todo ID Type for testEvoluSchema. |