Overview

schema() compiles the tables into one catalog. Each option is a page.

schema()Anatomy
export default schema({
tables: [notes],required
…,sections
});

Tables

The list, in the order you write it. A reference names a table in this list, earlier or later. table() only stores the columns. Names and the catalog hash are fixed here. Calling schema() twice on the same tables returns equal catalog bytes.

Pages

Each other field is a page in this group.

The declaration

Each option is a page. Tables come first, because every other option refers to them.

OrderPageYou use it for
1TablesThe list schema() compiles.
2CasingThe SQL name of a camelCase field.
3CodecsThe TypeScript value. The SQL type stays.
4Row typesEmitted types, or types kept in the checker.
5Id defaultWhat a bare t.id() means.
6Minimum PostgresThe oldest major. Omitted means 15.
7TraitsColumns added to every table.
8TenancyTenant keys on every table.
9ValidationWhether rules run.
10ExtensionsExtensions the catalog names.
11FunctionsRoutines the catalog stores.
12TriggersTriggers that call those functions.
13ViewsViews and materialized views.
14Several catalogsexternal(), a snapshot, and one history per namespace.

On this page