import { Jiti } from "jiti"; import { ClientBase, ClientConfig, QueryArrayConfig, QueryArrayResult, QueryConfig, QueryResult } from "pg"; //#region src/logger.d.ts type LogFn = (msg: string) => void; type Logger = { debug?: LogFn; info: LogFn; warn: LogFn; error: LogFn; }; //#endregion //#region src/db.d.ts interface DB { query(queryConfig: QueryArrayConfig, values?: any[]): Promise; query(queryConfig: QueryConfig): Promise; query(queryTextOrConfig: string | QueryConfig, values?: any[]): Promise; select(queryConfig: QueryArrayConfig, values?: any[]): Promise; select(queryConfig: QueryConfig): Promise; select(queryTextOrConfig: string | QueryConfig, values?: any[]): Promise; } interface DBConnection extends DB { createConnection(): Promise; column(columnName: string, queryConfig: QueryArrayConfig, values?: any[]): Promise; column(columnName: string, queryConfig: QueryConfig): Promise; column(columnName: string, queryTextOrConfig: string | QueryConfig, values?: any[]): Promise; connected: () => boolean; addBeforeCloseListener: (listener: any) => number; close(): Promise; } //#endregion //#region src/utils/escapeValue.d.ts declare function escapeValue(val: Value): string | number; //#endregion //#region src/operations/functions/shared.d.ts interface FunctionParamType { mode?: 'IN' | 'OUT' | 'INOUT' | 'VARIADIC'; name?: string; type: string; default?: Value; } type FunctionParam = string | FunctionParamType; interface FunctionOptions { returns?: string; language: string; replace?: boolean; window?: boolean; behavior?: 'IMMUTABLE' | 'STABLE' | 'VOLATILE'; security?: 'INVOKER' | 'DEFINER'; onNull?: boolean; parallel?: 'UNSAFE' | 'RESTRICTED' | 'SAFE'; set?: Array<{ configurationParameter: string; value: LiteralUnion<'FROM CURRENT'>; }>; } //#endregion //#region src/operations/functions/dropFunction.d.ts type DropFunctionOptions = DropOptions; type DropFunction = (functionName: Name, functionParams: FunctionParam[], dropOptions?: DropFunctionOptions) => string; //#endregion //#region src/operations/functions/createFunction.d.ts type CreateFunctionOptions = FunctionOptions & DropOptions; type CreateFunctionFn = (functionName: Name, functionParams: FunctionParam[], functionOptions: CreateFunctionOptions & DropFunctionOptions, definition: Value) => string; type CreateFunction = Reversible; //#endregion //#region src/operations/functions/renameFunction.d.ts type RenameFunctionFn = (oldFunctionName: Name, functionParams: FunctionParam[], newFunctionName: Name) => string; type RenameFunction = Reversible; //#endregion //#region src/sqlMigration.d.ts interface MigrationBuilderActions { up?: MigrationAction | false; down?: MigrationAction | false; shorthands?: ColumnDefinitions; } //#endregion //#region src/migrationLoader.d.ts /*** * Migration loader module. * * This module is responsible for loading migrations from the file system, allowing for custom loading behaviours. * If no configuration is provided, loading will be performed in a manner that is identical to the classic loading behaviour. * * A new SQL migration loading behaviour is available that supports pairing up/down migrations in separate files using up/down * suffixes before the .sql extension. * * This has been kept intentionally simple for maintainability and readability reasons. * */ /** * The jiti instance to use to load migration files. */ declare const jiti: Jiti; /************************* * Types and interfaces *************************/ /** * A migration unit is a collection of file paths and related migration actions that are related to a single migration. */ interface MigrationUnit { /** * The unique identifier for the migration unit. Represents the significant part of the file name. * Used for tracking which migrations have been performed. */ id: string; /** * The file paths that are part of the migration unit. */ filePaths: string[]; /** * The migration builder actions that are contained within the migration files. */ actions: MigrationBuilderActions; } /** * Loader function type. * * @param filePaths - The file paths to load migrations from. * @returns A list of migration units. */ type MigrationLoader = (filePaths: string[]) => Promise; /** * Predefined loader references. */ type PredefinedLoader = 'default' | 'legacySql' | 'sql'; /** * Configuration extension to support multiple loader strategies. */ interface MigrationLoaderConfig { /** * Configuration for the migration loader strategies. * Strategies are used to load migrations from different sources based on file patterns. * * If no strategy matches, the default strategy is used. */ migrationLoaderStrategies?: MigrationLoaderStrategy[]; /** * Enable [`jiti`](https://github.com/unjs/jiti) tsconfig paths resolution when * loading TypeScript/JavaScript migration files. This makes `compilerOptions.paths` * aliases defined in your `tsconfig.json` resolvable from within migration files. * * - `true`: auto-discover the nearest `tsconfig.json` (walking up from `cwd()`) * - `string`: explicit path to a `tsconfig.json` file * - `false` / `undefined` (default): disabled * * Has no effect on the built-in SQL loaders. * * @default false */ tsconfigPaths?: boolean | string; /** * Redirect messages to this logger object, rather than `console`. */ logger?: Logger; } /** * A migration loader strategy is a configuration object that defines a specific loader for given file extensions. */ interface MigrationLoaderStrategy { /** * File extensions handled by this strategy. */ extensions: string[]; /** * Loader that handles conversion of file paths to migration units. * Can be a loader function, when used as an API, or a predefined loader when using a json configuration file. * * @param filePaths - The file paths to load migrations from. * @returns The migration units. */ loader: MigrationLoader | PredefinedLoader; } //#endregion //#region src/runner.d.ts type AdvisoryLockMode = 'fail' | 'wait'; interface RunnerOptionConfig { /** * The table storing which migrations have been run. */ migrationsTable: string; /** * The schema storing table which migrations have been run. * * (defaults to same value as `schema`) */ migrationsSchema?: string; /** * The schema on which migration will be run. * * @default 'public' */ schema?: string | string[]; /** * The directory containing your migration files. This path is resolved from `cwd()`. * Alternatively, provide a [glob](https://www.npmjs.com/package/glob) pattern or * an array of glob patterns and set `useGlob = true` * * Note: enabling glob will read both, `dir` _and_ `ignorePattern` as glob patterns */ dir: string | string[]; /** * Use [glob](https://www.npmjs.com/package/glob) to find migration files. * This will use `dir` _and_ `ignorePattern` to glob-search for migration files. * * Note: enabling glob will read both, `dir` _and_ `ignorePattern` as glob patterns * * @default false */ useGlob?: boolean; /** * Check order of migrations before running them. */ checkOrder?: boolean; /** * Direction of migration-run. */ direction: MigrationDirection; /** * Number of migration to run. */ count?: number; /** * Treats `count` as timestamp. */ timestamp?: boolean; /** * Regex pattern for file names to ignore (ignores files starting with `.` by default). * Alternatively, provide a [glob](https://www.npmjs.com/package/glob) pattern or * an array of glob patterns and set `isGlob = true` * * Note: enabling glob will read both, `dir` _and_ `ignorePattern` as glob patterns */ ignorePattern?: string | string[]; /** * Run only migration with this name. */ file?: string; dryRun?: boolean; /** * Creates the configured schema if it doesn't exist. */ createSchema?: boolean; /** * Creates the configured migration schema if it doesn't exist. */ createMigrationsSchema?: boolean; /** * Combines all pending migrations into a single transaction so that if any migration fails, all will be rolled back. * * @default true */ singleTransaction?: boolean; /** * Disables locking mechanism and checks. */ noLock?: boolean; /** * Value to use for the lock. */ lockValue?: number; /** * Mark migrations as run without actually performing them (use with caution!). */ fake?: boolean; /** * Runs [`decamelize`](https://github.com/sindresorhus/decamelize) on table/column/etc. names. */ decamelize?: boolean; /** * Redirect log messages to this function, rather than `console`. */ log?: LogFn; /** * Redirect messages to this logger object, rather than `console`. */ logger?: Logger; /** * Print all debug messages like DB queries run (if you switch it on, it will disable `logger.debug` method). */ verbose?: boolean; /** * Controls behavior when the migration advisory lock is already held by another process. Use `fail` to throw immediately or wait to block until the lock becomes available. Default to `fail` */ advisoryLockMode?: AdvisoryLockMode; } interface RunnerOptionUrl { /** * Connection string or client config which is passed to [new pg.Client](https://node-postgres.com/api/client#constructor) */ databaseUrl: string | ClientConfig; } interface RunnerOptionClient { /** * Instance of [new pg.Client](https://node-postgres.com/api/client). * * Instance should be connected to DB and after finishing migration, user is responsible to close connection. */ dbClient: ClientBase; } type RunnerOption = RunnerOptionConfig & MigrationLoaderConfig & (RunnerOptionClient | RunnerOptionUrl); /** * Random but well-known identifier shared by all instances of `node-pg-migrate`. */ declare const PG_MIGRATE_LOCK_ID = 7241865325823964; type MigrationDirection = 'up' | 'down'; declare function runner(options: RunnerOption): Promise; //#endregion //#region src/utils/PgLiteral.d.ts /** * Represents a string that should not be escaped when used in a query. * * This will be used in `pgm.func` to create unescaped strings. */ declare class PgLiteral { /** * Creates a new `PgLiteral` instance. * * @param str The string value. * @returns The new `PgLiteral` instance. */ static create(str: string): PgLiteral; /** * Indicates that this object is a `PgLiteral`. */ readonly literal = true; /** * Value of the literal. */ readonly value: string; /** * Creates a new `PgLiteral` instance. * * @param value The string value. */ constructor(value: string); /** * Returns the string value. * * @returns The string value. */ toString(): string; } type PgLiteralValue = PublicPart; /** * Checks if the given value is a `PgLiteral`. * * @param val The value to check. * @returns `true` if the value is a `PgLiteral`, or `false` otherwise. */ declare function isPgLiteral(val: unknown): val is PgLiteral; //#endregion //#region src/operations/generalTypes.d.ts /** * Type that provides auto-suggestions but also any string. * * @see https://github.com/microsoft/TypeScript/issues/29729#issuecomment-471566609 */ type LiteralUnion = TSuggested | (TBase & { zz_IGNORE_ME?: never; }); type PublicPart = { [K in keyof T]: T[K] }; type Nullable = { [P in keyof T]: T[P] | null }; type Value = null | boolean | string | number | PgLiteral | PgLiteralValue | Value[]; type Type = string | { type: string; }; type Name = string | { schema?: string; name: string; } | PgLiteralValue; interface IfNotExistsOption { ifNotExists?: boolean; } interface IfExistsOption { ifExists?: boolean; } interface CascadeOption { cascade?: boolean; } type DropOptions = IfExistsOption & CascadeOption; /** * A function that returns a normal SQL statement or an array of SQL statements. * * The array is useful for operations that need to return multiple SQL statements like an additional `COMMENT`. */ type OperationFn = (...args: any[]) => string | string[]; /** * A function that returns a normal SQL statement or an array of SQL statements. * * The array is useful for operations that need to return multiple SQL statements like an additional `COMMENT`. * * The `reverse` property is a function that takes the same arguments and try to infer the reverse SQL statement with that. */ type Operation = OperationFn & { /** * Reverse the operation if provided. */ reverse?: OperationFn; }; /** * A function that returns a normal SQL statement or an array of SQL statements. * * The array is useful for operations that need to return multiple SQL statements like an additional `COMMENT`. * * The `reverse` property is a function that takes the same arguments and try to infer the reverse SQL statement with that. */ type Reversible string | string[]> = TFunction & { /** * Reverse the operation. * * Needs to be the same function definition, because it takes the same * arguments and try to infer the reverse SQL statement with that. */ reverse: TFunction; }; //#endregion //#region src/operations/tables/dropColumns.d.ts type DropColumnsOptions = DropOptions; type DropColumns = (tableName: Name, columns: string | string[] | { [name: string]: unknown; }, dropOptions?: DropColumnsOptions) => string; //#endregion //#region src/operations/sequences/shared.d.ts interface SequenceOptions { type?: Type; increment?: number; minvalue?: number | null | false; maxvalue?: number | null | false; start?: number; cache?: number; cycle?: boolean; owner?: string | null | false; } //#endregion //#region src/operations/sequences/alterSequence.d.ts interface AlterSequenceOptions extends SequenceOptions { restart?: number | true; } type AlterSequence = (sequenceName: Name, sequenceOptions: AlterSequenceOptions) => string; //#endregion //#region src/operations/sequences/dropSequence.d.ts type DropSequenceOptions = DropOptions; type DropSequence = (sequenceName: Name, dropOptions?: DropSequenceOptions) => string; //#endregion //#region src/operations/sequences/createSequence.d.ts interface CreateSequenceOptions extends SequenceOptions, IfNotExistsOption { temporary?: boolean; } type CreateSequenceFn = (sequenceName: Name, sequenceOptions?: CreateSequenceOptions & DropSequenceOptions) => string; type CreateSequence = Reversible; //#endregion //#region src/operations/sequences/renameSequence.d.ts type RenameSequenceFn = (oldSequenceName: Name, newSequenceName: Name) => string; type RenameSequence = Reversible; //#endregion //#region src/operations/tables/shared.d.ts type Action = 'NO ACTION' | 'RESTRICT' | 'CASCADE' | 'SET NULL' | 'SET DEFAULT'; interface ReferencesOptions { referencesConstraintName?: string; referencesConstraintComment?: string; references: Name; onDelete?: Action; onUpdate?: Action; match?: 'FULL' | 'SIMPLE'; } type SequenceGeneratedOptions = { precedence: 'ALWAYS' | 'BY DEFAULT'; } & SequenceOptions; interface ColumnDefinition extends Partial { type: string; array?: boolean | number; collation?: string; unique?: boolean; primaryKey?: boolean; notNull?: boolean; default?: Value; check?: string; deferrable?: boolean; deferred?: boolean; comment?: string | null; sequenceGenerated?: SequenceGeneratedOptions; expressionGenerated?: string; } interface ColumnDefinitions { [name: string]: ColumnDefinition | string; } type Like = 'COMMENTS' | 'CONSTRAINTS' | 'DEFAULTS' | 'IDENTITY' | 'INDEXES' | 'STATISTICS' | 'STORAGE' | 'ALL'; interface LikeOptions { including?: Like | Like[]; excluding?: Like | Like[]; } interface ForeignKeyOptions extends ReferencesOptions { columns: Name | Name[]; } interface ConstraintOptions { check?: string | string[]; unique?: Name | Array; primaryKey?: Name | Name[]; foreignKeys?: ForeignKeyOptions | ForeignKeyOptions[]; exclude?: string; deferrable?: boolean; deferred?: boolean; comment?: string; } type PartitionStrategy = 'RANGE' | 'LIST' | 'HASH'; interface PartitionColumnOptions { name: string; collate?: string; opclass?: string; } interface PartitionOptions { strategy: PartitionStrategy; columns: Array | string | PartitionColumnOptions; } interface TableOptions extends IfNotExistsOption { temporary?: boolean; inherits?: Name; like?: Name | { table: Name; options?: LikeOptions; }; constraints?: ConstraintOptions; comment?: string | null; partition?: PartitionOptions; unlogged?: boolean; } //#endregion //#region src/operations/tables/addColumns.d.ts type AddColumnsOptions = IfNotExistsOption; type AddColumnsFn = (tableName: Name, newColumns: ColumnDefinitions, addOptions?: AddColumnsOptions & DropColumnsOptions) => string; type AddColumns = Reversible; //#endregion //#region src/operations/tables/dropConstraint.d.ts type DropConstraintOptions = DropOptions & { ifTableExists?: boolean; }; type DropConstraint = (tableName: Name, constraintName: string, options?: DropConstraintOptions) => string; //#endregion //#region src/operations/tables/addConstraint.d.ts type CreateConstraintFn = (tableName: Name, constraintName: string | null, constraintExpressionOrOptions: (ConstraintOptions & DropConstraintOptions) | string) => string; type CreateConstraint = Reversible; //#endregion //#region src/operations/tables/alterColumn.d.ts interface AlterColumnOptions { type?: string; default?: Value; notNull?: boolean; allowNull?: boolean; collation?: string; using?: string; comment?: string | null; sequenceGenerated?: null | false | SequenceGeneratedOptions; expressionGenerated?: null | string; } type AlterColumn = (tableName: Name, columnName: string, options: AlterColumnOptions) => string; //#endregion //#region src/operations/tables/alterTable.d.ts interface AlterTableOptions { levelSecurity?: 'DISABLE' | 'ENABLE' | 'FORCE' | 'NO FORCE'; unlogged?: boolean; } type AlterTable = (tableName: Name, tableOptions: AlterTableOptions) => string; //#endregion //#region src/operations/tables/dropTable.d.ts type DropTableOptions = DropOptions; type DropTable = (tableName: Name, dropOptions?: DropTableOptions) => string; //#endregion //#region src/operations/tables/createTable.d.ts type CreateTableFn = (tableName: Name, columns: ColumnDefinitions, options?: TableOptions & DropTableOptions) => string; type CreateTable = Reversible; //#endregion //#region src/operations/tables/renameColumn.d.ts type RenameColumnFn = (tableName: Name, oldColumnName: string, newColumnName: string) => string; type RenameColumn = Reversible; //#endregion //#region src/operations/tables/renameConstraint.d.ts type RenameConstraintFn = (tableName: Name, oldConstraintName: string, newConstraintName: string) => string; type RenameConstraint = Reversible; //#endregion //#region src/operations/tables/renameTable.d.ts type RenameTableFn = (tableName: Name, newtableName: Name) => string; type RenameTable = Reversible; //#endregion //#region src/operations/casts/dropCast.d.ts type DropCastOptions = IfExistsOption; type DropCast = (fromType: string, toType: string, dropOptions?: DropCastOptions) => string; //#endregion //#region src/operations/casts/createCast.d.ts interface CreateCastWithFunctionOptions { functionName: Name; argumentTypes?: string[]; inout?: undefined; } interface CreateCastWithoutFunctionOptions { functionName?: undefined; argumentTypes?: undefined; inout?: undefined; } interface CreateCastWithInoutOptions { functionName?: undefined; argumentTypes?: undefined; inout: boolean; } type CreateCastOptions = (CreateCastWithFunctionOptions | CreateCastWithoutFunctionOptions | CreateCastWithInoutOptions) & { as?: 'ASSIGNMENT' | 'IMPLICIT'; }; type CreateCastFn = (fromType: string, toType: string, options: CreateCastOptions & DropCastOptions) => string; type CreateCast = Reversible; //#endregion //#region src/operations/domains/shared.d.ts interface DomainOptions { default?: Value; notNull?: boolean; check?: string; constraintName?: string; } //#endregion //#region src/operations/domains/alterDomain.d.ts interface AlterDomainOptions extends DomainOptions { allowNull?: boolean; } type AlterDomain = (domainName: Name, domainOptions: AlterDomainOptions) => string; //#endregion //#region src/operations/domains/dropDomain.d.ts type DropDomainOptions = DropOptions; type DropDomain = (domainName: Name, dropOptions?: DropDomainOptions) => string; //#endregion //#region src/operations/domains/createDomain.d.ts interface CreateDomainOptions extends DomainOptions { collation?: string; } type CreateDomainFn = (domainName: Name, type: Type, domainOptions?: CreateDomainOptions & DropDomainOptions) => string; type CreateDomain = Reversible; //#endregion //#region src/operations/domains/renameDomain.d.ts type RenameDomainFn = (oldDomainName: Name, newDomainName: Name) => string; type RenameDomain = Reversible; //#endregion //#region src/operations/extensions/shared.d.ts type Extension = 'adminpack' | 'amcheck' | 'auth_delay' | 'auto_explain' | 'bloom' | 'btree_gin' | 'btree_gist' | 'citext' | 'cube' | 'dblink' | 'dict_int' | 'dict_xsyn' | 'earthdistance' | 'file_fdw' | 'fuzzystrmatch' | 'hstore' | 'intagg' | 'intarray' | 'isn' | 'lo' | 'ltree' | 'pageinspect' | 'passwordcheck' | 'pg_buffercache' | 'pgcrypto' | 'pg_freespacemap' | 'pg_prewarm' | 'pgrowlocks' | 'pg_stat_statements' | 'pgstattuple' | 'pg_trgm' | 'pg_visibility' | 'postgres_fdw' | 'seg' | 'sepgsql' | 'spi' | 'sslinfo' | 'tablefunc' | 'tcn' | 'test_decoding' | 'tsm_system_rows' | 'tsm_system_time' | 'unaccent' | 'uuid-ossp' | 'xml2'; type StringExtension = LiteralUnion; //#endregion //#region src/operations/extensions/dropExtension.d.ts type DropExtensionOptions = DropOptions; type DropExtension = (extension: StringExtension | StringExtension[], dropOptions?: DropExtensionOptions) => string | string[]; //#endregion //#region src/operations/extensions/createExtension.d.ts interface CreateExtensionOptions extends IfNotExistsOption { schema?: string; } type CreateExtensionFn = (extension: StringExtension | StringExtension[], extensionOptions?: CreateExtensionOptions & DropExtensionOptions) => string | string[]; type CreateExtension = Reversible; //#endregion //#region src/operations/grants/shared.d.ts interface WithAdminOption { readonly withAdminOption?: boolean; } interface OnlyAdminOption { readonly onlyAdminOption?: boolean; } interface OnlyGrantOption { readonly onlyGrantOption?: boolean; } interface WithGrantOption { readonly withGrantOption?: boolean; } type TablePrivilege = 'SELECT' | 'INSERT' | 'UPDATE' | 'DELETE' | 'TRUNCATE' | 'REFERENCES' | 'TRIGGER'; type SchemaPrivilege = 'CREATE' | 'USAGE'; interface CommonOnTablesOptions { privileges: TablePrivilege | TablePrivilege[] | 'ALL'; roles: Name | Name[]; } type CommonGrantOnTablesOptions = CommonOnTablesOptions & WithGrantOption; interface SomeTablesOptions { tables: Name | Name[]; } interface AllTablesOptions { tables: 'ALL'; schema: string; } type RevokeOnObjectsOptions = OnlyGrantOption & CascadeOption; //#endregion //#region src/operations/grants/revokeOnSchemas.d.ts type RevokeOnSchemasOptions = OnlyGrantOnSchemasOptions & RevokeOnObjectsOptions; type RevokeOnSchemas = (revokeOptions: RevokeOnSchemasOptions) => string; //#endregion //#region src/operations/grants/grantOnSchemas.d.ts interface OnlyGrantOnSchemasOptions { privileges: SchemaPrivilege | SchemaPrivilege[] | 'ALL'; schemas: string[] | string; roles: Name | Name[]; } type GrantOnSchemasOptions = OnlyGrantOnSchemasOptions & WithGrantOption & RevokeOnObjectsOptions; type GrantOnSchemasFn = (grantOptions: GrantOnSchemasOptions & RevokeOnSchemasOptions) => string; type GrantOnSchemas = Reversible; //#endregion //#region src/operations/grants/revokeOnTables.d.ts type RevokeOnTablesOptions = CommonOnTablesOptions & (AllTablesOptions | SomeTablesOptions) & RevokeOnObjectsOptions; type RevokeOnTables = (revokeOptions: RevokeOnTablesOptions) => string; //#endregion //#region src/operations/grants/grantOnTables.d.ts type GrantOnSomeTablesOptions = CommonGrantOnTablesOptions & SomeTablesOptions; type GrantOnAllTablesOptions = CommonGrantOnTablesOptions & AllTablesOptions; type GrantOnTablesOptions = (GrantOnSomeTablesOptions | GrantOnAllTablesOptions) & RevokeOnObjectsOptions; type GrantOnTablesFn = (grantOptions: GrantOnTablesOptions & RevokeOnTablesOptions) => string; type GrantOnTables = Reversible; //#endregion //#region src/operations/grants/revokeRoles.d.ts type RevokeRolesOptions = OnlyAdminOption & CascadeOption; type RevokeRoles = (roles: Name | Name[], rolesFrom: Name | Name[], revokeOptions?: RevokeRolesOptions) => string; //#endregion //#region src/operations/grants/grantRoles.d.ts type GrantRolesOptions = WithAdminOption; type GrantRolesFn = (rolesFrom: Name | Name[], rolesTo: Name | Name[], grantOptions?: GrantRolesOptions & RevokeRolesOptions) => string; type GrantRoles = Reversible; //#endregion //#region src/operations/indexes/shared.d.ts interface IndexColumn { name: string; opclass?: Name; sort?: 'ASC' | 'DESC'; } //#endregion //#region src/operations/indexes/dropIndex.d.ts interface DropIndexOptions extends DropOptions { unique?: boolean; name?: string; concurrently?: boolean; } type DropIndex = (tableName: Name, columns: string | Array, dropOptions?: DropIndexOptions) => string; //#endregion //#region src/operations/indexes/createIndex.d.ts interface CreateIndexOptions extends IfNotExistsOption { name?: string; unique?: boolean; where?: string; concurrently?: boolean; method?: 'btree' | 'hash' | 'gist' | 'spgist' | 'gin'; include?: string | string[]; nulls?: 'distinct' | 'not distinct'; } type CreateIndexFn = (tableName: Name, columns: string | Array, indexOptions?: CreateIndexOptions & DropIndexOptions) => string; type CreateIndex = Reversible; //#endregion //#region src/operations/indexes/renameIndex.d.ts type RenameIndexFn = (name: Name, newName: Name) => string; type RenameIndex = Reversible; //#endregion //#region src/operations/materializedViews/shared.d.ts type StorageParameters = { [key: string]: boolean | number; }; //#endregion //#region src/operations/materializedViews/alterMaterializedView.d.ts interface AlterMaterializedViewOptions { cluster?: null | false | string; extension?: string; storageParameters?: Nullable; } type AlterMaterializedView = (viewName: Name, materializedViewOptions: AlterMaterializedViewOptions) => string; //#endregion //#region src/operations/materializedViews/dropMaterializedView.d.ts type DropMaterializedViewOptions = DropOptions; type DropMaterializedView = (viewName: Name, dropOptions?: DropMaterializedViewOptions) => string; //#endregion //#region src/operations/materializedViews/createMaterializedView.d.ts interface CreateMaterializedViewOptions extends IfNotExistsOption { columns?: string | string[]; tablespace?: string; storageParameters?: StorageParameters; data?: boolean; } type CreateMaterializedViewFn = (viewName: Name, materializedViewOptions: CreateMaterializedViewOptions & DropMaterializedViewOptions, definition: string) => string; type CreateMaterializedView = Reversible; //#endregion //#region src/operations/materializedViews/refreshMaterializedView.d.ts interface RefreshMaterializedViewOptions { concurrently?: boolean; data?: boolean; } type RefreshMaterializedViewFn = (viewName: Name, materializedViewOptions?: RefreshMaterializedViewOptions) => string; type RefreshMaterializedView = Reversible; //#endregion //#region src/operations/materializedViews/renameMaterializedView.d.ts type RenameMaterializedViewFn = (viewName: Name, newViewName: Name) => string; type RenameMaterializedView = Reversible; //#endregion //#region src/operations/materializedViews/renameMaterializedViewColumn.d.ts type RenameMaterializedViewColumnFn = (viewName: Name, columnName: string, newColumnName: string) => string; type RenameMaterializedViewColumn = Reversible; //#endregion //#region src/operations/operators/shared.d.ts interface OperatorListDefinition { type: 'function' | 'operator'; number: number; name: Name; params?: FunctionParam[]; } //#endregion //#region src/operations/operators/addToOperatorFamily.d.ts type AddToOperatorFamilyFn = (operatorFamilyName: Name, indexMethod: string, operatorList: OperatorListDefinition[]) => string; type AddToOperatorFamily = Reversible; //#endregion //#region src/operations/operators/dropOperator.d.ts interface DropOperatorOptions extends DropOptions { left?: Name; right?: Name; } type DropOperator = (operatorName: Name, dropOptions?: DropOperatorOptions) => string; //#endregion //#region src/operations/operators/createOperator.d.ts interface CreateOperatorOptions { procedure: Name; left?: Name; right?: Name; commutator?: Name; negator?: Name; restrict?: Name; join?: Name; hashes?: boolean; merges?: boolean; } type CreateOperatorFn = (operatorName: Name, operatorOptions: CreateOperatorOptions & DropOperatorOptions) => string; type CreateOperator = Reversible; //#endregion //#region src/operations/operators/dropOperatorClass.d.ts type DropOperatorClassOptions = DropOptions; type DropOperatorClass = (operatorClassName: Name, indexMethod: string, dropOptions?: DropOperatorClassOptions) => string; //#endregion //#region src/operations/operators/createOperatorClass.d.ts interface CreateOperatorClassOptions { default?: boolean; family?: string; } type CreateOperatorClassFn = (operatorClassName: Name, type: Type, indexMethod: string, operatorList: OperatorListDefinition[], operatorClassOptions: CreateOperatorClassOptions & DropOperatorClassOptions) => string; type CreateOperatorClass = Reversible; //#endregion //#region src/operations/operators/dropOperatorFamily.d.ts type DropOperatorFamilyOptions = DropOptions; type DropOperatorFamily = (operatorFamilyName: Name, indexMethod: string, dropOptions?: DropOperatorFamilyOptions) => string; //#endregion //#region src/operations/operators/createOperatorFamily.d.ts interface CreateOperatorFamilyOptions {} type CreateOperatorFamilyFn = (operatorFamilyName: Name, indexMethod: string, operatorFamilyOptions?: CreateOperatorFamilyOptions & DropOperatorFamilyOptions) => string; type CreateOperatorFamily = Reversible; //#endregion //#region src/operations/operators/removeFromOperatorFamily.d.ts type RemoveFromOperatorFamily = (operatorFamilyName: Name, indexMethod: string, operatorList: OperatorListDefinition[]) => string; //#endregion //#region src/operations/operators/renameOperatorClass.d.ts type RenameOperatorClassFn = (oldOperatorClassName: Name, indexMethod: string, newOperatorClassName: Name) => string; type RenameOperatorClass = Reversible; //#endregion //#region src/operations/operators/renameOperatorFamily.d.ts type RenameOperatorFamilyFn = (oldOperatorFamilyName: Name, indexMethod: string, newOperatorFamilyName: Name) => string; type RenameOperatorFamily = Reversible; //#endregion //#region src/operations/policies/shared.d.ts interface PolicyOptions { role?: string | string[]; using?: string; check?: string; } //#endregion //#region src/operations/policies/alterPolicy.d.ts type AlterPolicy = (tableName: Name, policyName: string, policyOptions: PolicyOptions) => string; //#endregion //#region src/operations/policies/dropPolicy.d.ts type DropPolicyOptions = IfExistsOption; type DropPolicy = (tableName: Name, policyName: string, dropOptions?: DropPolicyOptions) => string; //#endregion //#region src/operations/policies/createPolicy.d.ts interface CreatePolicyOptionsEn { command?: 'ALL' | 'SELECT' | 'INSERT' | 'UPDATE' | 'DELETE'; } type CreatePolicyOptions = CreatePolicyOptionsEn & PolicyOptions; type CreatePolicyFn = (tableName: Name, policyName: string, policyOptions?: CreatePolicyOptions & DropPolicyOptions) => string; type CreatePolicy = Reversible; //#endregion //#region src/operations/policies/renamePolicy.d.ts type RenamePolicyFn = (tableName: Name, policyName: string, newPolicyName: string) => string; type RenamePolicy = Reversible; //#endregion //#region src/operations/roles/shared.d.ts interface RoleOptions { superuser?: boolean; createdb?: boolean; createrole?: boolean; inherit?: boolean; login?: boolean; replication?: boolean; bypassrls?: boolean; limit?: number; password?: Value; encrypted?: boolean; valid?: Value; inRole?: string | string[]; role?: string | string[]; admin?: string | string[]; } //#endregion //#region src/operations/roles/alterRole.d.ts type AlterRole = (roleName: Name, roleOptions: RoleOptions) => string; //#endregion //#region src/operations/roles/dropRole.d.ts type DropRoleOptions = IfExistsOption; type DropRole = (roleName: Name, dropOptions?: DropRoleOptions) => string; //#endregion //#region src/operations/roles/createRole.d.ts type CreateRoleOptions = RoleOptions; type CreateRoleFn = (roleName: Name, roleOptions?: CreateRoleOptions & DropRoleOptions) => string; type CreateRole = Reversible; //#endregion //#region src/operations/roles/renameRole.d.ts type RenameRoleFn = (oldRoleName: Name, newRoleName: Name) => string; type RenameRole = Reversible; //#endregion //#region src/operations/schemas/dropSchema.d.ts type DropSchemaOptions = DropOptions; type DropSchema = (schemaName: string, dropOptions?: DropSchemaOptions) => string; //#endregion //#region src/operations/schemas/createSchema.d.ts interface CreateSchemaOptions extends IfNotExistsOption { authorization?: string; } type CreateSchemaFn = (schemaName: string, schemaOptions?: CreateSchemaOptions & DropSchemaOptions) => string; type CreateSchema = Reversible; //#endregion //#region src/operations/schemas/renameSchema.d.ts type RenameSchemaFn = (oldSchemaName: string, newSchemaName: string) => string; type RenameSchema = Reversible; //#endregion //#region src/operations/sql.d.ts type Sql = (sqlStr: string, args?: { [key: string]: Name | Value; }) => string; //#endregion //#region src/operations/triggers/dropTrigger.d.ts type DropTriggerOptions = DropOptions; type DropTrigger = (tableName: Name, triggerName: string, dropOptions?: DropTriggerOptions) => string; //#endregion //#region src/operations/triggers/shared.d.ts interface TriggerOptions { when?: 'BEFORE' | 'AFTER' | 'INSTEAD OF'; operation: string | string[]; constraint?: boolean; function?: Name; functionParams?: Value[]; level?: 'STATEMENT' | 'ROW'; condition?: string; deferrable?: boolean; deferred?: boolean; } //#endregion //#region src/operations/triggers/createTrigger.d.ts type CreateTriggerFn1 = (tableName: Name, triggerName: string, triggerOptions: TriggerOptions & DropTriggerOptions) => string; type CreateTriggerFn2 = (tableName: Name, triggerName: string, triggerOptions: TriggerOptions & FunctionOptions & DropTriggerOptions, definition: Value) => string; type CreateTriggerFn = CreateTriggerFn1 | CreateTriggerFn2; type CreateTrigger = Reversible; //#endregion //#region src/operations/triggers/renameTrigger.d.ts type RenameTriggerFn = (tableName: Name, oldTriggerName: string, newTriggerName: string) => string; type RenameTrigger = Reversible; //#endregion //#region src/operations/types/dropTypeAttribute.d.ts type DropTypeAttributeOptions = IfExistsOption; type DropTypeAttribute = (typeName: Name, attributeName: string, dropOptions?: DropTypeAttributeOptions) => string; //#endregion //#region src/operations/types/addTypeAttribute.d.ts type AddTypeAttributeFn = (typeName: Name, attributeName: string, attributeType: Type & DropTypeAttributeOptions) => string; type AddTypeAttribute = Reversible; //#endregion //#region src/operations/types/addTypeValue.d.ts interface AddTypeValueOptions extends IfNotExistsOption { before?: string; after?: string; } type AddTypeValue = (typeName: Name, value: Value, typeValueOptions?: AddTypeValueOptions) => string; //#endregion //#region src/operations/types/dropType.d.ts type DropTypeOptions = DropOptions; type DropType = (typeName: Name, dropOptions?: DropTypeOptions) => string; //#endregion //#region src/operations/types/createType.d.ts type CreateTypeFn = (typeName: Name, values: (Value[] | { [name: string]: Type; }) & DropTypeOptions) => string; type CreateType = Reversible; //#endregion //#region src/operations/types/renameType.d.ts type RenameTypeFn = (typeName: Name, newTypeName: Name) => string; type RenameType = Reversible; //#endregion //#region src/operations/types/renameTypeAttribute.d.ts type RenameTypeAttributeFn = (typeName: Name, attributeName: string, newAttributeName: string) => string; type RenameTypeAttribute = Reversible; //#endregion //#region src/operations/types/renameTypeValue.d.ts type RenameTypeValueFn = (typeName: Name, value: string, newValue: string) => string; type RenameTypeValue = Reversible; //#endregion //#region src/operations/types/setTypeAttribute.d.ts type SetTypeAttribute = (typeName: Name, attributeName: string, attributeType: Type) => string; //#endregion //#region src/operations/views/shared.d.ts type ViewOptions = { [key: string]: boolean | number | string; }; //#endregion //#region src/operations/views/alterView.d.ts interface AlterViewOptions { checkOption?: null | 'CASCADED' | 'LOCAL'; options?: Nullable; } type AlterView = (viewName: Name, viewOptions: AlterViewOptions) => string; //#endregion //#region src/operations/views/alterViewColumn.d.ts interface AlterViewColumnOptions { default?: Value; } type AlterViewColumn = (viewName: Name, columnName: string, viewColumnOptions: AlterViewColumnOptions) => string; //#endregion //#region src/operations/views/dropView.d.ts type DropViewOptions = DropOptions; type DropView = (viewName: Name, dropOptions?: DropViewOptions) => string; //#endregion //#region src/operations/views/createView.d.ts interface CreateViewOptions { temporary?: boolean; replace?: boolean; recursive?: boolean; columns?: string | string[]; checkOption?: 'CASCADED' | 'LOCAL'; options?: ViewOptions; } type CreateViewFn = (viewName: Name, options: CreateViewOptions & DropViewOptions, definition: string) => string; type CreateView = Reversible; //#endregion //#region src/operations/views/renameView.d.ts type RenameViewFn = (viewName: Name, newViewName: Name) => string; type RenameView = Reversible; //#endregion //#region src/migrationBuilder.d.ts declare class MigrationBuilder { /** * Install an extension. * * @alias addExtension * * @see https://www.postgresql.org/docs/current/sql-createextension.html */ readonly createExtension: (...args: Parameters) => void; /** * Remove an extension. * * @see https://www.postgresql.org/docs/current/sql-dropextension.html */ readonly dropExtension: (...args: Parameters) => void; /** * Install an extension. * * @alias createExtension * * @see https://www.postgresql.org/docs/current/sql-createextension.html */ readonly addExtension: (...args: Parameters) => void; /** * Define a new table. * * @see https://www.postgresql.org/docs/current/sql-createtable.html */ readonly createTable: (...args: Parameters) => void; /** * Remove a table. * * @see https://www.postgresql.org/docs/current/sql-droptable.html */ readonly dropTable: (...args: Parameters) => void; /** * Rename a table. * * @see https://www.postgresql.org/docs/current/sql-altertable.html */ readonly renameTable: (...args: Parameters) => void; /** * Change the definition of a table. * * @see https://www.postgresql.org/docs/current/sql-altertable.html */ readonly alterTable: (...args: Parameters) => void; /** * Add columns to a table. * * @alias addColumn * * @see https://www.postgresql.org/docs/current/sql-altertable.html */ readonly addColumns: (...args: Parameters) => void; /** * Remove columns from a table. * * @alias dropColumn * * @see https://www.postgresql.org/docs/current/sql-altertable.html */ readonly dropColumns: (...args: Parameters) => void; /** * Rename a column. * * @see https://www.postgresql.org/docs/current/sql-altertable.html */ readonly renameColumn: (...args: Parameters) => void; /** * Change the definition of a column. * * @see https://www.postgresql.org/docs/current/sql-altertable.html */ readonly alterColumn: (...args: Parameters) => void; /** * Add a column to a table. * * @alias addColumns * * @see https://www.postgresql.org/docs/current/sql-altertable.html */ readonly addColumn: (...args: Parameters) => void; /** * Remove a column from a table. * * @alias dropColumns * * @see https://www.postgresql.org/docs/current/sql-altertable.html */ readonly dropColumn: (...args: Parameters) => void; /** * Add a constraint to a table. * * @alias createConstraint * * @see https://www.postgresql.org/docs/current/sql-altertable.html */ readonly addConstraint: (...args: Parameters) => void; /** * Remove a constraint from a table. * * @see https://www.postgresql.org/docs/current/sql-altertable.html */ readonly dropConstraint: (...args: Parameters) => void; /** * Rename a constraint. * * @see https://www.postgresql.org/docs/current/sql-altertable.html */ readonly renameConstraint: (...args: Parameters) => void; /** * Add a constraint to a table. * * @alias addConstraint * * @see https://www.postgresql.org/docs/current/sql-altertable.html */ readonly createConstraint: (...args: Parameters) => void; /** * Define a new data type. * * @alias addType * * @see https://www.postgresql.org/docs/current/sql-createtype.html */ readonly createType: (...args: Parameters) => void; /** * Remove a data type. * * @see https://www.postgresql.org/docs/current/sql-droptype.html */ readonly dropType: (...args: Parameters) => void; /** * Define a new data type. * * @alias createType * * @see https://www.postgresql.org/docs/current/sql-createtype.html */ readonly addType: (...args: Parameters) => void; /** * Rename a data type. * * @see https://www.postgresql.org/docs/current/sql-altertype.html */ readonly renameType: (...args: Parameters) => void; /** * Rename a data type attribute. * * @see https://www.postgresql.org/docs/current/sql-altertype.html */ readonly renameTypeAttribute: (...args: Parameters) => void; /** * Rename a data type value. * * @see https://www.postgresql.org/docs/current/sql-altertype.html */ readonly renameTypeValue: (...args: Parameters) => void; /** * Add an attribute to a data type. * * @see https://www.postgresql.org/docs/current/sql-altertype.html */ readonly addTypeAttribute: (...args: Parameters) => void; /** * Remove an attribute from a data type. * * @see https://www.postgresql.org/docs/current/sql-altertype.html */ readonly dropTypeAttribute: (...args: Parameters) => void; /** * Set an attribute of a data type. * * @see https://www.postgresql.org/docs/current/sql-altertype.html */ readonly setTypeAttribute: (...args: Parameters) => void; /** * Add a value to a data type. * * @see https://www.postgresql.org/docs/current/sql-altertype.html */ readonly addTypeValue: (...args: Parameters) => void; /** * Define a new index. * * @alias addIndex * * @see https://www.postgresql.org/docs/current/sql-createindex.html */ readonly createIndex: (...args: Parameters) => void; /** * Remove an index. * * @see https://www.postgresql.org/docs/current/sql-dropindex.html */ readonly dropIndex: (...args: Parameters) => void; /** * Define a new index. * * @alias createIndex * * @see https://www.postgresql.org/docs/current/sql-createindex.html */ readonly addIndex: (...args: Parameters) => void; /** * Rename an index. * * @see https://www.postgresql.org/docs/current/sql-alterindex.html */ readonly renameIndex: (...args: Parameters) => void; /** * Define a new database role. * * @see https://www.postgresql.org/docs/current/sql-createrole.html */ readonly createRole: (...args: Parameters) => void; /** * Remove a database role. * * @see https://www.postgresql.org/docs/current/sql-droprole.html */ readonly dropRole: (...args: Parameters) => void; /** * Change a database role. * * @see https://www.postgresql.org/docs/current/sql-alterrole.html */ readonly alterRole: (...args: Parameters) => void; /** * Rename a database role. * * @see https://www.postgresql.org/docs/current/sql-alterrole.html */ readonly renameRole: (...args: Parameters) => void; /** * Define a new function. * * @see https://www.postgresql.org/docs/current/sql-createfunction.html */ readonly createFunction: (...args: Parameters) => void; /** * Remove a function. * * @see https://www.postgresql.org/docs/current/sql-dropfunction.html */ readonly dropFunction: (...args: Parameters) => void; /** * Rename a function. * * @see https://www.postgresql.org/docs/current/sql-alterfunction.html */ readonly renameFunction: (...args: Parameters) => void; /** * Define a new trigger. * * @see https://www.postgresql.org/docs/current/sql-createtrigger.html */ readonly createTrigger: (...args: Parameters) => void; /** * Remove a trigger. * * @see https://www.postgresql.org/docs/current/sql-droptrigger.html */ readonly dropTrigger: (...args: Parameters) => void; /** * Rename a trigger. * * @see https://www.postgresql.org/docs/current/sql-altertrigger.html */ readonly renameTrigger: (...args: Parameters) => void; /** * Define a new schema. * * @see https://www.postgresql.org/docs/current/sql-createschema.html */ readonly createSchema: (...args: Parameters) => void; /** * Remove a schema. * * @see https://www.postgresql.org/docs/current/sql-dropschema.html */ readonly dropSchema: (...args: Parameters) => void; /** * Rename a schema. * * @see https://www.postgresql.org/docs/current/sql-alterschema.html */ readonly renameSchema: (...args: Parameters) => void; /** * Define a new domain. * * @see https://www.postgresql.org/docs/current/sql-createdomain.html */ readonly createDomain: (...args: Parameters) => void; /** * Remove a domain. * * @see https://www.postgresql.org/docs/current/sql-dropdomain.html */ readonly dropDomain: (...args: Parameters) => void; /** * Change the definition of a domain. * * @see https://www.postgresql.org/docs/current/sql-alterdomain.html */ readonly alterDomain: (...args: Parameters) => void; /** * Rename a domain. * * @see https://www.postgresql.org/docs/current/sql-alterdomain.html */ readonly renameDomain: (...args: Parameters) => void; /** * Define a new sequence generator. * * @see https://www.postgresql.org/docs/current/sql-createsequence.html */ readonly createSequence: (...args: Parameters) => void; /** * Remove a sequence. * * @see https://www.postgresql.org/docs/current/sql-dropsequence.html */ readonly dropSequence: (...args: Parameters) => void; /** * Change the definition of a sequence generator. * * @see https://www.postgresql.org/docs/current/sql-altersequence.html */ readonly alterSequence: (...args: Parameters) => void; /** * Rename a sequence. * * @see https://www.postgresql.org/docs/current/sql-altersequence.html */ readonly renameSequence: (...args: Parameters) => void; /** * Define a new operator. * * @see https://www.postgresql.org/docs/current/sql-createoperator.html */ readonly createOperator: (...args: Parameters) => void; /** * Remove an operator. * * @see https://www.postgresql.org/docs/current/sql-dropoperator.html */ readonly dropOperator: (...args: Parameters) => void; /** * Define a new operator class. * * @see https://www.postgresql.org/docs/current/sql-createopclass.html */ readonly createOperatorClass: (...args: Parameters) => void; /** * Remove an operator class. * * @see https://www.postgresql.org/docs/current/sql-dropopclass.html */ readonly dropOperatorClass: (...args: Parameters) => void; /** * Rename an operator class. * * @see https://www.postgresql.org/docs/current/sql-alteropclass.html */ readonly renameOperatorClass: (...args: Parameters) => void; /** * Define a new operator family. * * @see https://www.postgresql.org/docs/current/sql-createopfamily.html */ readonly createOperatorFamily: (...args: Parameters) => void; /** * Remove an operator family. * * @see https://www.postgresql.org/docs/current/sql-dropopfamily.html */ readonly dropOperatorFamily: (...args: Parameters) => void; /** * Rename an operator family. * * @see https://www.postgresql.org/docs/current/sql-alteropfamily.html */ readonly renameOperatorFamily: (...args: Parameters) => void; /** * Add an operator to an operator family. * * @see https://www.postgresql.org/docs/current/sql-alteropfamily.html */ readonly addToOperatorFamily: (...args: Parameters) => void; /** * Remove an operator from an operator family. * * @see https://www.postgresql.org/docs/current/sql-alteropfamily.html */ readonly removeFromOperatorFamily: (...args: Parameters) => void; /** * Define a new row-level security policy for a table. * * @see https://www.postgresql.org/docs/current/sql-createpolicy.html */ readonly createPolicy: (...args: Parameters) => void; /** * Remove a row-level security policy from a table. * * @see https://www.postgresql.org/docs/current/sql-droppolicy.html */ readonly dropPolicy: (...args: Parameters) => void; /** * Change the definition of a row-level security policy. * * @see https://www.postgresql.org/docs/current/sql-alterpolicy.html */ readonly alterPolicy: (...args: Parameters) => void; /** * Rename a row-level security policy. * * @see https://www.postgresql.org/docs/current/sql-alterpolicy.html */ readonly renamePolicy: (...args: Parameters) => void; /** * Define a new view. * * @see https://www.postgresql.org/docs/current/sql-createview.html */ readonly createView: (...args: Parameters) => void; /** * Remove a view. * * @see https://www.postgresql.org/docs/current/sql-dropview.html */ readonly dropView: (...args: Parameters) => void; /** * Change the definition of a view. * * @see https://www.postgresql.org/docs/current/sql-alterview.html */ readonly alterView: (...args: Parameters) => void; /** * Change the definition of a view column. * * @see https://www.postgresql.org/docs/current/sql-alterview.html */ readonly alterViewColumn: (...args: Parameters) => void; /** * Rename a view. * * @see https://www.postgresql.org/docs/current/sql-alterview.html */ readonly renameView: (...args: Parameters) => void; /** * Define a new materialized view. * * @see https://www.postgresql.org/docs/current/sql-creatematerializedview.html */ readonly createMaterializedView: (...args: Parameters) => void; /** * Remove a materialized view. * * @see https://www.postgresql.org/docs/current/sql-dropmaterializedview.html */ readonly dropMaterializedView: (...args: Parameters) => void; /** * Change the definition of a materialized view. * * @see https://www.postgresql.org/docs/current/sql-altermaterializedview.html */ readonly alterMaterializedView: (...args: Parameters) => void; /** * Rename a materialized view. * * @see https://www.postgresql.org/docs/current/sql-altermaterializedview.html */ readonly renameMaterializedView: (...args: Parameters) => void; /** * Rename a materialized view column. * * @see https://www.postgresql.org/docs/current/sql-altermaterializedview.html */ readonly renameMaterializedViewColumn: (...args: Parameters) => void; /** * Replace the contents of a materialized view. * * @see https://www.postgresql.org/docs/current/sql-refreshmaterializedview.html */ readonly refreshMaterializedView: (...args: Parameters) => void; /** * Define access privileges. * * @see https://www.postgresql.org/docs/current/sql-grant.html */ readonly grantRoles: (...args: Parameters) => void; /** * Remove access privileges. * * @see https://www.postgresql.org/docs/current/sql-revoke.html */ readonly revokeRoles: (...args: Parameters) => void; /** * Define access privileges. * * @see https://www.postgresql.org/docs/current/sql-grant.html */ readonly grantOnSchemas: (...args: Parameters) => void; /** * Remove access privileges. * * @see https://www.postgresql.org/docs/current/sql-revoke.html */ readonly revokeOnSchemas: (...args: Parameters) => void; /** * Define access privileges. * * @see https://www.postgresql.org/docs/current/sql-grant.html */ readonly grantOnTables: (...args: Parameters) => void; /** * Remove access privileges. * * @see https://www.postgresql.org/docs/current/sql-revoke.html */ readonly revokeOnTables: (...args: Parameters) => void; /** * Define a new cast. * * @see https://www.postgresql.org/docs/current/sql-createcast.html */ readonly createCast: (...args: Parameters) => void; /** * Remove a cast. * * @see https://www.postgresql.org/docs/current/sql-dropcast.html */ readonly dropCast: (...args: Parameters) => void; /** * Run raw SQL, with some optional _[very basic](http://mir.aculo.us/2011/03/09/little-helpers-a-tweet-sized-javascript-templating-engine/)_ mustache templating. * * This is a low-level operation, and you should use the higher-level operations whenever possible. * * @param sql SQL query to run. * @param args Optional `key/val` of arguments to replace. * * @see https://www.postgresql.org/docs/current/sql-commands.html */ readonly sql: (...args: Parameters) => void; /** * Inserts raw string, **which is not escaped**. * * @param sql String to **not escaped**. * * @example * { default: pgm.func('CURRENT_TIMESTAMP') } */ readonly func: (sql: string) => PgLiteral; /** * The `db` client instance. * * Can be used to run queries directly. */ readonly db: DB; private _steps; private _REVERSE_MODE; private _useTransaction; constructor(db: DB, typeShorthands: ColumnDefinitions | undefined, shouldDecamelize: boolean, logger: Logger); /** * Run the reverse of the migration. Useful for creating a new migration that * reverts a previous migration. */ enableReverseMode(): this; /** * By default, all migrations are run in one transaction, but some DB * operations like add type value (`pgm.addTypeValue`) does not work if the * type is not created in the same transaction. * e.g. if it is created in previous migration. You need to run specific * migration outside a transaction (`pgm.noTransaction`). * Be aware that this means that you can have some migrations applied and some * not applied, if there is some error during migrating (leading to `ROLLBACK`). */ noTransaction(): this; isUsingTransaction(): boolean; getSql(): string; getSqlSteps(): string[]; } //#endregion //#region src/migration.d.ts type MigrationAction = (pgm: MigrationBuilder, run?: () => void) => Promise | void; interface RunMigration { readonly path: string; readonly name: string; readonly timestamp: number; } declare const FilenameFormat: Readonly<{ timestamp: "timestamp"; utc: "utc"; index: "index"; }>; type FilenameFormat = (typeof FilenameFormat)[keyof typeof FilenameFormat]; interface CreateOptionsTemplate { templateFileName: string; } interface CreateOptionsDefault { language?: 'js' | 'ts' | 'sql' | 'cjs' | 'mjs' | 'cts' | 'mts'; ignorePattern?: string; } type CreateOptions = { filenameFormat?: FilenameFormat; ignorePattern?: string; } & (CreateOptionsTemplate | CreateOptionsDefault); declare class Migration implements RunMigration { /** * Get file prefix for a new migrations file * * @method Migration.getFilePrefix * @param filenameFormat Filename format * @param directory Migrations directory * @param [ignorePattern] Glob ignore pattern * @returns string New file prefix */ static getFilePrefix(filenameFormat: string, directory: string, ignorePattern?: string): Promise; static create(name: string, directory: string, options?: CreateOptions): Promise; readonly db: DBConnection; readonly path: string; readonly name: string; readonly timestamp: number; up?: false | MigrationAction; down?: false | MigrationAction; readonly options: RunnerOption; readonly typeShorthands?: ColumnDefinitions; readonly logger: Logger; constructor(db: DBConnection, migrationPath: string, { up, down }: MigrationBuilderActions, options: RunnerOption, typeShorthands?: ColumnDefinitions, logger?: Logger); _getMarkAsRun(action: MigrationAction): string; _apply(action: MigrationAction, pgm: MigrationBuilder): Promise; _getAction(direction: MigrationDirection): MigrationAction; apply(direction: MigrationDirection): Promise; markAsRun(direction: MigrationDirection): Promise; } //#endregion //#region src/pgType.d.ts /** * @see https://www.postgresql.org/docs/current/datatype.html */ declare const PgType: Readonly<{ /** * signed eight-byte integer * * @see https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-INT */ BIGINT: "bigint"; /** * alias for bigint * * @see https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-INT */ INT8: "int8"; /** * autoincrementing eight-byte integer * * @see https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-SERIAL */ BIGSERIAL: "bigserial"; /** * alias for bigserial * * @see https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-SERIAL */ SERIAL8: "serial8"; /** * fixed-length bit string * * @see https://www.postgresql.org/docs/current/datatype-bit.html#DATATYPE-BIT */ BIT: "bit"; /** * fixed-length bit string * * @see https://www.postgresql.org/docs/current/datatype-bit.html#DATATYPE-BIT */ BIT_1: "bit"; /** * variable-length bit string * * @see https://www.postgresql.org/docs/current/datatype-bit.html#DATATYPE-BIT */ BIT_VARYING: "bit varying"; /** * alias for bit varying * * @see https://www.postgresql.org/docs/current/datatype-bit.html#DATATYPE-BIT */ VARBIT: "varbit"; /** * logical Boolean (true/false) * * @see https://www.postgresql.org/docs/current/datatype-boolean.html#DATATYPE-BOOLEAN */ BOOLEAN: "boolean"; /** * alias for boolean * * @see https://www.postgresql.org/docs/current/datatype-boolean.html#DATATYPE-BOOLEAN */ BOOL: "bool"; /** * rectangular box on a plane * * @see https://www.postgresql.org/docs/current/datatype-geometric.html#DATATYPE-GEOMETRIC */ BOX: "box"; /** * binary data ("byte array") * * @see https://www.postgresql.org/docs/current/datatype-binary.html#DATATYPE-BINARY */ BYTEA: "bytea"; /** * fixed-length character string * * @see https://www.postgresql.org/docs/current/datatype-character.html#DATATYPE-CHARACTER */ CHARACTER: "character"; /** * alias for character * * @see https://www.postgresql.org/docs/current/datatype-character.html#DATATYPE-CHARACTER */ CHAR: "char"; /** * variable-length character string * * @see https://www.postgresql.org/docs/current/datatype-character.html#DATATYPE-CHARACTER */ CHARACTER_VARYING: "character varying"; /** * alias for character varying * * @see https://www.postgresql.org/docs/current/datatype-character.html#DATATYPE-CHARACTER */ VARCHAR: "varchar"; /** * IPv4 or IPv6 network address * * @see https://www.postgresql.org/docs/current/datatype-net-types.html#DATATYPE-NET-TYPES */ CIDR: "cidr"; /** * circle on a plane * * @see https://www.postgresql.org/docs/current/datatype-geometric.html#DATATYPE-GEOMETRIC */ CIRCLE: "circle"; /** * calendar date (year, month, day) * * @see https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-DATETIME */ DATE: "date"; /** * float8 double precision floating-point number (8 bytes) * * @see https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-FLOAT */ DOUBLE_PRECISION: "double precision"; /** * alias for double precision * * @see https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-FLOAT */ FLOAT8: "float8"; /** * IPv4 or IPv6 host address * * @see https://www.postgresql.org/docs/current/datatype-net-types.html#DATATYPE-NET-TYPES */ INET: "inet"; /** * signed four-byte integer * * @see https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-INT */ INTEGER: "integer"; /** * alias for integer * * @see https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-INT */ INT: "int"; /** * alias for integer * * @see https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-INT */ INT4: "int4"; /** * time span * * @see https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-DATETIME */ INTERVAL: "interval"; /** * textual JSON data * * @see https://www.postgresql.org/docs/current/datatype-json.html#DATATYPE-JSON */ JSON: "json"; /** * binary JSON data, decomposed * * @see https://www.postgresql.org/docs/current/datatype-json.html#DATATYPE-JSON */ JSONB: "jsonb"; /** * infinite line on a plane * * @see https://www.postgresql.org/docs/current/datatype-geometric.html#DATATYPE-GEOMETRIC */ LINE: "line"; /** * line segment on a plane * * @see https://www.postgresql.org/docs/current/datatype-geometric.html#DATATYPE-GEOMETRIC */ LSEG: "lseg"; /** * MAC (Media Access Control) address * * @see https://www.postgresql.org/docs/current/datatype-net-types.html#DATATYPE-NET-TYPES */ MACADDR: "macaddr"; /** * MAC (Media Access Control) address (EUI-64 format) * * @see https://www.postgresql.org/docs/current/datatype-net-types.html#DATATYPE-NET-TYPES */ MACADDR8: "macaddr8"; /** * currency amount * * @see https://www.postgresql.org/docs/current/datatype-money.html#DATATYPE-MONEY */ MONEY: "money"; /** * exact numeric of selectable precision * * @see https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-NUMERIC-DECIMAL */ NUMERIC: "numeric"; /** * alias for numeric * * @see https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-NUMERIC-DECIMAL */ DECIMAL: "decimal"; /** * geometric path on a plane * * @see https://www.postgresql.org/docs/current/datatype-geometric.html#DATATYPE-GEOMETRIC */ PATH: "path"; /** * PostgreSQL Log Sequence Number * * @see https://www.postgresql.org/docs/current/datatype-pg-lsn.html#DATATYPE-PG-LSN */ PG_LSN: "pg_lsn"; /** * user-level transaction ID snapshot */ PG_SNAPSHOT: "pg_snapshot"; /** * geometric point on a plane * * @see https://www.postgresql.org/docs/current/datatype-geometric.html#DATATYPE-GEOMETRIC */ POINT: "point"; /** * closed geometric path on a plane * * @see https://www.postgresql.org/docs/current/datatype-geometric.html#DATATYPE-GEOMETRIC */ POLYGON: "polygon"; /** * single precision floating-point number (4 bytes) * * @see https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-FLOAT */ REAL: "real"; /** * alias for real * * @see https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-FLOAT */ FLOAT4: "float4"; /** * signed two-byte integer * * @see https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-INT */ SMALLINT: "smallint"; /** * alias for smallint * * @see https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-INT */ INT2: "int2"; /** * autoincrementing two-byte integer * * @see https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-SERIAL */ SMALLSERIAL: "smallserial"; /** * alias for smallserial * * @see https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-SERIAL */ SERIAL2: "serial2"; /** * autoincrementing four-byte integer * * @see https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-SERIAL */ SERIAL: "serial"; /** * alias for serial * * @see https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-SERIAL */ SERIAL4: "serial4"; /** * variable-length character string * * @see https://www.postgresql.org/docs/current/datatype-character.html#DATATYPE-CHARACTER */ TEXT: "text"; /** * time of day (no time zone) * * @see https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-DATETIME */ TIME: "time"; /** * alias of time * * @see https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-DATETIME */ TIME_WITHOUT_TIME_ZONE: "time without time zone"; /** * time of day, including time zone * * @see https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-DATETIME */ TIME_WITH_TIME_ZONE: "time with time zone"; /** * alias of time with time zone * * @see https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-DATETIME */ TIMETZ: "timetz"; /** * date and time (no time zone) * * @see https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-DATETIME */ TIMESTAMP: "timestamp"; /** * alias of timestamp * * @see https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-DATETIME */ TIMESTAMP_WITHOUT_TIME_ZONE: "timestamp without time zone"; /** * date and time, including time zone * * @see https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-DATETIME */ TIMESTAMP_WITH_TIME_ZONE: "timestamp with time zone"; /** * alias of timestamp with time zone * * @see https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-DATETIME */ TIMESTAMPTZ: "timestamptz"; /** * text search query * * @see https://www.postgresql.org/docs/current/datatype-textsearch.html#DATATYPE-TSQUERY */ TSQUERY: "tsquery"; /** * text search document * * @see https://www.postgresql.org/docs/current/datatype-textsearch.html#DATATYPE-TSVECTOR */ TSVECTOR: "tsvector"; /** * user-level transaction ID snapshot * * @deprecated see `PG_SNAPSHOT` */ TXID_SNAPSHOT: "txid_snapshot"; /** * universally unique identifier * * @see https://www.postgresql.org/docs/current/datatype-uuid.html#DATATYPE-UUID */ UUID: "uuid"; /** * XML data * * @see https://www.postgresql.org/docs/current/datatype-xml.html#DATATYPE-XML */ XML: "xml"; }>; type PgType = (typeof PgType)[keyof typeof PgType]; //#endregion export { type Action, type AddColumns, type AddColumnsFn, type AddColumnsOptions, type AddToOperatorFamily, type AddToOperatorFamilyFn, type AddTypeAttribute, type AddTypeAttributeFn, type AddTypeValue, type AddTypeValueOptions, type AllTablesOptions, type AlterColumn, type AlterColumnOptions, type AlterDomain, type AlterDomainOptions, type AlterMaterializedView, type AlterMaterializedViewOptions, type AlterPolicy, type AlterRole, type AlterSequence, type AlterSequenceOptions, type AlterTable, type AlterTableOptions, type AlterView, type AlterViewColumn, type AlterViewColumnOptions, type AlterViewOptions, type CascadeOption, type ColumnDefinition, type ColumnDefinitions, type CommonGrantOnTablesOptions, type CommonOnTablesOptions, type ConstraintOptions, type CreateCast, type CreateCastFn, type CreateCastOptions, type CreateCastWithFunctionOptions, type CreateCastWithInoutOptions, type CreateCastWithoutFunctionOptions, type CreateConstraint, type CreateConstraintFn, type CreateDomain, type CreateDomainFn, type CreateDomainOptions, type CreateExtension, type CreateExtensionFn, type CreateExtensionOptions, type CreateFunction, type CreateFunctionFn, type CreateFunctionOptions, type CreateIndex, type CreateIndexFn, type CreateIndexOptions, type CreateMaterializedView, type CreateMaterializedViewFn, type CreateMaterializedViewOptions, type CreateOperator, type CreateOperatorClass, type CreateOperatorClassFn, type CreateOperatorClassOptions, type CreateOperatorFamily, type CreateOperatorFamilyFn, type CreateOperatorFamilyOptions, type CreateOperatorFn, type CreateOperatorOptions, type CreatePolicy, type CreatePolicyOptions, type CreatePolicyOptionsEn, type CreateRole, type CreateRoleFn, type CreateRoleOptions, type CreateSchema, type CreateSchemaFn, type CreateSchemaOptions, type CreateSequence, type CreateSequenceFn, type CreateSequenceOptions, type CreateTable, type CreateTableFn, type CreateTrigger, type CreateTriggerFn, type CreateTriggerFn1, type CreateTriggerFn2, type CreateType, type CreateTypeFn, type CreateView, type CreateViewFn, type CreateViewOptions, type DomainOptions, type DropCast, type DropCastOptions, type DropColumns, type DropColumnsOptions, type DropConstraint, type DropConstraintOptions, type DropDomain, type DropDomainOptions, type DropExtension, type DropExtensionOptions, type DropFunction, type DropFunctionOptions, type DropIndex, type DropIndexOptions, type DropMaterializedView, type DropMaterializedViewOptions, type DropOperator, type DropOperatorClass, type DropOperatorClassOptions, type DropOperatorFamily, type DropOperatorFamilyOptions, type DropOperatorOptions, type DropOptions, type DropPolicy, type DropPolicyOptions, type DropRole, type DropRoleOptions, type DropSchema, type DropSchemaOptions, type DropSequence, type DropSequenceOptions, type DropTable, type DropTableOptions, type DropTrigger, type DropTriggerOptions, type DropType, type DropTypeAttribute, type DropTypeAttributeOptions, type DropTypeOptions, type DropView, type DropViewOptions, type Extension, type ForeignKeyOptions, type FunctionOptions, type FunctionParam, type FunctionParamType, type GrantOnAllTablesOptions, type GrantOnSchemas, type GrantOnSchemasFn, type GrantOnSchemasOptions, type GrantOnSomeTablesOptions, type GrantOnTables, type GrantOnTablesFn, type GrantOnTablesOptions, type GrantRoles, type GrantRolesFn, type GrantRolesOptions, type IfExistsOption, type IfNotExistsOption, type IndexColumn, type Like, type LikeOptions, type LiteralUnion, Migration, MigrationBuilder, type Name, type Nullable, type OnlyAdminOption, type OnlyGrantOnSchemasOptions, type OnlyGrantOption, type Operation, type OperationFn, type OperatorListDefinition, PG_MIGRATE_LOCK_ID, PgLiteral, type PgLiteralValue, PgType, type PolicyOptions, type PublicPart, type ReferencesOptions, type RefreshMaterializedView, type RefreshMaterializedViewFn, type RefreshMaterializedViewOptions, type RemoveFromOperatorFamily, type RenameColumn, type RenameColumnFn, type RenameConstraint, type RenameConstraintFn, type RenameDomain, type RenameDomainFn, type RenameFunction, type RenameFunctionFn, type RenameMaterializedView, type RenameMaterializedViewColumn, type RenameMaterializedViewColumnFn, type RenameMaterializedViewFn, type RenameOperatorClass, type RenameOperatorClassFn, type RenameOperatorFamily, type RenameOperatorFamilyFn, type RenamePolicy, type RenamePolicyFn, type RenameRole, type RenameRoleFn, type RenameSchema, type RenameSchemaFn, type RenameSequence, type RenameSequenceFn, type RenameTable, type RenameTableFn, type RenameTrigger, type RenameTriggerFn, type RenameType, type RenameTypeAttribute, type RenameTypeAttributeFn, type RenameTypeFn, type RenameTypeValue, type RenameTypeValueFn, type RenameView, type RenameViewFn, type Reversible, type RevokeOnObjectsOptions, type RevokeOnSchemas, type RevokeOnSchemasOptions, type RevokeOnTables, type RevokeOnTablesOptions, type RevokeRoles, type RevokeRolesOptions, type RoleOptions, type RunnerOption, type SchemaPrivilege, type SequenceGeneratedOptions, type SequenceOptions, type SetTypeAttribute, type SomeTablesOptions, type Sql, type StorageParameters, type StringExtension, type TableOptions, type TablePrivilege, type TriggerOptions, type Type, type Value, type ViewOptions, type WithAdminOption, type WithGrantOption, escapeValue, isPgLiteral, jiti, runner };