54 lines
1.9 KiB
TypeScript
54 lines
1.9 KiB
TypeScript
import { AlterColumnNode } from '../operation-node/alter-column-node.js';
|
|
import type { OperationNodeSource } from '../operation-node/operation-node-source.js';
|
|
import { type DataTypeExpression } from '../parser/data-type-parser.js';
|
|
import { type DefaultValueExpression } from '../parser/default-value-parser.js';
|
|
export declare class AlterColumnBuilder {
|
|
#private;
|
|
constructor(column: string);
|
|
setDataType(dataType: DataTypeExpression): AlteredColumnBuilder;
|
|
setDefault(value: DefaultValueExpression): AlteredColumnBuilder;
|
|
dropDefault(): AlteredColumnBuilder;
|
|
setNotNull(): AlteredColumnBuilder;
|
|
dropNotNull(): AlteredColumnBuilder;
|
|
/**
|
|
* Simply calls the provided function passing `this` as the only argument. `$call` returns
|
|
* what the provided function returns.
|
|
*/
|
|
$call<T>(func: (qb: this) => T): T;
|
|
}
|
|
/**
|
|
* Allows us to force consumers to do exactly one alteration to a column.
|
|
*
|
|
* One cannot do no alterations:
|
|
*
|
|
* ```ts
|
|
* await db.schema
|
|
* .alterTable('person')
|
|
* // .execute() // Property 'execute' does not exist on type 'AlteredColumnBuilder'.
|
|
* ```
|
|
*
|
|
* ```ts
|
|
* await db.schema
|
|
* .alterTable('person')
|
|
* // .alterColumn('age', (ac) => ac) // Type 'AlterColumnBuilder' is not assignable to type 'AlteredColumnBuilder'.
|
|
* // .execute()
|
|
* ```
|
|
*
|
|
* One cannot do multiple alterations:
|
|
*
|
|
* ```ts
|
|
* await db.schema
|
|
* .alterTable('person')
|
|
* // .alterColumn('age', (ac) => ac.dropNotNull().setNotNull()) // Property 'setNotNull' does not exist on type 'AlteredColumnBuilder'.
|
|
* // .execute()
|
|
* ```
|
|
*
|
|
* Which would now throw a compilation error, instead of a runtime error.
|
|
*/
|
|
export declare class AlteredColumnBuilder implements OperationNodeSource {
|
|
#private;
|
|
constructor(alterColumnNode: AlterColumnNode);
|
|
toOperationNode(): AlterColumnNode;
|
|
}
|
|
export type AlterColumnBuilderCallback = (builder: AlterColumnBuilder) => AlteredColumnBuilder;
|