import { ColumnDefinition } from './ColumnDefinition'; import { SchemaCommand } from './Command'; import { ForeignKeyDefinition } from './ForeignKeyDefinition'; import { IndexDefinition } from './IndexDefinition'; /** What a Blueprint is compiled into: a brand-new table or an alteration. */ export type BlueprintMode = 'create' | 'alter'; /** * Collects the columns and structural commands that describe a table, exactly * like Laravel's Blueprint. Grammars turn a Blueprint into the concrete DDL for * a given engine, so the same Blueprint runs unchanged on PostgreSQL, MySQL and * SQLite. * * Schema.create('users', (table) => { * table.increments('id') * table.string('email', 150).unique() * table.boolean('active').default(true) * table.timestamp('createdAt').useCurrent() * }) */ export declare class Blueprint { private readonly tableName; private readonly _mode; private _ifNotExists; private readonly _columns; private readonly _commands; constructor(tableName: string, _mode?: BlueprintMode, _ifNotExists?: boolean); getTable(): string; getMode(): BlueprintMode; getColumns(): ColumnDefinition[]; getCommands(): SchemaCommand[]; /** * Removes and returns the `dropColumn` commands from this blueprint. Used by * the SchemaBuilder on engines whose `dropColumnStrategy()` is 'rebuild' * (SQLite): the remaining commands are compiled normally and the dropped * column names drive a table rebuild instead of an ALTER … DROP COLUMN. */ removeDropColumnCommands(): string[]; /** Whether the blueprint carries any column definitions or structural commands. */ isEmpty(): boolean; wantsIfNotExists(): boolean; /** Emits CREATE TABLE IF NOT EXISTS. */ ifNotExists(): this; private addColumn; /** Auto-incrementing UNSIGNED INTEGER primary key. */ increments(name: string): ColumnDefinition; /** Auto-incrementing UNSIGNED BIGINT primary key. */ bigIncrements(name: string): ColumnDefinition; /** Alias of bigIncrements — the conventional primary key. */ id(name?: string): ColumnDefinition; char(name: string, length?: number): ColumnDefinition; string(name: string, length?: number): ColumnDefinition; text(name: string): ColumnDefinition; mediumText(name: string): ColumnDefinition; longText(name: string): ColumnDefinition; integer(name: string): ColumnDefinition; unsignedInteger(name: string): ColumnDefinition; bigInteger(name: string): ColumnDefinition; unsignedBigInteger(name: string): ColumnDefinition; smallInteger(name: string): ColumnDefinition; tinyInteger(name: string): ColumnDefinition; boolean(name: string): ColumnDefinition; float(name: string): ColumnDefinition; double(name: string): ColumnDefinition; decimal(name: string, total?: number, places?: number): ColumnDefinition; date(name: string): ColumnDefinition; dateTime(name: string): ColumnDefinition; time(name: string): ColumnDefinition; timestamp(name: string): ColumnDefinition; json(name: string): ColumnDefinition; jsonb(name: string): ColumnDefinition; uuid(name: string): ColumnDefinition; /** * Array of integers: native INT[] on PostgreSQL, JSON-encoded TEXT on SQLite, * JSON on MySQL. Lets the same migration keep list columns engine-agnostic. */ integerArray(name: string): ColumnDefinition; /** Adds nullable createdAt / updatedAt TIMESTAMP columns. */ timestamps(): void; /** * UNSIGNED BIGINT column meant to hold a foreign key (Laravel's foreignId). * Call `.constrained(table)` on the result to add the matching constraint. */ foreignId(name: string): ColumnDefinition; private guessForeignTable; private addCommand; primary(columns: string | string[], name?: string): IndexDefinition; unique(columns: string | string[], name?: string): IndexDefinition; index(columns: string | string[], name?: string): IndexDefinition; foreign(columns: string | string[], name?: string): ForeignKeyDefinition; dropColumn(columns: string | string[]): void; renameColumn(from: string, to: string): void; dropIndex(index: string): void; dropUnique(index: string): void; dropPrimary(index?: string): void; dropForeign(index: string): void; }