postgrelize 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +269 -0
- package/LICENSE +21 -0
- package/README.md +131 -2
- package/dist/associations/association-accessors.d.ts +21 -0
- package/dist/associations/association-key-types.d.ts +44 -0
- package/dist/associations/association-keys.d.ts +98 -0
- package/dist/associations/association-lookup.d.ts +26 -0
- package/dist/associations/association-shape.d.ts +25 -0
- package/dist/associations/association.d.ts +95 -0
- package/dist/associations/belongs-to-many.d.ts +86 -0
- package/dist/associations/belongs-to.d.ts +45 -0
- package/dist/associations/has-many.d.ts +79 -0
- package/dist/associations/has-one.d.ts +44 -0
- package/dist/associations/include-assembler.d.ts +21 -0
- package/dist/associations/include-columns.d.ts +24 -0
- package/dist/associations/include-joins.d.ts +17 -0
- package/dist/associations/include-loader.d.ts +48 -0
- package/dist/associations/include-order.d.ts +22 -0
- package/dist/associations/include-query-builder.d.ts +54 -0
- package/dist/associations/include-resolver.d.ts +29 -0
- package/dist/associations/include-rows.d.ts +47 -0
- package/dist/associations/include-sub-query.d.ts +35 -0
- package/dist/associations/include.d.ts +112 -0
- package/dist/associations/junction-keys.d.ts +23 -0
- package/dist/associations/nested-creator.d.ts +44 -0
- package/dist/associations/nested-saver.d.ts +30 -0
- package/dist/associations/owner-keys.d.ts +34 -0
- package/dist/associations/separate-include-loader.d.ts +24 -0
- package/dist/associations/types.d.ts +139 -0
- package/dist/connection/connection-config.d.ts +33 -0
- package/dist/connection/connection-manager.d.ts +65 -0
- package/dist/connection/connection-types.d.ts +21 -0
- package/dist/connection/copy-from-stdin.d.ts +52 -0
- package/dist/connection/copy-runner.d.ts +30 -0
- package/dist/connection/copy-to-stdout.d.ts +49 -0
- package/dist/connection/copy.d.ts +22 -0
- package/dist/connection/notifications.d.ts +28 -0
- package/dist/connection/options.d.ts +158 -0
- package/dist/connection/query-logger.d.ts +41 -0
- package/dist/connection/replica-router.d.ts +20 -0
- package/dist/connection/statement-cache.d.ts +36 -0
- package/dist/connection/statement-timeout.d.ts +22 -0
- package/dist/data-types/abstract-data-type.d.ts +58 -0
- package/dist/data-types/array-literal-parser.d.ts +17 -0
- package/dist/data-types/array-type.d.ts +18 -0
- package/dist/data-types/bit-type.d.ts +14 -0
- package/dist/data-types/blob-type.d.ts +12 -0
- package/dist/data-types/char-type.d.ts +12 -0
- package/dist/data-types/composite-fields.d.ts +26 -0
- package/dist/data-types/composite-type.d.ts +32 -0
- package/dist/data-types/data-types.d.ts +172 -0
- package/dist/data-types/date-type.d.ts +14 -0
- package/dist/data-types/decimal-type.d.ts +13 -0
- package/dist/data-types/default-value-generator.d.ts +15 -0
- package/dist/data-types/enum-type.d.ts +19 -0
- package/dist/data-types/ewkb-reader.d.ts +18 -0
- package/dist/data-types/ewkb-writer.d.ts +17 -0
- package/dist/data-types/float-type.d.ts +12 -0
- package/dist/data-types/geometric-text.d.ts +65 -0
- package/dist/data-types/geometric-type.d.ts +46 -0
- package/dist/data-types/hstore-type.d.ts +16 -0
- package/dist/data-types/integer-type.d.ts +24 -0
- package/dist/data-types/json-type.d.ts +16 -0
- package/dist/data-types/multirange-type.d.ts +19 -0
- package/dist/data-types/range-type.d.ts +28 -0
- package/dist/data-types/record-text.d.ts +29 -0
- package/dist/data-types/scalar-type.d.ts +13 -0
- package/dist/data-types/spatial-type.d.ts +20 -0
- package/dist/data-types/string-type.d.ts +12 -0
- package/dist/data-types/text-type.d.ts +12 -0
- package/dist/data-types/timestamp-type.d.ts +15 -0
- package/dist/data-types/virtual-type.d.ts +15 -0
- package/dist/data-types/wall-clock.d.ts +14 -0
- package/dist/ddl/column-ddl.d.ts +73 -0
- package/dist/ddl/constraint-ddl.d.ts +30 -0
- package/dist/ddl/ddl-generator.d.ts +181 -0
- package/dist/ddl/ddl-guards.d.ts +60 -0
- package/dist/ddl/ddl-types.d.ts +193 -0
- package/dist/ddl/enum-ddl.d.ts +42 -0
- package/dist/ddl/extension-ddl.d.ts +57 -0
- package/dist/ddl/function-ddl.d.ts +98 -0
- package/dist/ddl/index-ddl.d.ts +29 -0
- package/dist/ddl/index-element-ddl.d.ts +19 -0
- package/dist/ddl/partition-ddl.d.ts +88 -0
- package/dist/ddl/partition-types.d.ts +94 -0
- package/dist/ddl/policy-ddl.d.ts +137 -0
- package/dist/ddl/routine-guards.d.ts +63 -0
- package/dist/ddl/sequence-ddl.d.ts +103 -0
- package/dist/ddl/sql-literal.d.ts +61 -0
- package/dist/ddl/table-ddl.d.ts +35 -0
- package/dist/ddl/trigger-ddl.d.ts +81 -0
- package/dist/ddl/view-ddl.d.ts +122 -0
- package/dist/decorators/association-applier.d.ts +18 -0
- package/dist/decorators/association-decorators.d.ts +72 -0
- package/dist/decorators/column-decorators.d.ts +147 -0
- package/dist/decorators/decorator-factory.d.ts +45 -0
- package/dist/decorators/decorator-signature.d.ts +26 -0
- package/dist/decorators/decorator-types.d.ts +24 -0
- package/dist/decorators/foreign-key-decorator.d.ts +21 -0
- package/dist/decorators/hook-decorators.d.ts +393 -0
- package/dist/decorators/init-arguments.d.ts +29 -0
- package/dist/decorators/model-decorators.d.ts +18 -0
- package/dist/decorators/model-metadata.d.ts +70 -0
- package/dist/decorators/table-decorators.d.ts +43 -0
- package/dist/decorators/timestamp-decorators.d.ts +38 -0
- package/dist/errors/base-error.d.ts +40 -0
- package/dist/errors/connection-errors.d.ts +152 -0
- package/dist/errors/database-errors.d.ts +152 -0
- package/dist/errors/errors.d.ts +5 -0
- package/dist/errors/map-pg-error.d.ts +27 -0
- package/dist/errors/misc-errors.d.ts +188 -0
- package/dist/errors/validation-errors.d.ts +117 -0
- package/dist/exports-core.d.ts +15 -0
- package/dist/exports-decorators.d.ts +8 -0
- package/dist/exports-errors.d.ts +2 -0
- package/dist/exports-model.d.ts +21 -0
- package/dist/exports-schema.d.ts +19 -0
- package/dist/expressions/call-expressions.d.ts +54 -0
- package/dist/expressions/condition-expressions.d.ts +51 -0
- package/dist/expressions/expression.d.ts +52 -0
- package/dist/expressions/jsonpath-helpers.d.ts +37 -0
- package/dist/expressions/methods.d.ts +188 -0
- package/dist/expressions/op.d.ts +182 -0
- package/dist/expressions/query-expressions.d.ts +110 -0
- package/dist/expressions/row-expressions.d.ts +35 -0
- package/dist/expressions/search-helpers.d.ts +138 -0
- package/dist/expressions/trigram-helpers.d.ts +40 -0
- package/dist/hooks/hooks.d.ts +125 -0
- package/dist/index.cjs +20461 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +20332 -0
- package/dist/index.js.map +1 -0
- package/dist/model/attribute-columns.d.ts +85 -0
- package/dist/model/attribute-normalizer.d.ts +42 -0
- package/dist/model/attribute-options.d.ts +121 -0
- package/dist/model/bulk-insert-builder.d.ts +24 -0
- package/dist/model/bulk-options.d.ts +173 -0
- package/dist/model/copy-options.d.ts +51 -0
- package/dist/model/cte-builder.d.ts +134 -0
- package/dist/model/definition-normalizer.d.ts +26 -0
- package/dist/model/delete-query-builder.d.ts +42 -0
- package/dist/model/find-options.d.ts +144 -0
- package/dist/model/find-query-builder.d.ts +38 -0
- package/dist/model/insert-query-builder.d.ts +41 -0
- package/dist/model/instance-destroyer.d.ts +44 -0
- package/dist/model/instance-lifecycle-services.d.ts +61 -0
- package/dist/model/instance-lifecycle.d.ts +128 -0
- package/dist/model/instance-saver.d.ts +25 -0
- package/dist/model/instance-state.d.ts +48 -0
- package/dist/model/instance-validation.d.ts +35 -0
- package/dist/model/instance-values.d.ts +80 -0
- package/dist/model/instance-writer.d.ts +59 -0
- package/dist/model/join-source-builder.d.ts +25 -0
- package/dist/model/lateral-keys-builder.d.ts +25 -0
- package/dist/model/merge-action-builder.d.ts +31 -0
- package/dist/model/merge-options.d.ts +72 -0
- package/dist/model/merge-query-builder.d.ts +29 -0
- package/dist/model/merge-source-builder.d.ts +22 -0
- package/dist/model/mixins/model-aggregates.d.ts +69 -0
- package/dist/model/mixins/model-associations.d.ts +73 -0
- package/dist/model/mixins/model-constructor.d.ts +7 -0
- package/dist/model/mixins/model-finders.d.ts +124 -0
- package/dist/model/mixins/model-hooks.d.ts +138 -0
- package/dist/model/mixins/model-postgres.d.ts +198 -0
- package/dist/model/mixins/model-schema-binding.d.ts +36 -0
- package/dist/model/mixins/model-schema.d.ts +55 -0
- package/dist/model/mixins/model-scopes.d.ts +57 -0
- package/dist/model/mixins/model-writers.d.ts +175 -0
- package/dist/model/mixins/named-hooks.d.ts +28 -0
- package/dist/model/model-accessors.d.ts +22 -0
- package/dist/model/model-base.d.ts +83 -0
- package/dist/model/model-definition.d.ts +130 -0
- package/dist/model/model-instance-persistence.d.ts +132 -0
- package/dist/model/model-instance-values.d.ts +154 -0
- package/dist/model/model-operations.d.ts +22 -0
- package/dist/model/model-registry.d.ts +139 -0
- package/dist/model/model-services.d.ts +46 -0
- package/dist/model/model-state.d.ts +60 -0
- package/dist/model/model-values.d.ts +86 -0
- package/dist/model/model.d.ts +560 -0
- package/dist/model/on-conflict-builder.d.ts +111 -0
- package/dist/model/operations/bulk-create-operation.d.ts +40 -0
- package/dist/model/operations/copy-from-source.d.ts +51 -0
- package/dist/model/operations/copy-operation.d.ts +54 -0
- package/dist/model/operations/count-operation.d.ts +52 -0
- package/dist/model/operations/create-operation.d.ts +31 -0
- package/dist/model/operations/destroy-operation.d.ts +65 -0
- package/dist/model/operations/find-cursor.d.ts +23 -0
- package/dist/model/operations/find-lookups.d.ts +89 -0
- package/dist/model/operations/find-operation.d.ts +47 -0
- package/dist/model/operations/increment-operation.d.ts +40 -0
- package/dist/model/operations/insert-operation.d.ts +71 -0
- package/dist/model/operations/merge-operation.d.ts +56 -0
- package/dist/model/operations/model-operation.d.ts +33 -0
- package/dist/model/operations/update-operation.d.ts +45 -0
- package/dist/model/operations/upsert-operation.d.ts +39 -0
- package/dist/model/options.d.ts +103 -0
- package/dist/model/returning-old.d.ts +52 -0
- package/dist/model/row-mapper.d.ts +78 -0
- package/dist/model/row-plan.d.ts +31 -0
- package/dist/model/runtime.d.ts +54 -0
- package/dist/model/scope-registry.d.ts +81 -0
- package/dist/model/select-aggregates.d.ts +37 -0
- package/dist/model/select-lock.d.ts +13 -0
- package/dist/model/select-options.d.ts +92 -0
- package/dist/model/select-query-builder.d.ts +73 -0
- package/dist/model/select-targets.d.ts +77 -0
- package/dist/model/source-option-builder.d.ts +23 -0
- package/dist/model/source-options.d.ts +108 -0
- package/dist/model/statement-builder.d.ts +77 -0
- package/dist/model/statement-services.d.ts +2 -0
- package/dist/model/sync-hooks.d.ts +18 -0
- package/dist/model/table-sample-builder.d.ts +13 -0
- package/dist/model/types.d.ts +85 -0
- package/dist/model/unnest-insert-builder.d.ts +24 -0
- package/dist/model/update-query-builder.d.ts +39 -0
- package/dist/model/v6-conflict-builder.d.ts +37 -0
- package/dist/model/value-cloner.d.ts +17 -0
- package/dist/model/values-writer.d.ts +12 -0
- package/dist/model/where-options.d.ts +164 -0
- package/dist/model/write-options.d.ts +160 -0
- package/dist/model/written-rows.d.ts +56 -0
- package/dist/query/query-result-shaper.d.ts +91 -0
- package/dist/query/raw-query.d.ts +27 -0
- package/dist/query-interface/alter-planner.d.ts +40 -0
- package/dist/query-interface/bulk-data.d.ts +44 -0
- package/dist/query-interface/column-commands.d.ts +52 -0
- package/dist/query-interface/column-describer.d.ts +17 -0
- package/dist/query-interface/enum-commands.d.ts +36 -0
- package/dist/query-interface/index-commands.d.ts +57 -0
- package/dist/query-interface/model-tables.d.ts +58 -0
- package/dist/query-interface/object-commands.d.ts +71 -0
- package/dist/query-interface/partition-commands.d.ts +43 -0
- package/dist/query-interface/policy-commands.d.ts +54 -0
- package/dist/query-interface/query-interface-objects.d.ts +108 -0
- package/dist/query-interface/query-interface-partitions.d.ts +66 -0
- package/dist/query-interface/query-interface-policies.d.ts +86 -0
- package/dist/query-interface/query-interface-routines.d.ts +120 -0
- package/dist/query-interface/query-interface-tables.d.ts +179 -0
- package/dist/query-interface/query-interface-types.d.ts +62 -0
- package/dist/query-interface/query-interface-views.d.ts +84 -0
- package/dist/query-interface/query-interface.d.ts +256 -0
- package/dist/query-interface/routine-commands.d.ts +71 -0
- package/dist/query-interface/schema-synchronizer.d.ts +99 -0
- package/dist/query-interface/statement-runner.d.ts +40 -0
- package/dist/query-interface/sync-planner.d.ts +26 -0
- package/dist/query-interface/table-commands.d.ts +63 -0
- package/dist/query-interface/table-introspector.d.ts +58 -0
- package/dist/query-interface/view-commands.d.ts +47 -0
- package/dist/sequelize/sequelize-base.d.ts +196 -0
- package/dist/sequelize/sequelize-constructor.d.ts +7 -0
- package/dist/sequelize/sequelize-hooks.d.ts +86 -0
- package/dist/sequelize/sequelize-internals.d.ts +87 -0
- package/dist/sequelize/sequelize-notifications.d.ts +66 -0
- package/dist/sequelize/sequelize-schema.d.ts +106 -0
- package/dist/sequelize/sequelize-transactions.d.ts +96 -0
- package/dist/sequelize.d.ts +790 -0
- package/dist/sql/ast-clauses.d.ts +137 -0
- package/dist/sql/ast-expressions.d.ts +88 -0
- package/dist/sql/ast-statements.d.ts +80 -0
- package/dist/sql/ast.d.ts +21 -0
- package/dist/sql/compile.d.ts +21 -0
- package/dist/sql/dml-compiler.d.ts +54 -0
- package/dist/sql/expression-compiler.d.ts +56 -0
- package/dist/sql/from-compiler.d.ts +39 -0
- package/dist/sql/identifier-quoter.d.ts +15 -0
- package/dist/sql/merge-compiler.d.ts +20 -0
- package/dist/sql/order.d.ts +15 -0
- package/dist/sql/query-compiler.d.ts +45 -0
- package/dist/sql/sql-chunks.d.ts +50 -0
- package/dist/sql/with-compiler.d.ts +19 -0
- package/dist/transaction/advisory-locks.d.ts +28 -0
- package/dist/transaction/transaction-constants.d.ts +35 -0
- package/dist/transaction/transaction-runner.d.ts +60 -0
- package/dist/transaction/transaction-starter.d.ts +25 -0
- package/dist/transaction/transaction-statements.d.ts +28 -0
- package/dist/transaction/transaction.d.ts +198 -0
- package/dist/validation/attribute-validators.d.ts +23 -0
- package/dist/validation/builtin-attribute-validator.d.ts +19 -0
- package/dist/validation/builtin-validators.d.ts +16 -0
- package/dist/validation/core-validator.d.ts +16 -0
- package/dist/validation/custom-validators.d.ts +13 -0
- package/dist/validation/instance-validator.d.ts +25 -0
- package/dist/validation/schema-items.d.ts +22 -0
- package/dist/validation/standard-schema-validator.d.ts +30 -0
- package/dist/validation/standard-schema.d.ts +39 -0
- package/dist/validation/types.d.ts +36 -0
- package/dist/validation/validation-target.d.ts +13 -0
- package/dist/where/comparison-compiler.d.ts +27 -0
- package/dist/where/condition-compiler.d.ts +18 -0
- package/dist/where/operand-resolver.d.ts +10 -0
- package/dist/where/operator-allowlist.d.ts +14 -0
- package/dist/where/where-support.d.ts +52 -0
- package/dist/where/where.d.ts +46 -0
- package/dist/where/window-compiler.d.ts +14 -0
- package/llm/USAGE.md +423 -0
- package/package.json +102 -4
- package/skills/postgrelize/SKILL.md +57 -0
- package/skills/postgrelize/reference/associations.md +108 -0
- package/skills/postgrelize/reference/errors.md +37 -0
- package/skills/postgrelize/reference/migrating-from-sequelize.md +15 -0
- package/skills/postgrelize/reference/postgresql-features.md +157 -0
- package/skills/postgrelize/reference/querying.md +111 -0
- package/skills/postgrelize/reference/schema.md +135 -0
- package/skills/postgrelize/reference/security.md +34 -0
- package/skills/postgrelize/reference/transactions-and-sessions.md +122 -0
- package/skills/postgrelize/reference/writing.md +198 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { TableName } from '../ddl/sql-literal.ts';
|
|
2
|
+
import { QueryOptionsBase } from '../model/runtime.ts';
|
|
3
|
+
import { StatementRunner } from './statement-runner.ts';
|
|
4
|
+
/**
|
|
5
|
+
* Bulk data methods of `QueryInterface` (seeders). Values are bound as parameters; `where` objects
|
|
6
|
+
* are keyed by column.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare class BulkData {
|
|
11
|
+
#private;
|
|
12
|
+
/**
|
|
13
|
+
* @param runner - Statement runner.
|
|
14
|
+
*/
|
|
15
|
+
constructor(runner: StatementRunner);
|
|
16
|
+
/**
|
|
17
|
+
* Inserts rows; missing values become `DEFAULT`.
|
|
18
|
+
*
|
|
19
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
20
|
+
* @param records - Rows keyed by column name.
|
|
21
|
+
* @param options - Query options.
|
|
22
|
+
* @returns Number of inserted rows.
|
|
23
|
+
*/
|
|
24
|
+
bulkInsert(table: TableName, records: readonly Readonly<Record<string, unknown>>[], options: QueryOptionsBase): Promise<number>;
|
|
25
|
+
/**
|
|
26
|
+
* Updates rows matching `where`.
|
|
27
|
+
*
|
|
28
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
29
|
+
* @param values - New column values.
|
|
30
|
+
* @param where - Filter.
|
|
31
|
+
* @param options - Query options.
|
|
32
|
+
* @returns Number of updated rows.
|
|
33
|
+
*/
|
|
34
|
+
bulkUpdate(table: TableName, values: Readonly<Record<string, unknown>>, where: unknown, options: QueryOptionsBase): Promise<number>;
|
|
35
|
+
/**
|
|
36
|
+
* Deletes rows matching `where`.
|
|
37
|
+
*
|
|
38
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
39
|
+
* @param where - Filter; empty deletes all rows.
|
|
40
|
+
* @param options - Query options.
|
|
41
|
+
* @returns Number of deleted rows.
|
|
42
|
+
*/
|
|
43
|
+
bulkDelete(table: TableName, where: unknown, options: QueryOptionsBase): Promise<number>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { DataTypeInput } from '../data-types/data-types.ts';
|
|
2
|
+
import { TableName } from '../ddl/sql-literal.ts';
|
|
3
|
+
import { AttributeOptions } from '../model/model-definition.ts';
|
|
4
|
+
import { QueryOptionsBase } from '../model/runtime.ts';
|
|
5
|
+
import { StatementRunner } from './statement-runner.ts';
|
|
6
|
+
/**
|
|
7
|
+
* Column DDL of `QueryInterface`: add, remove, change and rename. Names are quoted identifiers.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare class ColumnCommands {
|
|
12
|
+
#private;
|
|
13
|
+
/**
|
|
14
|
+
* @param runner - Statement runner.
|
|
15
|
+
*/
|
|
16
|
+
constructor(runner: StatementRunner);
|
|
17
|
+
/**
|
|
18
|
+
* Adds a column and its enum type and comment.
|
|
19
|
+
*
|
|
20
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
21
|
+
* @param column - Column name.
|
|
22
|
+
* @param attribute - Column definition.
|
|
23
|
+
* @param options - Query options.
|
|
24
|
+
*/
|
|
25
|
+
addColumn(table: TableName, column: string, attribute: DataTypeInput | AttributeOptions, options?: QueryOptionsBase): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Removes a column.
|
|
28
|
+
*
|
|
29
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
30
|
+
* @param column - Column name.
|
|
31
|
+
* @param options - Query options.
|
|
32
|
+
*/
|
|
33
|
+
removeColumn(table: TableName, column: string, options?: QueryOptionsBase): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Changes type, nullability, default and comment of a column.
|
|
36
|
+
*
|
|
37
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
38
|
+
* @param column - Column name.
|
|
39
|
+
* @param attribute - New column definition.
|
|
40
|
+
* @param options - Query options.
|
|
41
|
+
*/
|
|
42
|
+
changeColumn(table: TableName, column: string, attribute: DataTypeInput | AttributeOptions, options?: QueryOptionsBase): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Renames a column.
|
|
45
|
+
*
|
|
46
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
47
|
+
* @param before - Current column name.
|
|
48
|
+
* @param after - New column name.
|
|
49
|
+
* @param options - Query options.
|
|
50
|
+
*/
|
|
51
|
+
renameColumn(table: TableName, before: string, after: string, options?: QueryOptionsBase): Promise<void>;
|
|
52
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ColumnDescription } from './query-interface-types.ts';
|
|
2
|
+
import { StatementRows } from './statement-runner.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Converts `describeTable` catalog rows into Sequelize v6 column descriptions.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare class ColumnDescriber {
|
|
9
|
+
#private;
|
|
10
|
+
/**
|
|
11
|
+
* Column descriptions keyed by column name.
|
|
12
|
+
*
|
|
13
|
+
* @param rows - Rows of the `describeTable` query.
|
|
14
|
+
* @returns Column descriptions.
|
|
15
|
+
*/
|
|
16
|
+
describe(rows: StatementRows): Record<string, ColumnDescription>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { TableName } from '../ddl/sql-literal.ts';
|
|
2
|
+
import { QueryOptionsBase } from '../model/runtime.ts';
|
|
3
|
+
import { StatementRunner } from './statement-runner.ts';
|
|
4
|
+
/**
|
|
5
|
+
* Enum type DDL of `QueryInterface`. Lookups filter by schema; names are quoted identifiers.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare class EnumCommands {
|
|
10
|
+
#private;
|
|
11
|
+
/**
|
|
12
|
+
* @param runner - Statement runner.
|
|
13
|
+
*/
|
|
14
|
+
constructor(runner: StatementRunner);
|
|
15
|
+
/**
|
|
16
|
+
* Drops an enum type.
|
|
17
|
+
*
|
|
18
|
+
* @param name - Enum type name.
|
|
19
|
+
* @param options - Query options.
|
|
20
|
+
*/
|
|
21
|
+
dropEnum(name: string, options?: QueryOptionsBase): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Drops all enum types of the current schema.
|
|
24
|
+
*
|
|
25
|
+
* @param options - Query options.
|
|
26
|
+
*/
|
|
27
|
+
dropAllEnums(options?: QueryOptionsBase): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Drops the enum types of table columns.
|
|
30
|
+
*
|
|
31
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
32
|
+
* @param fields - Enum column names.
|
|
33
|
+
* @param options - Query options.
|
|
34
|
+
*/
|
|
35
|
+
dropEnumsOf(table: TableName, fields: readonly string[], options?: QueryOptionsBase): Promise<void>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ConstraintOptions, IndexField, IndexOptions } from '../ddl/ddl-generator.ts';
|
|
2
|
+
import { TableName } from '../ddl/sql-literal.ts';
|
|
3
|
+
import { QueryOptionsBase } from '../model/runtime.ts';
|
|
4
|
+
import { StatementRunner } from './statement-runner.ts';
|
|
5
|
+
/**
|
|
6
|
+
* Index and constraint DDL of `QueryInterface`. Names are quoted identifiers.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare class IndexCommands {
|
|
11
|
+
#private;
|
|
12
|
+
/**
|
|
13
|
+
* @param runner - Statement runner.
|
|
14
|
+
*/
|
|
15
|
+
constructor(runner: StatementRunner);
|
|
16
|
+
/**
|
|
17
|
+
* Creates an index.
|
|
18
|
+
*
|
|
19
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
20
|
+
* @param fieldsOrOptions - Indexed fields or index options.
|
|
21
|
+
* @param options - Index options when fields are given separately.
|
|
22
|
+
*/
|
|
23
|
+
addIndex(table: TableName, fieldsOrOptions: readonly IndexField[] | IndexOptions, options: IndexOptions & QueryOptionsBase): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Drops an index by name or by its fields (default name).
|
|
26
|
+
*
|
|
27
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
28
|
+
* @param nameOrFields - Index name or indexed fields.
|
|
29
|
+
* @param options - `concurrently` and query options.
|
|
30
|
+
*/
|
|
31
|
+
removeIndex(table: TableName, nameOrFields: string | readonly IndexField[], options: QueryOptionsBase & Readonly<{
|
|
32
|
+
concurrently?: boolean;
|
|
33
|
+
}>): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Adds a constraint.
|
|
36
|
+
*
|
|
37
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
38
|
+
* @param options - Constraint definition.
|
|
39
|
+
*/
|
|
40
|
+
addConstraint(table: TableName, options: ConstraintOptions & QueryOptionsBase): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Drops a constraint.
|
|
43
|
+
*
|
|
44
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
45
|
+
* @param name - Constraint name.
|
|
46
|
+
* @param options - Query options.
|
|
47
|
+
*/
|
|
48
|
+
removeConstraint(table: TableName, name: string, options?: QueryOptionsBase): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Validates a `NOT VALID` constraint.
|
|
51
|
+
*
|
|
52
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
53
|
+
* @param name - Constraint name.
|
|
54
|
+
* @param options - Query options.
|
|
55
|
+
*/
|
|
56
|
+
validateConstraint(table: TableName, name: string, options?: QueryOptionsBase): Promise<void>;
|
|
57
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ColumnDefinition } from '../ddl/ddl-generator.ts';
|
|
2
|
+
import { TableName } from '../ddl/sql-literal.ts';
|
|
3
|
+
import { ModelDefinition } from '../model/model-definition.ts';
|
|
4
|
+
/**
|
|
5
|
+
* Table, column, index and foreign key DDL derived from a model definition for `sync()`.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare class ModelTables {
|
|
10
|
+
#private;
|
|
11
|
+
/**
|
|
12
|
+
* The definition moved to another schema (the `schema` option of `sync()` / `drop()`).
|
|
13
|
+
*
|
|
14
|
+
* @param definition - Model definition.
|
|
15
|
+
* @param schema - Target schema, or undefined to keep the model's.
|
|
16
|
+
* @returns Definition in the schema.
|
|
17
|
+
*/
|
|
18
|
+
inSchema(definition: ModelDefinition, schema: string | undefined): ModelDefinition;
|
|
19
|
+
/**
|
|
20
|
+
* Table reference of a definition.
|
|
21
|
+
*
|
|
22
|
+
* @param definition - Model definition.
|
|
23
|
+
* @returns Table name or `{ tableName, schema }`.
|
|
24
|
+
*/
|
|
25
|
+
tableOf(definition: ModelDefinition): TableName;
|
|
26
|
+
/**
|
|
27
|
+
* Columns stored in the table (virtual attributes excluded).
|
|
28
|
+
*
|
|
29
|
+
* @param definition - Model definition.
|
|
30
|
+
* @returns Column definitions.
|
|
31
|
+
*/
|
|
32
|
+
storedColumns(definition: ModelDefinition): readonly ColumnDefinition[];
|
|
33
|
+
/**
|
|
34
|
+
* `CREATE TABLE` (and enum types) of a definition; deferred columns lose their foreign keys.
|
|
35
|
+
*
|
|
36
|
+
* @param definition - Model definition.
|
|
37
|
+
* @param deferred - Columns created without their foreign keys.
|
|
38
|
+
* @param schema - `schema` option of `sync()`.
|
|
39
|
+
* @returns Statements.
|
|
40
|
+
*/
|
|
41
|
+
createStatements(definition: ModelDefinition, deferred: readonly string[], schema: string | undefined): readonly string[];
|
|
42
|
+
/**
|
|
43
|
+
* `CREATE INDEX IF NOT EXISTS` of the model indexes, attribute names mapped to fields.
|
|
44
|
+
*
|
|
45
|
+
* @param definition - Model definition.
|
|
46
|
+
* @returns Statements.
|
|
47
|
+
*/
|
|
48
|
+
indexStatements(definition: ModelDefinition): readonly string[];
|
|
49
|
+
/**
|
|
50
|
+
* `ALTER TABLE ... ADD FOREIGN KEY` of a column.
|
|
51
|
+
*
|
|
52
|
+
* @param qualified - Quoted table name.
|
|
53
|
+
* @param column - Column with `references`.
|
|
54
|
+
* @param schema - `schema` option of `sync()`.
|
|
55
|
+
* @returns Statement.
|
|
56
|
+
*/
|
|
57
|
+
foreignKeySql(qualified: string, column: ColumnDefinition, schema: string | undefined): string;
|
|
58
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { CreateExtensionOptions, DropExtensionOptions } from '../ddl/extension-ddl.ts';
|
|
2
|
+
import { AlterSequenceOptions, CreateSequenceOptions, DropSequenceOptions, SequenceNumber } from '../ddl/sequence-ddl.ts';
|
|
3
|
+
import { TableName } from '../ddl/sql-literal.ts';
|
|
4
|
+
import { QueryOptionsBase } from '../model/runtime.ts';
|
|
5
|
+
import { StatementRunner } from './statement-runner.ts';
|
|
6
|
+
/**
|
|
7
|
+
* Extension and sequence DDL of `QueryInterface`. Names are quoted identifiers; sequence numbers
|
|
8
|
+
* are validated integers; `nextval` / `setval` bind everything.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare class ObjectCommands {
|
|
13
|
+
#private;
|
|
14
|
+
/**
|
|
15
|
+
* @param runner - Statement runner.
|
|
16
|
+
*/
|
|
17
|
+
constructor(runner: StatementRunner);
|
|
18
|
+
/**
|
|
19
|
+
* Runs `CREATE EXTENSION`.
|
|
20
|
+
*
|
|
21
|
+
* @param name - Extension name.
|
|
22
|
+
* @param options - Statement and query options.
|
|
23
|
+
*/
|
|
24
|
+
createExtension(name: string, options: CreateExtensionOptions & QueryOptionsBase): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Runs `DROP EXTENSION`.
|
|
27
|
+
*
|
|
28
|
+
* @param name - Extension name.
|
|
29
|
+
* @param options - Statement and query options.
|
|
30
|
+
*/
|
|
31
|
+
dropExtension(name: string, options: DropExtensionOptions & QueryOptionsBase): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Runs `CREATE SEQUENCE`.
|
|
34
|
+
*
|
|
35
|
+
* @param name - Sequence name.
|
|
36
|
+
* @param options - Sequence and query options.
|
|
37
|
+
*/
|
|
38
|
+
createSequence(name: TableName, options: CreateSequenceOptions & QueryOptionsBase): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Runs `ALTER SEQUENCE`.
|
|
41
|
+
*
|
|
42
|
+
* @param name - Sequence name.
|
|
43
|
+
* @param options - Properties to change and query options.
|
|
44
|
+
*/
|
|
45
|
+
alterSequence(name: TableName, options: AlterSequenceOptions & QueryOptionsBase): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Runs `DROP SEQUENCE`.
|
|
48
|
+
*
|
|
49
|
+
* @param name - Sequence name.
|
|
50
|
+
* @param options - Statement and query options.
|
|
51
|
+
*/
|
|
52
|
+
dropSequence(name: TableName, options: DropSequenceOptions & QueryOptionsBase): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Advances a sequence and returns the new value.
|
|
55
|
+
*
|
|
56
|
+
* @param name - Sequence name.
|
|
57
|
+
* @param options - Query options.
|
|
58
|
+
* @returns Value as text (bigint safe).
|
|
59
|
+
*/
|
|
60
|
+
nextval(name: TableName, options: QueryOptionsBase): Promise<string>;
|
|
61
|
+
/**
|
|
62
|
+
* Sets the current value of a sequence.
|
|
63
|
+
*
|
|
64
|
+
* @param name - Sequence name.
|
|
65
|
+
* @param value - New value.
|
|
66
|
+
* @param isCalled - `false` makes the next `nextval` return `value` itself.
|
|
67
|
+
* @param options - Query options.
|
|
68
|
+
* @returns The value set, as text.
|
|
69
|
+
*/
|
|
70
|
+
setval(name: TableName, value: SequenceNumber, isCalled: boolean, options: QueryOptionsBase): Promise<string>;
|
|
71
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CreatePartitionOptions, DetachPartitionOptions } from '../ddl/partition-ddl.ts';
|
|
2
|
+
import { PartitionBoundSpec } from '../ddl/partition-types.ts';
|
|
3
|
+
import { TableName } from '../ddl/sql-literal.ts';
|
|
4
|
+
import { QueryOptionsBase } from '../model/runtime.ts';
|
|
5
|
+
import { StatementRunner } from './statement-runner.ts';
|
|
6
|
+
/**
|
|
7
|
+
* Declarative partitioning DDL of `QueryInterface`. Names are quoted, bound values are literals.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare class PartitionCommands {
|
|
12
|
+
#private;
|
|
13
|
+
/**
|
|
14
|
+
* @param runner - Statement runner.
|
|
15
|
+
*/
|
|
16
|
+
constructor(runner: StatementRunner);
|
|
17
|
+
/**
|
|
18
|
+
* Runs `CREATE TABLE ... PARTITION OF`.
|
|
19
|
+
*
|
|
20
|
+
* @param parent - Partitioned table.
|
|
21
|
+
* @param partition - New partition.
|
|
22
|
+
* @param bound - Bounds.
|
|
23
|
+
* @param options - Partition and query options.
|
|
24
|
+
*/
|
|
25
|
+
create(parent: TableName, partition: TableName, bound: PartitionBoundSpec, options: CreatePartitionOptions & QueryOptionsBase): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Runs `ALTER TABLE ... ATTACH PARTITION`.
|
|
28
|
+
*
|
|
29
|
+
* @param parent - Partitioned table.
|
|
30
|
+
* @param partition - Existing table.
|
|
31
|
+
* @param bound - Bounds.
|
|
32
|
+
* @param options - Query options.
|
|
33
|
+
*/
|
|
34
|
+
attach(parent: TableName, partition: TableName, bound: PartitionBoundSpec, options: QueryOptionsBase): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Runs `ALTER TABLE ... DETACH PARTITION`.
|
|
37
|
+
*
|
|
38
|
+
* @param parent - Partitioned table.
|
|
39
|
+
* @param partition - Partition.
|
|
40
|
+
* @param options - Detach and query options.
|
|
41
|
+
*/
|
|
42
|
+
detach(parent: TableName, partition: TableName, options: DetachPartitionOptions & QueryOptionsBase): Promise<void>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AlterPolicyOptions, CreatePolicyOptions, DisableRowLevelSecurityOptions, DropPolicyOptions, EnableRowLevelSecurityOptions } from '../ddl/policy-ddl.ts';
|
|
2
|
+
import { TableName } from '../ddl/sql-literal.ts';
|
|
3
|
+
import { QueryOptionsBase } from '../model/runtime.ts';
|
|
4
|
+
import { StatementRunner } from './statement-runner.ts';
|
|
5
|
+
/**
|
|
6
|
+
* Row-level security DDL of `QueryInterface`. Names are quoted; string conditions are trusted SQL.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare class PolicyCommands {
|
|
11
|
+
#private;
|
|
12
|
+
/**
|
|
13
|
+
* @param runner - Statement runner.
|
|
14
|
+
*/
|
|
15
|
+
constructor(runner: StatementRunner);
|
|
16
|
+
/**
|
|
17
|
+
* Runs `ENABLE ROW LEVEL SECURITY`.
|
|
18
|
+
*
|
|
19
|
+
* @param table - Table.
|
|
20
|
+
* @param options - Statement and query options.
|
|
21
|
+
*/
|
|
22
|
+
enable(table: TableName, options: EnableRowLevelSecurityOptions & QueryOptionsBase): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Runs `DISABLE ROW LEVEL SECURITY`.
|
|
25
|
+
*
|
|
26
|
+
* @param table - Table.
|
|
27
|
+
* @param options - Statement and query options.
|
|
28
|
+
*/
|
|
29
|
+
disable(table: TableName, options: DisableRowLevelSecurityOptions & QueryOptionsBase): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Runs `CREATE POLICY`.
|
|
32
|
+
*
|
|
33
|
+
* @param table - Table.
|
|
34
|
+
* @param name - Policy name.
|
|
35
|
+
* @param options - Policy and query options.
|
|
36
|
+
*/
|
|
37
|
+
create(table: TableName, name: string, options: CreatePolicyOptions & QueryOptionsBase): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Runs `ALTER POLICY`.
|
|
40
|
+
*
|
|
41
|
+
* @param table - Table.
|
|
42
|
+
* @param name - Policy name.
|
|
43
|
+
* @param options - Changes and query options.
|
|
44
|
+
*/
|
|
45
|
+
alter(table: TableName, name: string, options: AlterPolicyOptions & QueryOptionsBase): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Runs `DROP POLICY`.
|
|
48
|
+
*
|
|
49
|
+
* @param table - Table.
|
|
50
|
+
* @param name - Policy name.
|
|
51
|
+
* @param options - Statement and query options.
|
|
52
|
+
*/
|
|
53
|
+
drop(table: TableName, name: string, options: DropPolicyOptions & QueryOptionsBase): Promise<void>;
|
|
54
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { CreateExtensionOptions, DropExtensionOptions } from '../ddl/extension-ddl.ts';
|
|
2
|
+
import { AlterSequenceOptions, CreateSequenceOptions, DropSequenceOptions, SequenceNumber } from '../ddl/sequence-ddl.ts';
|
|
3
|
+
import { TableName } from '../ddl/sql-literal.ts';
|
|
4
|
+
import { QueryOptionsBase, RuntimeOwner } from '../model/runtime.ts';
|
|
5
|
+
import { QueryInterfaceTables } from './query-interface-tables.ts';
|
|
6
|
+
/**
|
|
7
|
+
* Schema object part of {@link QueryInterface}: extensions and sequences.
|
|
8
|
+
*/
|
|
9
|
+
export declare class QueryInterfaceObjects extends QueryInterfaceTables {
|
|
10
|
+
#private;
|
|
11
|
+
/**
|
|
12
|
+
* @param sequelize - Owning `Sequelize` instance.
|
|
13
|
+
*/
|
|
14
|
+
constructor(sequelize: RuntimeOwner);
|
|
15
|
+
/**
|
|
16
|
+
* Installs an extension with `CREATE EXTENSION`. Needs the privileges PostgreSQL requires for that extension (superuser or a trusted extension).
|
|
17
|
+
*
|
|
18
|
+
* @param name - Extension name, quoted as an identifier.
|
|
19
|
+
* @param options - `ifNotExists`, `schema`, `version`, `cascade` and query options.
|
|
20
|
+
* @throws DatabaseError when the extension is not available on the server or the role may not install it.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* await queryInterface.createExtension('pg_trgm', { ifNotExists: true });
|
|
25
|
+
* ```
|
|
26
|
+
* @see [Schema guide](/guide/schema)
|
|
27
|
+
*/
|
|
28
|
+
createExtension(name: string, options?: CreateExtensionOptions & QueryOptionsBase): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Removes an extension with `DROP EXTENSION`.
|
|
31
|
+
*
|
|
32
|
+
* @param name - Extension name.
|
|
33
|
+
* @param options - `ifExists`, `cascade` and query options.
|
|
34
|
+
* @throws DatabaseError when objects depend on the extension and `cascade` is not set.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* await queryInterface.dropExtension('pg_trgm', { ifExists: true });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
dropExtension(name: string, options?: DropExtensionOptions & QueryOptionsBase): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Creates a sequence with `CREATE SEQUENCE`. Numbers must be whole (`number` or `bigint`).
|
|
44
|
+
*
|
|
45
|
+
* @param name - Sequence name or `{ tableName, schema }`.
|
|
46
|
+
* @param options - Sequence properties and query options.
|
|
47
|
+
* @throws Error for an unknown `dataType` or a non-integer number.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* await queryInterface.createSequence('invoice_number', { start: 1000, increment: 1, cache: 10 });
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
createSequence(name: TableName, options?: CreateSequenceOptions & QueryOptionsBase): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Changes a sequence with `ALTER SEQUENCE`.
|
|
57
|
+
*
|
|
58
|
+
* @param name - Sequence name or `{ tableName, schema }`.
|
|
59
|
+
* @param options - Properties to change (at least one) and query options.
|
|
60
|
+
* @throws Error when no property is given or a number is not whole.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* await queryInterface.alterSequence('invoice_number', { restartWith: 5000, cycle: false });
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
alterSequence(name: TableName, options?: AlterSequenceOptions & QueryOptionsBase): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Drops a sequence with `DROP SEQUENCE`.
|
|
70
|
+
*
|
|
71
|
+
* @param name - Sequence name or `{ tableName, schema }`.
|
|
72
|
+
* @param options - `ifExists`, `cascade` and query options.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* await queryInterface.dropSequence('invoice_number', { ifExists: true });
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
dropSequence(name: TableName, options?: DropSequenceOptions & QueryOptionsBase): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Advances a sequence and returns the new value (`SELECT nextval(...)`; the name is bound).
|
|
82
|
+
*
|
|
83
|
+
* @param name - Sequence name or `{ tableName, schema }`.
|
|
84
|
+
* @param options - Query options.
|
|
85
|
+
* @returns The value as text, so bigint values stay exact.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* const next = await queryInterface.nextval('invoice_number');
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
nextval(name: TableName, options?: QueryOptionsBase): Promise<string>;
|
|
93
|
+
/**
|
|
94
|
+
* Sets the current value of a sequence (`SELECT setval(...)`; name and value are bound).
|
|
95
|
+
*
|
|
96
|
+
* @param name - Sequence name or `{ tableName, schema }`.
|
|
97
|
+
* @param value - New value (`number` or `bigint`).
|
|
98
|
+
* @param isCalled - `true` (default): the next `nextval` returns `value + increment`; `false`: it returns `value`.
|
|
99
|
+
* @param options - Query options.
|
|
100
|
+
* @returns The value set, as text.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* await queryInterface.setval('invoice_number', 9000, false);
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
setval(name: TableName, value: SequenceNumber, isCalled?: boolean, options?: QueryOptionsBase): Promise<string>;
|
|
108
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { CreatePartitionOptions, DetachPartitionOptions } from '../ddl/partition-ddl.ts';
|
|
2
|
+
import { PartitionBoundSpec } from '../ddl/partition-types.ts';
|
|
3
|
+
import { TableName } from '../ddl/sql-literal.ts';
|
|
4
|
+
import { QueryOptionsBase, RuntimeOwner } from '../model/runtime.ts';
|
|
5
|
+
import { QueryInterfacePolicies } from './query-interface-policies.ts';
|
|
6
|
+
/**
|
|
7
|
+
* Declarative partitioning part of {@link QueryInterface}.
|
|
8
|
+
*/
|
|
9
|
+
export declare class QueryInterfacePartitions extends QueryInterfacePolicies {
|
|
10
|
+
#private;
|
|
11
|
+
/**
|
|
12
|
+
* @param sequelize - Owning `Sequelize` instance.
|
|
13
|
+
*/
|
|
14
|
+
constructor(sequelize: RuntimeOwner);
|
|
15
|
+
/**
|
|
16
|
+
* Creates a partition of a partitioned table (`CREATE TABLE ... PARTITION OF`). The partitioned parent comes from `createTable` with `partitionBy`.
|
|
17
|
+
*
|
|
18
|
+
* @param parent - Partitioned table name or `{ tableName, schema }`.
|
|
19
|
+
* @param partition - New partition name or `{ tableName, schema }`.
|
|
20
|
+
* @param bound - `{ in }` (list), `{ from, to }` (range), `{ modulus, remainder }` (hash) or `{ default: true }`; values are rendered as literals.
|
|
21
|
+
* @param options - `partitionBy` (sub-partitioning), `ifNotExists` and query options.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* await queryInterface.createTable('events', { at: DataTypes.DATE }, {
|
|
26
|
+
* partitionBy: { strategy: 'range', columns: ['at'] },
|
|
27
|
+
* });
|
|
28
|
+
* await queryInterface.createPartition('events', 'events_2026', {
|
|
29
|
+
* from: ['2026-01-01'],
|
|
30
|
+
* to: ['2027-01-01'],
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
* @see [Constraints and indexes guide](/guide/constraints-indexes)
|
|
34
|
+
*/
|
|
35
|
+
createPartition(parent: TableName, partition: TableName, bound: PartitionBoundSpec, options?: CreatePartitionOptions & QueryOptionsBase): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Attaches an existing table as a partition (`ALTER TABLE ... ATTACH PARTITION`). PostgreSQL scans the table to check the bounds unless a matching `CHECK` constraint exists.
|
|
38
|
+
*
|
|
39
|
+
* @param parent - Partitioned table name or `{ tableName, schema }`.
|
|
40
|
+
* @param partition - Existing table name or `{ tableName, schema }`.
|
|
41
|
+
* @param bound - Partition bounds, see {@link QueryInterface.createPartition}.
|
|
42
|
+
* @param options - Query options.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* await queryInterface.attachPartition('events', 'events_2027', {
|
|
47
|
+
* from: ['2027-01-01'],
|
|
48
|
+
* to: ['2028-01-01'],
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
attachPartition(parent: TableName, partition: TableName, bound: PartitionBoundSpec, options?: QueryOptionsBase): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Detaches a partition, keeping it as a standalone table (`ALTER TABLE ... DETACH PARTITION`).
|
|
55
|
+
*
|
|
56
|
+
* @param parent - Partitioned table name or `{ tableName, schema }`.
|
|
57
|
+
* @param partition - Partition name or `{ tableName, schema }`.
|
|
58
|
+
* @param options - `concurrently` (PostgreSQL 14+, not inside a transaction), `finalize` and query options.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* await queryInterface.detachPartition('events', 'events_2026', { concurrently: true });
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
detachPartition(parent: TableName, partition: TableName, options?: DetachPartitionOptions & QueryOptionsBase): Promise<void>;
|
|
66
|
+
}
|