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.The name of the table to create
A builder for creating table definitions
Examples
dropTable
Drop a table.The name of the table to drop
A builder for dropping tables
Examples
createIndex
Create a new index.The name of the index to create
A builder for creating indexes
Examples
dropIndex
Drop an index.The name of the index to drop
A builder for dropping indexes
Examples
createSchema
Create a new schema.The name of the schema to create
A builder for creating schemas
Examples
dropSchema
Drop a schema.The name of the schema to drop
A builder for dropping schemas
Examples
alterTable
Alter a table.The name of the table to alter
A builder for altering tables
Examples
createView
Create a new view.The name of the view to create
A builder for creating views
Examples
dropView
Drop a view.The name of the view to drop
A builder for dropping views
Examples
refreshMaterializedView
Refresh a materialized view.The name of the materialized view to refresh
A builder for refreshing materialized views
Examples
createType
Create a new type. Only some dialects like PostgreSQL have user-defined types.The name of the type to create
A builder for creating types
Examples
dropType
Drop a type. Only some dialects like PostgreSQL have user-defined types.The name of the type to drop
A builder for dropping types
Examples
withPlugin
Returns a copy of this schema module with the given plugin installed.The plugin to install
A new SchemaModule instance with the plugin installed
withoutPlugins
Returns a copy of this schema module without any plugins.A new SchemaModule instance without plugins
withSchema
Sets the schema to be used for all subsequent operations.The schema name to use
A new SchemaModule instance that uses the specified schema