iagate-querykit
Version:
QueryKit: lightweight TypeScript query toolkit with models, views, triggers, events, scheduler and adapters (better-sqlite3).
74 lines • 2.27 kB
TypeScript
import type { MigrationContext, MigrationStep } from './migration-manager';
export declare enum ColumnType {
Int = "Int",
BigInt = "BigInt",
Float = "Float",
Double = "Double",
Decimal = "Decimal",
String = "String",
Text = "Text",
Varchar = "Varchar",
Date = "Date",
Time = "Time",
DateTime = "DateTime",
Timestamp = "Timestamp",
TimestampTz = "TimestampTz",
Boolean = "Boolean",
Json = "Json",
Uuid = "Uuid",
Binary = "Binary"
}
export declare enum ColumnDefault {
CurrentTimestamp = "CurrentTimestamp",
UuidV4 = "UuidV4"
}
export type ForeignKeyOptions = {
table: string;
column?: string;
onDelete?: 'CASCADE' | 'RESTRICT' | 'SET NULL' | 'NO ACTION';
onUpdate?: 'CASCADE' | 'RESTRICT' | 'SET NULL' | 'NO ACTION';
};
export type ColumnOptions = {
primaryKey?: boolean;
notNull?: boolean;
unique?: boolean;
default?: string | number | boolean | null | ColumnDefault;
length?: number;
precision?: number;
scale?: number;
autoIncrement?: boolean | {
mode?: 'always' | 'default' | 'serial';
start?: number;
increment?: number;
};
references?: ForeignKeyOptions;
};
export declare class MigrationBuilder {
private steps;
private typeFor;
private defaultFor;
private colDef;
createTable(name: string, columns: Record<string, {
type: ColumnType;
} & ColumnOptions>): this;
dropTable(name: string): this;
addColumn(table: string, column: string, def: {
type: ColumnType;
} & ColumnOptions): this;
dropColumn(table: string, column: string): this;
renameColumn(table: string, from: string, to: string): this;
createIndex(table: string, columns: string[], opts?: {
unique?: boolean;
name?: string;
}): this;
dropIndex(name: string): this;
createJoinTable(name: string, leftTable: string, rightTable: string, opts?: {
cascade?: boolean;
leftKeyName?: string;
rightKeyName?: string;
}): this;
raw(sql: string): this;
apply(ctx: MigrationContext): Promise<void>;
}
export declare function migration(dsl: (b: MigrationBuilder) => void): MigrationStep;
//# sourceMappingURL=migration-dsl.d.ts.map