Skip to main content
Module

x/cotton/mod.ts>Schema

SQL Database Toolkit for Deno
Latest
class Schema
import { Schema } from "https://deno.land/x/cotton@v0.7.5/mod.ts";

Database schema migration helper

Constructors

new
Schema(adapter: Adapter)

Methods

addColumn(tableName: string, column: ColumnBuilder)

Create a new column

addIndex(index: string)

Create an index

alterColumn(column: string, newColumn: string)

Update a column's datatype

createTable(
name: string,
fn: (builder: TableBuilder) => void,
options?: CreateTableOptions,
)

Create a table

dropColumn(tableName: string, columnName: string)

Remove a column

dropTable(tableName: string, options?: { ifExists?: boolean; }): Promise<void>

Drop a single table

dropTable(tableNames: string[], options?: { ifExists?: boolean; }): Promise<void>

Drop multiple tables

hasColumn(tableName: string, columnName: string): Promise<boolean>

Check if a column exists in a table

hasTable(tableName: string): Promise<boolean>

Check if a table exists in the database

query(query: string)

Execute SQL query

removeIndex(index: string)

Remove an index

renameColumn(
tableName: string,
columnName: string,
newColumnName: string,
)

Rename a column

renameTable(name: string, newName: string)

Rename a table