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,256 @@
|
|
|
1
|
+
import { DataTypeInput } from '../data-types/data-types.ts';
|
|
2
|
+
import { ConstraintOptions, IndexField, IndexOptions } from '../ddl/ddl-generator.ts';
|
|
3
|
+
import { TableName } from '../ddl/sql-literal.ts';
|
|
4
|
+
import { AttributeOptions } from '../model/model-definition.ts';
|
|
5
|
+
import { QueryOptionsBase, RuntimeOwner } from '../model/runtime.ts';
|
|
6
|
+
import { QueryInterfacePartitions } from './query-interface-partitions.ts';
|
|
7
|
+
export type { ColumnDescription, CreateTableOptions, DropTableOptions, ForeignKeyReference, } from './query-interface-types.ts';
|
|
8
|
+
/**
|
|
9
|
+
* Schema manipulation API (Sequelize v6 `QueryInterface`) for PostgreSQL. Used by `sync()` and by
|
|
10
|
+
* migrations (`sequelize-cli`, umzug). Obtain the instance with {@link Sequelize.getQueryInterface}.
|
|
11
|
+
* Table names are `string` or `{ tableName, schema }`; identifiers are always quoted and values bound or
|
|
12
|
+
* escaped, never concatenated raw.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const queryInterface = sequelize.getQueryInterface();
|
|
17
|
+
* await queryInterface.createTable('users', {
|
|
18
|
+
* id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
19
|
+
* name: { type: DataTypes.STRING, allowNull: false },
|
|
20
|
+
* });
|
|
21
|
+
* await queryInterface.addIndex('users', ['name'], { unique: true });
|
|
22
|
+
* ```
|
|
23
|
+
* @see [Schema guide](/guide/schema)
|
|
24
|
+
*/
|
|
25
|
+
export declare class QueryInterface extends QueryInterfacePartitions {
|
|
26
|
+
#private;
|
|
27
|
+
/**
|
|
28
|
+
* Creates the schema API bound to a `Sequelize` instance; prefer {@link Sequelize.getQueryInterface}.
|
|
29
|
+
*
|
|
30
|
+
* @param sequelize - Owning `Sequelize` instance.
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* const api = new QueryInterface(sequelize);
|
|
34
|
+
* await api.showAllTables();
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
constructor(sequelize: RuntimeOwner);
|
|
38
|
+
/**
|
|
39
|
+
* Adds a column with `ALTER TABLE ... ADD COLUMN`; a plain data type or a full attribute definition (nullability, default, references, ...) is accepted.
|
|
40
|
+
*
|
|
41
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
42
|
+
* @param column - Column name.
|
|
43
|
+
* @param attribute - Column definition.
|
|
44
|
+
* @param options - Query options.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* await queryInterface.addColumn('users', 'nickname', { type: DataTypes.STRING, allowNull: true });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
addColumn(table: TableName, column: string, attribute: DataTypeInput | AttributeOptions, options?: QueryOptionsBase): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Drops a column with `ALTER TABLE ... DROP COLUMN`.
|
|
54
|
+
*
|
|
55
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
56
|
+
* @param column - Column name.
|
|
57
|
+
* @param options - Query options.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* await queryInterface.removeColumn('users', 'nickname');
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
removeColumn(table: TableName, column: string, options?: QueryOptionsBase): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Alters the type, nullability, default and comment of an existing column in one go.
|
|
67
|
+
*
|
|
68
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
69
|
+
* @param column - Column name.
|
|
70
|
+
* @param attribute - New column definition.
|
|
71
|
+
* @param options - Query options.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* await queryInterface.changeColumn('users', 'name', { type: DataTypes.STRING(100), allowNull: false });
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
changeColumn(table: TableName, column: string, attribute: DataTypeInput | AttributeOptions, options?: QueryOptionsBase): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Renames a column with `ALTER TABLE ... RENAME COLUMN`.
|
|
81
|
+
*
|
|
82
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
83
|
+
* @param before - Current column name.
|
|
84
|
+
* @param after - New column name.
|
|
85
|
+
* @param options - Query options.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* await queryInterface.renameColumn('users', 'name', 'full_name');
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
renameColumn(table: TableName, before: string, after: string, options?: QueryOptionsBase): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Creates an index on a table, optionally unique, partial, covering or `CONCURRENTLY`.
|
|
95
|
+
*
|
|
96
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
97
|
+
* @param fieldsOrOptions - Indexed fields or index options.
|
|
98
|
+
* @param options - Index options when fields are given separately.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* await queryInterface.addIndex('users', ['email'], { unique: true, name: 'users_email_unique' });
|
|
103
|
+
* await queryInterface.addIndex('users', {
|
|
104
|
+
* name: 'users_lower_email',
|
|
105
|
+
* fields: [{ expression: 'lower(email)', nulls: 'LAST' }],
|
|
106
|
+
* });
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
addIndex(table: TableName, fieldsOrOptions: readonly IndexField[] | IndexOptions, options?: IndexOptions & QueryOptionsBase): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Drops an index identified by name, or by the fields it was created on (the default generated name is derived from them).
|
|
112
|
+
*
|
|
113
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
114
|
+
* @param nameOrFields - Index name or indexed fields.
|
|
115
|
+
* @param options - `concurrently` and query options.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```ts
|
|
119
|
+
* await queryInterface.removeIndex('users', 'users_email_unique');
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
removeIndex(table: TableName, nameOrFields: string | readonly IndexField[], options?: QueryOptionsBase & Readonly<{
|
|
123
|
+
concurrently?: boolean;
|
|
124
|
+
}>): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Adds a `CHECK`, `UNIQUE`, `PRIMARY KEY`, `FOREIGN KEY` or `EXCLUDE` constraint to a table.
|
|
127
|
+
* `notValid: true` skips checking existing rows (check and foreign key); validate later with
|
|
128
|
+
* {@link QueryInterface.validateConstraint}.
|
|
129
|
+
*
|
|
130
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
131
|
+
* @param options - Constraint definition.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* await queryInterface.addConstraint('products', {
|
|
136
|
+
* type: 'check',
|
|
137
|
+
* fields: ['price'],
|
|
138
|
+
* name: 'products_price_positive',
|
|
139
|
+
* where: { price: { [Op.gt]: 0 } },
|
|
140
|
+
* });
|
|
141
|
+
* await queryInterface.addConstraint('bookings', {
|
|
142
|
+
* type: 'exclude',
|
|
143
|
+
* name: 'bookings_no_overlap',
|
|
144
|
+
* using: 'gist',
|
|
145
|
+
* exclude: [
|
|
146
|
+
* { name: 'room', with: '=' },
|
|
147
|
+
* { expression: 'tstzrange(starts, ends)', with: '&&' },
|
|
148
|
+
* ],
|
|
149
|
+
* });
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
addConstraint(table: TableName, options: ConstraintOptions & QueryOptionsBase): Promise<void>;
|
|
153
|
+
/**
|
|
154
|
+
* Validates a constraint added with `notValid: true`, scanning existing rows without blocking writes.
|
|
155
|
+
*
|
|
156
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
157
|
+
* @param name - Constraint name.
|
|
158
|
+
* @param options - Query options.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* await queryInterface.addConstraint('products', {
|
|
163
|
+
* type: 'check',
|
|
164
|
+
* name: 'products_price_positive',
|
|
165
|
+
* where: { price: { [Op.gt]: 0 } },
|
|
166
|
+
* notValid: true,
|
|
167
|
+
* });
|
|
168
|
+
* await queryInterface.validateConstraint('products', 'products_price_positive');
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
validateConstraint(table: TableName, name: string, options?: QueryOptionsBase): Promise<void>;
|
|
172
|
+
/**
|
|
173
|
+
* Drops a named constraint from a table.
|
|
174
|
+
*
|
|
175
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
176
|
+
* @param name - Constraint name.
|
|
177
|
+
* @param options - Query options.
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```ts
|
|
181
|
+
* await queryInterface.removeConstraint('products', 'products_price_positive');
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
removeConstraint(table: TableName, name: string, options?: QueryOptionsBase): Promise<void>;
|
|
185
|
+
/**
|
|
186
|
+
* Runs `DROP TYPE IF EXISTS` for an enum type.
|
|
187
|
+
*
|
|
188
|
+
* @param name - Enum type name.
|
|
189
|
+
* @param options - Query options.
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```ts
|
|
193
|
+
* await queryInterface.dropEnum('enum_users_role');
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
dropEnum(name: string, options?: QueryOptionsBase): Promise<void>;
|
|
197
|
+
/**
|
|
198
|
+
* Drops every enum type of the current schema with `CASCADE`, which also drops dependent columns' defaults. Destructive.
|
|
199
|
+
*
|
|
200
|
+
* @param options - Query options.
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```ts
|
|
204
|
+
* await queryInterface.dropAllEnums();
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
dropAllEnums(options?: QueryOptionsBase): Promise<void>;
|
|
208
|
+
/** @internal */
|
|
209
|
+
dropEnumsOf(table: TableName, fields: readonly string[], options?: QueryOptionsBase): Promise<void>;
|
|
210
|
+
/**
|
|
211
|
+
* Inserts several rows with one `INSERT` (used by seeders). Values are bound as parameters.
|
|
212
|
+
*
|
|
213
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
214
|
+
* @param records - Rows keyed by column name.
|
|
215
|
+
* @param options - Query options.
|
|
216
|
+
* @returns Number of inserted rows.
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```ts
|
|
220
|
+
* const inserted = await queryInterface.bulkInsert('users', [
|
|
221
|
+
* { name: 'Ada', email: 'ada@example.com' },
|
|
222
|
+
* { name: 'Alan', email: 'alan@example.com' },
|
|
223
|
+
* ]);
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
bulkInsert(table: TableName, records: readonly Readonly<Record<string, unknown>>[], options?: QueryOptionsBase): Promise<number>;
|
|
227
|
+
/**
|
|
228
|
+
* Updates every row matching a where object with one `UPDATE`, without model hooks or validation.
|
|
229
|
+
*
|
|
230
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
231
|
+
* @param values - New column values.
|
|
232
|
+
* @param where - Filter (where object keyed by column).
|
|
233
|
+
* @param options - Query options.
|
|
234
|
+
* @returns Number of updated rows.
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```ts
|
|
238
|
+
* const updated = await queryInterface.bulkUpdate('users', { active: false }, { name: 'Ada' });
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
bulkUpdate(table: TableName, values: Readonly<Record<string, unknown>>, where: unknown, options?: QueryOptionsBase): Promise<number>;
|
|
242
|
+
/**
|
|
243
|
+
* Deletes every row matching a where object with one `DELETE`, without model hooks.
|
|
244
|
+
*
|
|
245
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
246
|
+
* @param where - Filter (where object keyed by column); empty deletes all rows.
|
|
247
|
+
* @param options - Query options.
|
|
248
|
+
* @returns Number of deleted rows.
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```ts
|
|
252
|
+
* const removed = await queryInterface.bulkDelete('users', { active: false });
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
bulkDelete(table: TableName, where?: unknown, options?: QueryOptionsBase): Promise<number>;
|
|
256
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { CreateFunctionOptions, DropFunctionOptions, FunctionName, FunctionParam } from '../ddl/function-ddl.ts';
|
|
2
|
+
import { TableName } from '../ddl/sql-literal.ts';
|
|
3
|
+
import { CreateTriggerOptions, DropTriggerOptions, TriggerSpec } from '../ddl/trigger-ddl.ts';
|
|
4
|
+
import { QueryOptionsBase } from '../model/runtime.ts';
|
|
5
|
+
import { StatementRunner } from './statement-runner.ts';
|
|
6
|
+
/**
|
|
7
|
+
* Function and trigger DDL of `QueryInterface`. Names are quoted or guarded words, trigger
|
|
8
|
+
* arguments are literals, function bodies are trusted SQL (ADR-025).
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare class RoutineCommands {
|
|
13
|
+
#private;
|
|
14
|
+
/**
|
|
15
|
+
* @param runner - Statement runner.
|
|
16
|
+
*/
|
|
17
|
+
constructor(runner: StatementRunner);
|
|
18
|
+
/**
|
|
19
|
+
* Runs `CREATE FUNCTION`.
|
|
20
|
+
*
|
|
21
|
+
* @param name - Function name.
|
|
22
|
+
* @param params - Parameters.
|
|
23
|
+
* @param returnType - Return type.
|
|
24
|
+
* @param language - Language.
|
|
25
|
+
* @param body - Trusted body text.
|
|
26
|
+
* @param optionsArray - Characteristic keywords.
|
|
27
|
+
* @param options - Statement and query options.
|
|
28
|
+
*/
|
|
29
|
+
createFunction(name: FunctionName, params: readonly FunctionParam[], returnType: string, language: string, body: string, optionsArray: readonly string[], options: CreateFunctionOptions & QueryOptionsBase): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Runs `DROP FUNCTION`.
|
|
32
|
+
*
|
|
33
|
+
* @param name - Function name.
|
|
34
|
+
* @param params - Parameters identifying the overload.
|
|
35
|
+
* @param options - Statement and query options.
|
|
36
|
+
*/
|
|
37
|
+
dropFunction(name: FunctionName, params: readonly FunctionParam[], options: DropFunctionOptions & QueryOptionsBase): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Runs `ALTER FUNCTION ... RENAME TO`.
|
|
40
|
+
*
|
|
41
|
+
* @param name - Current name.
|
|
42
|
+
* @param params - Parameters identifying the overload.
|
|
43
|
+
* @param newName - New name.
|
|
44
|
+
* @param options - Query options.
|
|
45
|
+
*/
|
|
46
|
+
renameFunction(name: FunctionName, params: readonly FunctionParam[], newName: string, options: QueryOptionsBase): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Runs `CREATE TRIGGER`.
|
|
49
|
+
*
|
|
50
|
+
* @param spec - Trigger definition.
|
|
51
|
+
* @param options - Statement and query options.
|
|
52
|
+
*/
|
|
53
|
+
createTrigger(spec: TriggerSpec, options: CreateTriggerOptions & QueryOptionsBase): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Runs `DROP TRIGGER`.
|
|
56
|
+
*
|
|
57
|
+
* @param table - Table.
|
|
58
|
+
* @param name - Trigger name.
|
|
59
|
+
* @param options - Statement and query options.
|
|
60
|
+
*/
|
|
61
|
+
dropTrigger(table: TableName, name: string, options: DropTriggerOptions & QueryOptionsBase): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Runs `ALTER TRIGGER ... RENAME TO`.
|
|
64
|
+
*
|
|
65
|
+
* @param table - Table.
|
|
66
|
+
* @param name - Current name.
|
|
67
|
+
* @param newName - New name.
|
|
68
|
+
* @param options - Query options.
|
|
69
|
+
*/
|
|
70
|
+
renameTrigger(table: TableName, name: string, newName: string, options: QueryOptionsBase): Promise<void>;
|
|
71
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { ModelDefinition } from '../model/model-definition.ts';
|
|
2
|
+
import { ModelRuntime, QueryOptionsBase } from '../model/runtime.ts';
|
|
3
|
+
import { QueryInterface } from './query-interface.ts';
|
|
4
|
+
/**
|
|
5
|
+
* `alter` options of `sync()`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const alter: AlterOptions = { drop: false };
|
|
10
|
+
* await sequelize.sync({ alter });
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export type AlterOptions = Readonly<{
|
|
14
|
+
/** Drop columns that are not in the model. Default true. */
|
|
15
|
+
drop?: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Options of `sync()`: `force`, `alter`, `match`, `schema` plus the common query options.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const options: SyncOptions = { alter: true, match: /_test$/, schema: 'tenant_1' };
|
|
23
|
+
* await sequelize.sync(options);
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export type SyncOptions = QueryOptionsBase & Readonly<{
|
|
27
|
+
/** Drop and re-create tables. */
|
|
28
|
+
force?: boolean;
|
|
29
|
+
/** Alter existing tables to match models; `{ drop: false }` keeps extra columns. */
|
|
30
|
+
alter?: boolean | AlterOptions;
|
|
31
|
+
/** Only sync when the database name matches this pattern. */
|
|
32
|
+
match?: RegExp;
|
|
33
|
+
/** Create the tables in this schema instead of the models' schema (references stay in it too). */
|
|
34
|
+
schema?: string;
|
|
35
|
+
/** Run the `beforeSync` / `afterSync` hooks. Default true. */
|
|
36
|
+
hooks?: boolean;
|
|
37
|
+
}>;
|
|
38
|
+
/** Wraps the sync of one model (used to run its sync hooks). */
|
|
39
|
+
export type SyncWrapper = (definition: ModelDefinition, run: () => Promise<void>) => Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Options of `drop()`: `cascade`, `schema` plus the common query options.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* const options: DropOptions = { cascade: true, schema: 'tenant_1' };
|
|
46
|
+
* await sequelize.drop(options);
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export type DropOptions = QueryOptionsBase & Readonly<{
|
|
50
|
+
/** `DROP TABLE ... CASCADE`. */
|
|
51
|
+
cascade?: boolean;
|
|
52
|
+
/** Drop the tables in this schema instead of the models' schema. */
|
|
53
|
+
schema?: string;
|
|
54
|
+
}>;
|
|
55
|
+
/**
|
|
56
|
+
* Creates, alters and drops the tables of model definitions (`sync()` / `drop()`): dependency
|
|
57
|
+
* order, deferred foreign keys for reference cycles, `force`, `alter` and the `schema` option.
|
|
58
|
+
*
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
export declare class SchemaSynchronizer {
|
|
62
|
+
#private;
|
|
63
|
+
/**
|
|
64
|
+
* @param runtime - Runtime executing the statements.
|
|
65
|
+
* @param queryInterface - Query interface used to inspect and drop tables.
|
|
66
|
+
*/
|
|
67
|
+
constructor(runtime: ModelRuntime, queryInterface: QueryInterface);
|
|
68
|
+
/**
|
|
69
|
+
* Syncs several models: referenced tables first, foreign keys of reference cycles added once
|
|
70
|
+
* every table exists. With `force`, drops the tables in reverse order first.
|
|
71
|
+
*
|
|
72
|
+
* @param definitions - Model definitions.
|
|
73
|
+
* @param options - `force`, `alter`, `schema` and query options.
|
|
74
|
+
* @param wrap - Runs around the sync of each model.
|
|
75
|
+
*/
|
|
76
|
+
syncAll(definitions: readonly ModelDefinition[], options?: SyncOptions, wrap?: SyncWrapper): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Drops the tables of several models in reverse foreign-key order.
|
|
79
|
+
*
|
|
80
|
+
* @param definitions - Model definitions.
|
|
81
|
+
* @param options - `cascade`, `schema` and query options.
|
|
82
|
+
*/
|
|
83
|
+
dropAll(definitions: readonly ModelDefinition[], options?: DropOptions): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Creates (or alters / re-creates) the table of a model and its indexes.
|
|
86
|
+
*
|
|
87
|
+
* @param model - Model definition.
|
|
88
|
+
* @param options - `force`, `alter`, `schema` and query options.
|
|
89
|
+
* @param deferred - Columns created without their foreign keys (added later).
|
|
90
|
+
*/
|
|
91
|
+
sync(model: ModelDefinition, options?: SyncOptions, deferred?: readonly string[]): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* Drops the table of a model and its enum types.
|
|
94
|
+
*
|
|
95
|
+
* @param model - Model definition.
|
|
96
|
+
* @param options - `cascade`, `schema` and query options.
|
|
97
|
+
*/
|
|
98
|
+
drop(model: ModelDefinition, options?: DropOptions): Promise<void>;
|
|
99
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { QueryResult } from '../connection/connection-manager.ts';
|
|
2
|
+
import { QueryOptionsBase, RuntimeOwner } from '../model/runtime.ts';
|
|
3
|
+
import { CompiledQuery } from '../sql/compile.ts';
|
|
4
|
+
/** Result rows of a statement. */
|
|
5
|
+
export type StatementRows = readonly Readonly<Record<string, unknown>>[];
|
|
6
|
+
/**
|
|
7
|
+
* Runs schema statements through the runtime of a `Sequelize` instance, one after another.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare class StatementRunner {
|
|
12
|
+
#private;
|
|
13
|
+
/**
|
|
14
|
+
* @param owner - Owning `Sequelize` instance.
|
|
15
|
+
*/
|
|
16
|
+
constructor(owner: RuntimeOwner);
|
|
17
|
+
/**
|
|
18
|
+
* Runs a compiled query.
|
|
19
|
+
*
|
|
20
|
+
* @param query - Compiled query.
|
|
21
|
+
* @param options - Query options.
|
|
22
|
+
* @returns Query result.
|
|
23
|
+
*/
|
|
24
|
+
execute(query: CompiledQuery, options: QueryOptionsBase): Promise<QueryResult>;
|
|
25
|
+
/**
|
|
26
|
+
* Runs one statement without parameters.
|
|
27
|
+
*
|
|
28
|
+
* @param sql - SQL statement.
|
|
29
|
+
* @param options - Query options.
|
|
30
|
+
* @returns Result rows.
|
|
31
|
+
*/
|
|
32
|
+
run(sql: string, options?: QueryOptionsBase): Promise<StatementRows>;
|
|
33
|
+
/**
|
|
34
|
+
* Runs statements in order, each after the previous one finished.
|
|
35
|
+
*
|
|
36
|
+
* @param statements - SQL statements.
|
|
37
|
+
* @param options - Query options.
|
|
38
|
+
*/
|
|
39
|
+
runAll(statements: readonly string[], options?: QueryOptionsBase): Promise<void>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ModelDefinition } from '../model/model-definition.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Plans the order of `sync()` over several models: referenced tables first, and the foreign keys
|
|
4
|
+
* of reference cycles deferred until every table exists.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare class SyncPlanner {
|
|
9
|
+
#private;
|
|
10
|
+
/**
|
|
11
|
+
* Orders definitions so that referenced tables come first.
|
|
12
|
+
*
|
|
13
|
+
* @param definitions - Model definitions.
|
|
14
|
+
* @returns Definitions in dependency order.
|
|
15
|
+
*/
|
|
16
|
+
dependencyOrder(definitions: readonly ModelDefinition[]): readonly ModelDefinition[];
|
|
17
|
+
/**
|
|
18
|
+
* Columns (by field) of each definition whose foreign key points to a table created later in
|
|
19
|
+
* `ordered` — a reference cycle. Their tables are created without these constraints, which are
|
|
20
|
+
* added once every table exists.
|
|
21
|
+
*
|
|
22
|
+
* @param ordered - Definitions in dependency order.
|
|
23
|
+
* @returns Deferred fields per definition.
|
|
24
|
+
*/
|
|
25
|
+
deferredReferences(ordered: readonly ModelDefinition[]): ReadonlyMap<ModelDefinition, readonly string[]>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { TableName } from '../ddl/sql-literal.ts';
|
|
2
|
+
import { ModelAttributes } from '../model/model-definition.ts';
|
|
3
|
+
import { QueryOptionsBase } from '../model/runtime.ts';
|
|
4
|
+
import { CreateTableOptions, DropTableOptions } from './query-interface-types.ts';
|
|
5
|
+
import { StatementRunner } from './statement-runner.ts';
|
|
6
|
+
/**
|
|
7
|
+
* Schema and table DDL of `QueryInterface`. Names are quoted identifiers.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare class TableCommands {
|
|
12
|
+
#private;
|
|
13
|
+
/**
|
|
14
|
+
* @param runner - Statement runner.
|
|
15
|
+
*/
|
|
16
|
+
constructor(runner: StatementRunner);
|
|
17
|
+
/**
|
|
18
|
+
* `CREATE SCHEMA IF NOT EXISTS`.
|
|
19
|
+
*
|
|
20
|
+
* @param schema - Schema name.
|
|
21
|
+
* @param options - Query options.
|
|
22
|
+
*/
|
|
23
|
+
createSchema(schema: string, options?: QueryOptionsBase): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* `DROP SCHEMA IF EXISTS ... CASCADE`.
|
|
26
|
+
*
|
|
27
|
+
* @param schema - Schema name.
|
|
28
|
+
* @param options - Query options.
|
|
29
|
+
*/
|
|
30
|
+
dropSchema(schema: string, options?: QueryOptionsBase): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Creates a table and its enum types.
|
|
33
|
+
*
|
|
34
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
35
|
+
* @param attributes - Column definitions keyed by column name.
|
|
36
|
+
* @param options - Comment and query options.
|
|
37
|
+
*/
|
|
38
|
+
createTable(table: TableName, attributes: ModelAttributes, options: CreateTableOptions): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* `DROP TABLE IF EXISTS`.
|
|
41
|
+
*
|
|
42
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
43
|
+
* @param options - `cascade` and query options.
|
|
44
|
+
*/
|
|
45
|
+
dropTable(table: TableName, options: DropTableOptions): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Drops tables of the current schema with `CASCADE`, except the skipped ones.
|
|
48
|
+
*
|
|
49
|
+
* @param tables - Table names.
|
|
50
|
+
* @param options - `skip`: table names to keep.
|
|
51
|
+
*/
|
|
52
|
+
dropTables(tables: readonly string[], options: QueryOptionsBase & Readonly<{
|
|
53
|
+
skip?: readonly string[];
|
|
54
|
+
}>): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Renames a table.
|
|
57
|
+
*
|
|
58
|
+
* @param before - Current table.
|
|
59
|
+
* @param after - New table name.
|
|
60
|
+
* @param options - Query options.
|
|
61
|
+
*/
|
|
62
|
+
renameTable(before: TableName, after: TableName, options?: QueryOptionsBase): Promise<void>;
|
|
63
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { TableName } from '../ddl/sql-literal.ts';
|
|
2
|
+
import { QueryOptionsBase } from '../model/runtime.ts';
|
|
3
|
+
import { ColumnDescription, ForeignKeyReference } from './query-interface-types.ts';
|
|
4
|
+
import { StatementRunner } from './statement-runner.ts';
|
|
5
|
+
/**
|
|
6
|
+
* Catalog lookups of `QueryInterface`: schemas, tables, columns and foreign keys. Every lookup
|
|
7
|
+
* filters by schema (the given one or `current_schema()`); values are escaped literals.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare class TableIntrospector {
|
|
12
|
+
#private;
|
|
13
|
+
/**
|
|
14
|
+
* @param runner - Statement runner.
|
|
15
|
+
*/
|
|
16
|
+
constructor(runner: StatementRunner);
|
|
17
|
+
/**
|
|
18
|
+
* Lists user schemas.
|
|
19
|
+
*
|
|
20
|
+
* @param options - Query options.
|
|
21
|
+
* @returns Schema names.
|
|
22
|
+
*/
|
|
23
|
+
showAllSchemas(options?: QueryOptionsBase): Promise<string[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Checks whether a table exists.
|
|
26
|
+
*
|
|
27
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
28
|
+
* @param options - Query options.
|
|
29
|
+
* @returns True when the table exists.
|
|
30
|
+
*/
|
|
31
|
+
tableExists(table: TableName, options?: QueryOptionsBase): Promise<boolean>;
|
|
32
|
+
/**
|
|
33
|
+
* Lists tables of the current schema.
|
|
34
|
+
*
|
|
35
|
+
* @param options - Query options.
|
|
36
|
+
* @returns Table names.
|
|
37
|
+
*/
|
|
38
|
+
showAllTables(options?: QueryOptionsBase): Promise<string[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Describes the columns of a table.
|
|
41
|
+
*
|
|
42
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
43
|
+
* @param options - `schema` and query options.
|
|
44
|
+
* @returns Column descriptions keyed by column name.
|
|
45
|
+
* @throws Error when the table does not exist.
|
|
46
|
+
*/
|
|
47
|
+
describeTable(table: TableName, options: QueryOptionsBase & Readonly<{
|
|
48
|
+
schema?: string;
|
|
49
|
+
}>): Promise<Record<string, ColumnDescription>>;
|
|
50
|
+
/**
|
|
51
|
+
* Foreign keys of a table.
|
|
52
|
+
*
|
|
53
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
54
|
+
* @param options - Query options.
|
|
55
|
+
* @returns Constraint name, column and referenced table/column per foreign key column.
|
|
56
|
+
*/
|
|
57
|
+
getForeignKeyReferencesForTable(table: TableName, options?: QueryOptionsBase): Promise<ForeignKeyReference[]>;
|
|
58
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { CreateMaterializedViewOptions, CreateViewOptions, DropViewOptions, RefreshMaterializedViewOptions } from '../ddl/view-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
|
+
* View and materialized view DDL of `QueryInterface`. Names are quoted; the query is trusted SQL.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare class ViewCommands {
|
|
11
|
+
#private;
|
|
12
|
+
/**
|
|
13
|
+
* @param runner - Statement runner.
|
|
14
|
+
*/
|
|
15
|
+
constructor(runner: StatementRunner);
|
|
16
|
+
/**
|
|
17
|
+
* Runs `CREATE VIEW`.
|
|
18
|
+
*
|
|
19
|
+
* @param name - View name.
|
|
20
|
+
* @param query - Trusted `SELECT` text.
|
|
21
|
+
* @param options - View and query options.
|
|
22
|
+
*/
|
|
23
|
+
createView(name: TableName, query: string, options: CreateViewOptions & QueryOptionsBase): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Runs `CREATE MATERIALIZED VIEW`.
|
|
26
|
+
*
|
|
27
|
+
* @param name - View name.
|
|
28
|
+
* @param query - Trusted `SELECT` text.
|
|
29
|
+
* @param options - View and query options.
|
|
30
|
+
*/
|
|
31
|
+
createMaterializedView(name: TableName, query: string, options: CreateMaterializedViewOptions & QueryOptionsBase): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Runs `REFRESH MATERIALIZED VIEW`.
|
|
34
|
+
*
|
|
35
|
+
* @param name - View name.
|
|
36
|
+
* @param options - Refresh and query options.
|
|
37
|
+
*/
|
|
38
|
+
refreshMaterializedView(name: TableName, options: RefreshMaterializedViewOptions & QueryOptionsBase): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Runs `DROP VIEW` or `DROP MATERIALIZED VIEW`.
|
|
41
|
+
*
|
|
42
|
+
* @param name - View name.
|
|
43
|
+
* @param materialized - Drops a materialized view.
|
|
44
|
+
* @param options - Drop and query options.
|
|
45
|
+
*/
|
|
46
|
+
dropView(name: TableName, materialized: boolean, options: DropViewOptions & QueryOptionsBase): Promise<void>;
|
|
47
|
+
}
|