sqliteTable()
Defines a SQLite table with columns and optional constraints.Signature
Parameters
string
required
The name of the table in the database
object | function
required
Object mapping column names to column definitions, or a function that receives column builders
function
Optional function to define indexes, foreign keys, checks, and composite primary keys
Basic Usage
Table with Indexes
Table with Foreign Keys
Table with Composite Primary Key
Table with Check Constraints
Table with Unique Constraints
sqliteTableCreator()
Creates a custom table creator function with a name transformation function.Use Case: Table Prefixes
Use Case: Schema Prefixes
Table Configuration Helpers
index()
Creates an index on one or more columns.uniqueIndex()
Creates a unique index.primaryKey()
Defines a composite primary key.foreignKey()
Defines a foreign key relationship.Column[]
required
The columns in the current table that reference the foreign table
Column[]
required
The columns in the foreign table being referenced
string
Optional custom name for the foreign key constraint
check()
Defines a check constraint.unique()
Defines a unique constraint on one or more columns.Foreign Key Actions
When defining foreign keys, you can specify actions for updates and deletes:UpdateDeleteAction
Action when the referenced row is deleted
UpdateDeleteAction
Action when the referenced row is updated
'cascade'- Propagate the change to dependent rows'restrict'- Prevent the change if dependent rows exist'no action'- No action (SQLite default)'set null'- Set the foreign key column to NULL'set default'- Set the foreign key column to its default value