SchemaModule class provides methods for building and managing database schema. It allows you to create, alter, and drop tables, indexes, schemas, views, and types.
Overview
The schema module is accessed through theschema property of the Kysely instance:
Methods
createTable
Create a new table.string
required
The name of the table to create
CreateTableBuilder<TB, never>
A builder for creating table definitions
Examples
dropTable
Drop a table.string
required
The name of the table to drop
DropTableBuilder
A builder for dropping tables
Examples
createIndex
Create a new index.string
required
The name of the index to create
CreateIndexBuilder
A builder for creating indexes
Examples
dropIndex
Drop an index.string
required
The name of the index to drop
DropIndexBuilder
A builder for dropping indexes
Examples
createSchema
Create a new schema.string
required
The name of the schema to create
CreateSchemaBuilder
A builder for creating schemas
Examples
dropSchema
Drop a schema.string
required
The name of the schema to drop
DropSchemaBuilder
A builder for dropping schemas
Examples
alterTable
Alter a table.string
required
The name of the table to alter
AlterTableBuilder
A builder for altering tables
Examples
createView
Create a new view.string
required
The name of the view to create
CreateViewBuilder
A builder for creating views
Examples
dropView
Drop a view.string
required
The name of the view to drop
DropViewBuilder
A builder for dropping views
Examples
refreshMaterializedView
Refresh a materialized view.string
required
The name of the materialized view to refresh
RefreshMaterializedViewBuilder
A builder for refreshing materialized views
Examples
createType
Create a new type. Only some dialects like PostgreSQL have user-defined types.string
required
The name of the type to create
CreateTypeBuilder
A builder for creating types
Examples
dropType
Drop a type. Only some dialects like PostgreSQL have user-defined types.string
required
The name of the type to drop
DropTypeBuilder
A builder for dropping types
Examples
withPlugin
Returns a copy of this schema module with the given plugin installed.KyselyPlugin
required
The plugin to install
SchemaModule
A new SchemaModule instance with the plugin installed
withoutPlugins
Returns a copy of this schema module without any plugins.SchemaModule
A new SchemaModule instance without plugins
withSchema
Sets the schema to be used for all subsequent operations.string
required
The schema name to use
SchemaModule
A new SchemaModule instance that uses the specified schema