postgrelize 0.0.0-stage → 1.1.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 +289 -0
- package/LICENSE +21 -0
- package/README.md +131 -2
- package/dist/associations/alias-minifier.d.ts +43 -0
- 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/after-connect-hook.d.ts +24 -0
- package/dist/connection/connect-hooks.d.ts +26 -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 +165 -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 +176 -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 +204 -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 +186 -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 +232 -0
- package/dist/errors/validation-errors.d.ts +141 -0
- package/dist/exports-associations.d.ts +6 -0
- package/dist/exports-core.d.ts +95 -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/logic.d.ts +25 -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 +21864 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +21688 -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/inflector.d.ts +28 -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 +88 -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 +113 -0
- package/dist/model/mixins/model-constructor.d.ts +7 -0
- package/dist/model/mixins/model-finders.d.ts +140 -0
- package/dist/model/mixins/model-hooks.d.ts +142 -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 +100 -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 +197 -0
- package/dist/model/model-operations.d.ts +22 -0
- package/dist/model/model-registry.d.ts +152 -0
- package/dist/model/model-services.d.ts +46 -0
- package/dist/model/model-state.d.ts +68 -0
- package/dist/model/model-values.d.ts +86 -0
- package/dist/model/model.d.ts +629 -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 +99 -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 +56 -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/package-version.d.ts +8 -0
- package/dist/query/query-result-shaper.d.ts +93 -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-catalog.d.ts +180 -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 +110 -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/instance-hook-adders.d.ts +72 -0
- package/dist/sequelize/sequelize-base.d.ts +196 -0
- package/dist/sequelize/sequelize-constructor.d.ts +7 -0
- package/dist/sequelize/sequelize-helpers.d.ts +133 -0
- package/dist/sequelize/sequelize-hooks.d.ts +99 -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 +125 -0
- package/dist/sequelize/sequelize-transactions.d.ts +96 -0
- package/dist/sequelize.d.ts +1175 -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/cls-namespace.d.ts +44 -0
- package/dist/transaction/transaction-constants.d.ts +35 -0
- package/dist/transaction/transaction-runner.d.ts +78 -0
- package/dist/transaction/transaction-starter.d.ts +25 -0
- package/dist/transaction/transaction-statements.d.ts +29 -0
- package/dist/transaction/transaction.d.ts +201 -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 +103 -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,180 @@
|
|
|
1
|
+
import { DeferrableValue } from '../ddl/ddl-types.ts';
|
|
2
|
+
import { TableName } from '../ddl/sql-literal.ts';
|
|
3
|
+
import { Transaction } from '../transaction/transaction.ts';
|
|
4
|
+
import { QueryOptionsBase, RuntimeOwner } from '../model/runtime.ts';
|
|
5
|
+
import { QueryInterfacePartitions } from './query-interface-partitions.ts';
|
|
6
|
+
import { ColumnDescription } from './query-interface-types.ts';
|
|
7
|
+
/** One column of an index in {@link IndexDescription}. */
|
|
8
|
+
export type IndexColumn = Readonly<{
|
|
9
|
+
/** Column name. */
|
|
10
|
+
attribute: string;
|
|
11
|
+
/** `COLLATE` of the index column, when set. */
|
|
12
|
+
collate: string | undefined;
|
|
13
|
+
/** `ASC` or `DESC` when the index column states it. */
|
|
14
|
+
order: 'ASC' | 'DESC' | undefined;
|
|
15
|
+
/** Always `undefined` (v6 field for MySQL prefix lengths). */
|
|
16
|
+
length: undefined;
|
|
17
|
+
}>;
|
|
18
|
+
/** One index of a table as returned by {@link QueryInterface.showIndex} (Sequelize v6 shape). */
|
|
19
|
+
export type IndexDescription = Readonly<{
|
|
20
|
+
/** Index name. */
|
|
21
|
+
name: string;
|
|
22
|
+
/** Whether it backs the primary key. */
|
|
23
|
+
primary: boolean;
|
|
24
|
+
/** Whether it is unique. */
|
|
25
|
+
unique: boolean;
|
|
26
|
+
/** Column numbers, space separated (`pg_index.indkey`). */
|
|
27
|
+
indkey: string;
|
|
28
|
+
/** `CREATE INDEX` statement of the index. */
|
|
29
|
+
definition: string;
|
|
30
|
+
/** Indexed columns in order, without expression columns. */
|
|
31
|
+
fields: readonly IndexColumn[];
|
|
32
|
+
}>;
|
|
33
|
+
/** Options of {@link QueryInterface.createDatabase}. */
|
|
34
|
+
export type CreateDatabaseOptions = QueryOptionsBase & Readonly<{
|
|
35
|
+
/** `ENCODING`, e.g. `'UTF8'`. */
|
|
36
|
+
encoding?: string;
|
|
37
|
+
/** `LC_COLLATE`. */
|
|
38
|
+
collate?: string;
|
|
39
|
+
/** `LC_CTYPE`. */
|
|
40
|
+
ctype?: string;
|
|
41
|
+
/** `TEMPLATE` database. */
|
|
42
|
+
template?: string;
|
|
43
|
+
}>;
|
|
44
|
+
type Row = Readonly<Record<string, unknown>>;
|
|
45
|
+
/**
|
|
46
|
+
* Catalog helpers of {@link QueryInterface}: indexes, constraints, database creation, identifier quoting and
|
|
47
|
+
* a few Sequelize v6 convenience lookups.
|
|
48
|
+
*/
|
|
49
|
+
export declare class QueryInterfaceCatalog extends QueryInterfacePartitions {
|
|
50
|
+
#private;
|
|
51
|
+
/**
|
|
52
|
+
* @param sequelize - Owning `Sequelize` instance.
|
|
53
|
+
*/
|
|
54
|
+
constructor(sequelize: RuntimeOwner);
|
|
55
|
+
/**
|
|
56
|
+
* Lists the indexes of a table, with their columns, uniqueness and definition.
|
|
57
|
+
*
|
|
58
|
+
* @param table - Table name or `{ tableName, schema }`; `current_schema()` when no schema is given.
|
|
59
|
+
* @param options - Query options.
|
|
60
|
+
* @returns One entry per index, ordered by name.
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* const indexes = await queryInterface.showIndex('users');
|
|
64
|
+
* const unique = indexes.filter((index) => index.unique).map((index) => index.name);
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
showIndex(table: TableName, options?: QueryOptionsBase): Promise<IndexDescription[]>;
|
|
68
|
+
/**
|
|
69
|
+
* Lists the constraints of a table (`information_schema.table_constraints`), optionally one by name.
|
|
70
|
+
*
|
|
71
|
+
* @param table - Table name or `{ tableName, schema }`; `current_schema()` when no schema is given.
|
|
72
|
+
* @param constraintName - Only this constraint. Sequelize v6 ignores it for PostgreSQL and lists all.
|
|
73
|
+
* @param options - Query options.
|
|
74
|
+
* @returns Constraint rows (`constraintName`, `constraintType`, `isDeferrable`, ...), ordered by name.
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* const constraints = await queryInterface.showConstraint('users');
|
|
78
|
+
* const names = constraints.map((constraint) => constraint.constraintName);
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
showConstraint(table: TableName, constraintName?: string | null, options?: QueryOptionsBase): Promise<Row[]>;
|
|
82
|
+
/**
|
|
83
|
+
* Quotes an identifier for SQL: `"name"`, embedded double quotes are doubled.
|
|
84
|
+
*
|
|
85
|
+
* @param identifier - Identifier.
|
|
86
|
+
* @param _force - Accepted for Sequelize v6 compatibility; identifiers are always quoted.
|
|
87
|
+
* @returns Quoted identifier.
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* queryInterface.quoteIdentifier('user name'); // "user name"
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
quoteIdentifier(identifier: string, _force?: boolean): string;
|
|
94
|
+
/**
|
|
95
|
+
* Quotes a dotted identifier part by part: `schema.table` becomes `"schema"."table"`.
|
|
96
|
+
*
|
|
97
|
+
* @param identifiers - Dot separated identifiers.
|
|
98
|
+
* @returns Quoted identifiers.
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* queryInterface.quoteIdentifiers('tenant.users'); // "tenant"."users"
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
quoteIdentifiers(identifiers: string): string;
|
|
105
|
+
/**
|
|
106
|
+
* Reads the PostgreSQL server version (`SHOW server_version`), e.g. `'17.2'`.
|
|
107
|
+
*
|
|
108
|
+
* @param options - Query options.
|
|
109
|
+
* @returns Version string.
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* const version = await queryInterface.databaseVersion();
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
databaseVersion(options?: QueryOptionsBase): Promise<string>;
|
|
116
|
+
/**
|
|
117
|
+
* Runs `CREATE DATABASE`. Must run outside a transaction.
|
|
118
|
+
*
|
|
119
|
+
* @param database - Database name (quoted).
|
|
120
|
+
* @param options - `encoding`, `collate`, `ctype`, `template` (escaped as literals) and query options.
|
|
121
|
+
* @example
|
|
122
|
+
* ```ts
|
|
123
|
+
* await queryInterface.createDatabase('tenant_42', { encoding: 'UTF8', template: 'template0' });
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
createDatabase(database: string, options?: CreateDatabaseOptions): Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Runs `DROP DATABASE IF EXISTS`. Must run outside a transaction.
|
|
129
|
+
*
|
|
130
|
+
* @param database - Database name (quoted).
|
|
131
|
+
* @param options - Query options.
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* await queryInterface.dropDatabase('tenant_42');
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
dropDatabase(database: string, options?: QueryOptionsBase): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Runs `SET CONSTRAINTS ...` for `options.deferrable` (`Deferrable.SET_DEFERRED` / `SET_IMMEDIATE`) on the
|
|
140
|
+
* connection of a transaction.
|
|
141
|
+
*
|
|
142
|
+
* @param transaction - Transaction to run in.
|
|
143
|
+
* @param options - `deferrable` and query options.
|
|
144
|
+
* @throws Error when `deferrable` is not `Deferrable.SET_DEFERRED` / `SET_IMMEDIATE`.
|
|
145
|
+
* @example
|
|
146
|
+
* ```ts
|
|
147
|
+
* await queryInterface.deferConstraints(transaction, { deferrable: Deferrable.SET_DEFERRED(['posts_user_fk']) });
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
deferConstraints(transaction: Transaction, options?: QueryOptionsBase & Readonly<{
|
|
151
|
+
deferrable?: DeferrableValue;
|
|
152
|
+
}>): Promise<void>;
|
|
153
|
+
/**
|
|
154
|
+
* Describes a table and throws when it lacks a column.
|
|
155
|
+
*
|
|
156
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
157
|
+
* @param column - Column name.
|
|
158
|
+
* @param options - Query options.
|
|
159
|
+
* @returns The table description (see {@link QueryInterface.describeTable}).
|
|
160
|
+
* @throws Error when the table has no such column.
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* const columns = await queryInterface.assertTableHasColumn('users', 'email');
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
assertTableHasColumn(table: TableName, column: string, options?: QueryOptionsBase): Promise<Record<string, ColumnDescription>>;
|
|
167
|
+
/**
|
|
168
|
+
* Names of the foreign key constraints of each table.
|
|
169
|
+
*
|
|
170
|
+
* @param tables - Table names or `{ tableName, schema }`.
|
|
171
|
+
* @param options - Query options.
|
|
172
|
+
* @returns Constraint names keyed by table (`schema.table` for qualified tables).
|
|
173
|
+
* @example
|
|
174
|
+
* ```ts
|
|
175
|
+
* const keys = await queryInterface.getForeignKeysForTables(['posts', 'comments']);
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
getForeignKeysForTables(tables: readonly TableName[], options?: QueryOptionsBase): Promise<Record<string, readonly string[]>>;
|
|
179
|
+
}
|
|
180
|
+
export {};
|