MigrationSchema
Summary
DDL-focused operations mixed into the migration db object.
Signature
interface MigrationSchema {
addCheck(
table: TableInput,
expression: string,
options: NamedConstraintOptions,
): Promise<void>;
addForeignKey(
table: TableInput,
columns: KeyColumns,
refTable: TableInput,
refColumns: KeyColumns,
options: ForeignKeyOptions,
): Promise<void>;
alterTable(
table: TableInput,
migrate: (table: AlterTableBuilder) => void,
options: AlterTableOptions,
): Promise<void>;
createIndex(
table: TableInput,
columns: IndexColumns,
options: CreateIndexOptions,
): Promise<void>;
createTable<table extends AnyTable>(
table: table,
options: CreateTableOptions,
): Promise<void>;
dropCheck(table: TableInput, name: string): Promise<void>;
dropForeignKey(table: TableInput, name: string): Promise<void>;
dropIndex(
table: TableInput,
name: string,
options: { ifExists?: boolean },
): Promise<void>;
dropTable(table: TableInput, options: DropTableOptions): Promise<void>;
hasColumn(table: TableInput, column: string): Promise<boolean>;
hasTable(table: TableInput): Promise<boolean>;
plan(sql: string | SqlStatement): Promise<void>;
renameIndex(table: TableInput, from: string, to: string): Promise<void>;
renameTable(from: TableInput, to: string): Promise<void>;
}
Methods
addCheck(table: TableInput, expression: string, options: NamedConstraintOptions): Promise
Adds a check constraint in the migration schema.
table
expression
options
addForeignKey(table: TableInput, columns: KeyColumns, refTable: TableInput, refColumns: KeyColumns, options: ForeignKeyOptions): Promise
Adds a foreign key in the migration schema.
table
columns
refTable
refColumns
options
alterTable(table: TableInput, migrate: (table: AlterTableBuilder) => void, options: AlterTableOptions): Promise
Alters an existing table in the migration schema.
table
migrate
options
createIndex(table: TableInput, columns: IndexColumns, options: CreateIndexOptions): Promise
Creates an index in the migration schema.