API reference@evolu/common › local‑first/Schema

Database schema definition and validation.

Core

NameDescription
SystemColumnsSystem columns that are implicitly defined by Evolu.
AnyStandardSchemaV1Any Standard Schema V1 declaration.
EvoluSchemaDefines the schema of an Evolu database.
TableSchemaA table schema: column names mapped to Standard Schema validators.
systemColumnsNames of SystemColumns.
SystemColumnsSystem columns that are implicitly defined by Evolu.
systemColumnsWithIdNames of SystemColumns together with id.

Queries

NameDescription
CreateQueryTyped query factory returned by createQueryBuilder.
QuarantineOriginWhether 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.
QuarantineReasonWhy 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.
kyselyKysely instance that only compiles queries to SQL. It never executes them; Evolu runs the compiled SQL itself.
QuarantineOriginWhether 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.
QuarantineReasonWhy 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.
createQueryBuilderCreates a query builder from a EvoluSchema.

Mutations

NameDescription
MutationChangeDatabase change produced by a Mutation, attributed to the OwnerId that owns the row.
MutationOptionsOptions accepted by every Mutation.
InsertValuesInsert values: id omitted (auto-generated), nullable columns optional, non-nullable columns required.
MutationMutation function type. Accepts already-validated values — validation is the caller's responsibility using any Standard Schema library (Evolu Type, Zod, Valibot, ArkType, etc.).
MutationKindKind of a Mutation: insert, update, or upsert.
MutationValuesDerives the expected values type for a mutation from a table's column schemas and a MutationKind.
NullableColumnsToOptionalMakes columns whose output type includes null optional.
OptionalColumnKeysColumn names whose output type includes null.
RequiredColumnKeysColumn names whose output type excludes null.
UpdateValuesUpdate values: id required, all other columns optional. Includes isDeleted for soft deletes.
UpsertValuesUpsert values: id required, nullable columns optional, non-nullable columns required. Includes isDeleted for soft deletes.

Validation

Type AliasDescription
SchemaValidationErrorSchema validation error that shows clear, readable messages
ValidateColumnTypesRequires every column output type to be compatible with SQLite.
ValidateIdColumnTypeRequires every id column output type to extend Id.
ValidateNoSystemColumnsRejects tables that define system column names.
ValidateSchemaValidates 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.
ValidateSchemaHasIdRequires an id column in every table.

SQLite

NameDescription
SqliteSchemaDepDependency wrapper for SqliteSchema.
IndexesConfigDefines SQLite indexes with Kysely's index builder.
ensureSqliteSchemaCreates missing tables, columns, and indexes, and drops indexes that the new schema no longer defines.
evoluSchemaToSqliteSchemaDerives SqliteSchema tables and indexes from an EvoluSchema.
getEvoluSqliteSchemaReads the current application SqliteSchema, excluding Evolu's internal indexes.

Testing

NameDescription
TestEvoluSchemaSchema type of testEvoluSchema.
TestProjectIdProject ID Type for testEvoluSchema.
TestTodoIdTodo ID Type for testEvoluSchema.
testEvoluSchemaTodo 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.
testLocalOnlyEvoluSchemaApp-owner registry schema with local tables for tests and examples.
testProjectIdDeterministic TestProjectId for tests and examples.
TestProjectIdProject ID Type for testEvoluSchema.
testTodoIdDeterministic TestTodoId for tests and examples.
TestTodoIdTodo ID Type for testEvoluSchema.