@warlock.js/cascade 4.0.174 → 4.1.2
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/README.md +6 -5
- package/bin/cascadejs +3 -0
- package/esm/cli/commands/migrate-export-sql.mjs +48 -0
- package/esm/cli/commands/migrate-export-sql.mjs.map +1 -0
- package/esm/cli/commands/migrate-list.mjs +26 -0
- package/esm/cli/commands/migrate-list.mjs.map +1 -0
- package/esm/cli/commands/migrate-rollback.mjs +50 -0
- package/esm/cli/commands/migrate-rollback.mjs.map +1 -0
- package/esm/cli/commands/migrate.mjs +65 -0
- package/esm/cli/commands/migrate.mjs.map +1 -0
- package/esm/cli/connection-from-env.mjs +181 -0
- package/esm/cli/connection-from-env.mjs.map +1 -0
- package/esm/cli/index.mjs +31 -0
- package/esm/cli/index.mjs.map +1 -0
- package/esm/cli/load-migrations.mjs +78 -0
- package/esm/cli/load-migrations.mjs.map +1 -0
- package/esm/cli/printers.mjs +57 -0
- package/esm/cli/printers.mjs.map +1 -0
- package/esm/cli/setup-logger.mjs +30 -0
- package/esm/cli/setup-logger.mjs.map +1 -0
- package/esm/cli/with-cli-connection.mjs +39 -0
- package/esm/cli/with-cli-connection.mjs.map +1 -0
- package/esm/cli.d.mts +1 -0
- package/esm/cli.mjs +26 -0
- package/esm/cli.mjs.map +1 -0
- package/esm/context/database-data-source-context.d.mts +32 -0
- package/esm/context/database-data-source-context.d.mts.map +1 -0
- package/esm/context/database-data-source-context.mjs +35 -0
- package/esm/context/database-data-source-context.mjs.map +1 -0
- package/esm/context/database-transaction-context.d.mts +38 -0
- package/esm/context/database-transaction-context.d.mts.map +1 -0
- package/esm/context/database-transaction-context.mjs +47 -0
- package/esm/context/database-transaction-context.mjs.map +1 -0
- package/esm/contracts/database-driver.contract.d.mts +443 -0
- package/esm/contracts/database-driver.contract.d.mts.map +1 -0
- package/esm/contracts/database-id-generator.contract.d.mts +109 -0
- package/esm/contracts/database-id-generator.contract.d.mts.map +1 -0
- package/esm/contracts/database-remover.contract.d.mts +108 -0
- package/esm/contracts/database-remover.contract.d.mts.map +1 -0
- package/esm/contracts/database-restorer.contract.d.mts +145 -0
- package/esm/contracts/database-restorer.contract.d.mts.map +1 -0
- package/esm/contracts/database-writer.contract.d.mts +123 -0
- package/esm/contracts/database-writer.contract.d.mts.map +1 -0
- package/esm/contracts/driver-blueprint.contract.d.mts +52 -0
- package/esm/contracts/driver-blueprint.contract.d.mts.map +1 -0
- package/esm/contracts/index.d.mts +9 -0
- package/esm/contracts/migration-driver.contract.d.mts +476 -0
- package/esm/contracts/migration-driver.contract.d.mts.map +1 -0
- package/esm/contracts/query-builder.contract.d.mts +1663 -0
- package/esm/contracts/query-builder.contract.d.mts.map +1 -0
- package/esm/contracts/sync-adapter.contract.d.mts +49 -0
- package/esm/contracts/sync-adapter.contract.d.mts.map +1 -0
- package/esm/data-source/data-source-registry.d.mts +111 -0
- package/esm/data-source/data-source-registry.d.mts.map +1 -0
- package/esm/data-source/data-source-registry.mjs +142 -0
- package/esm/data-source/data-source-registry.mjs.map +1 -0
- package/esm/data-source/data-source.d.mts +160 -0
- package/esm/data-source/data-source.d.mts.map +1 -0
- package/esm/data-source/data-source.mjs +87 -0
- package/esm/data-source/data-source.mjs.map +1 -0
- package/esm/database-dirty-tracker.d.mts +254 -0
- package/esm/database-dirty-tracker.d.mts.map +1 -0
- package/esm/database-dirty-tracker.mjs +356 -0
- package/esm/database-dirty-tracker.mjs.map +1 -0
- package/esm/drivers/mongodb/mongodb-blueprint.mjs +54 -0
- package/esm/drivers/mongodb/mongodb-blueprint.mjs.map +1 -0
- package/esm/drivers/mongodb/mongodb-driver.d.mts +334 -0
- package/esm/drivers/mongodb/mongodb-driver.d.mts.map +1 -0
- package/esm/drivers/mongodb/mongodb-driver.mjs +716 -0
- package/esm/drivers/mongodb/mongodb-driver.mjs.map +1 -0
- package/esm/drivers/mongodb/mongodb-id-generator.d.mts +120 -0
- package/esm/drivers/mongodb/mongodb-id-generator.d.mts.map +1 -0
- package/esm/drivers/mongodb/mongodb-id-generator.mjs +141 -0
- package/esm/drivers/mongodb/mongodb-id-generator.mjs.map +1 -0
- package/esm/drivers/mongodb/mongodb-migration-driver.d.mts +322 -0
- package/esm/drivers/mongodb/mongodb-migration-driver.d.mts.map +1 -0
- package/esm/drivers/mongodb/mongodb-migration-driver.mjs +531 -0
- package/esm/drivers/mongodb/mongodb-migration-driver.mjs.map +1 -0
- package/esm/drivers/mongodb/mongodb-query-builder.d.mts +1117 -0
- package/esm/drivers/mongodb/mongodb-query-builder.d.mts.map +1 -0
- package/esm/drivers/mongodb/mongodb-query-builder.mjs +1828 -0
- package/esm/drivers/mongodb/mongodb-query-builder.mjs.map +1 -0
- package/esm/drivers/mongodb/mongodb-query-operations.d.mts +230 -0
- package/esm/drivers/mongodb/mongodb-query-operations.d.mts.map +1 -0
- package/esm/drivers/mongodb/mongodb-query-operations.mjs +275 -0
- package/esm/drivers/mongodb/mongodb-query-operations.mjs.map +1 -0
- package/esm/drivers/mongodb/mongodb-query-parser.d.mts +263 -0
- package/esm/drivers/mongodb/mongodb-query-parser.d.mts.map +1 -0
- package/esm/drivers/mongodb/mongodb-query-parser.mjs +965 -0
- package/esm/drivers/mongodb/mongodb-query-parser.mjs.map +1 -0
- package/esm/drivers/mongodb/mongodb-sync-adapter.d.mts +78 -0
- package/esm/drivers/mongodb/mongodb-sync-adapter.d.mts.map +1 -0
- package/esm/drivers/mongodb/mongodb-sync-adapter.mjs +118 -0
- package/esm/drivers/mongodb/mongodb-sync-adapter.mjs.map +1 -0
- package/esm/drivers/mongodb/types.d.mts +43 -0
- package/esm/drivers/mongodb/types.d.mts.map +1 -0
- package/esm/drivers/postgres/index.d.mts +8 -0
- package/esm/drivers/postgres/index.mjs +9 -0
- package/esm/drivers/postgres/postgres-blueprint.d.mts +60 -0
- package/esm/drivers/postgres/postgres-blueprint.d.mts.map +1 -0
- package/esm/drivers/postgres/postgres-blueprint.mjs +105 -0
- package/esm/drivers/postgres/postgres-blueprint.mjs.map +1 -0
- package/esm/drivers/postgres/postgres-dialect.d.mts +144 -0
- package/esm/drivers/postgres/postgres-dialect.d.mts.map +1 -0
- package/esm/drivers/postgres/postgres-dialect.mjs +227 -0
- package/esm/drivers/postgres/postgres-dialect.mjs.map +1 -0
- package/esm/drivers/postgres/postgres-driver.d.mts +424 -0
- package/esm/drivers/postgres/postgres-driver.d.mts.map +1 -0
- package/esm/drivers/postgres/postgres-driver.mjs +845 -0
- package/esm/drivers/postgres/postgres-driver.mjs.map +1 -0
- package/esm/drivers/postgres/postgres-migration-driver.d.mts +393 -0
- package/esm/drivers/postgres/postgres-migration-driver.d.mts.map +1 -0
- package/esm/drivers/postgres/postgres-migration-driver.mjs +760 -0
- package/esm/drivers/postgres/postgres-migration-driver.mjs.map +1 -0
- package/esm/drivers/postgres/postgres-query-builder.d.mts +399 -0
- package/esm/drivers/postgres/postgres-query-builder.d.mts.map +1 -0
- package/esm/drivers/postgres/postgres-query-builder.mjs +1105 -0
- package/esm/drivers/postgres/postgres-query-builder.mjs.map +1 -0
- package/esm/drivers/postgres/postgres-query-parser.d.mts +351 -0
- package/esm/drivers/postgres/postgres-query-parser.d.mts.map +1 -0
- package/esm/drivers/postgres/postgres-query-parser.mjs +796 -0
- package/esm/drivers/postgres/postgres-query-parser.mjs.map +1 -0
- package/esm/drivers/postgres/postgres-sql-serializer.mjs +260 -0
- package/esm/drivers/postgres/postgres-sql-serializer.mjs.map +1 -0
- package/esm/drivers/postgres/postgres-sync-adapter.d.mts +79 -0
- package/esm/drivers/postgres/postgres-sync-adapter.d.mts.map +1 -0
- package/esm/drivers/postgres/postgres-sync-adapter.mjs +162 -0
- package/esm/drivers/postgres/postgres-sync-adapter.mjs.map +1 -0
- package/esm/drivers/postgres/types.d.mts +105 -0
- package/esm/drivers/postgres/types.d.mts.map +1 -0
- package/esm/drivers/sql/sql-dialect.contract.d.mts +221 -0
- package/esm/drivers/sql/sql-dialect.contract.d.mts.map +1 -0
- package/esm/drivers/sql/sql-types.d.mts +150 -0
- package/esm/drivers/sql/sql-types.d.mts.map +1 -0
- package/esm/errors/missing-data-source.error.d.mts +25 -0
- package/esm/errors/missing-data-source.error.d.mts.map +1 -0
- package/esm/errors/missing-data-source.error.mjs +31 -0
- package/esm/errors/missing-data-source.error.mjs.map +1 -0
- package/esm/errors/transaction-rollback.error.d.mts +23 -0
- package/esm/errors/transaction-rollback.error.d.mts.map +1 -0
- package/esm/errors/transaction-rollback.error.mjs +29 -0
- package/esm/errors/transaction-rollback.error.mjs.map +1 -0
- package/esm/events/model-events.d.mts +234 -0
- package/esm/events/model-events.d.mts.map +1 -0
- package/esm/events/model-events.mjs +254 -0
- package/esm/events/model-events.mjs.map +1 -0
- package/esm/expressions/aggregate-expressions.d.mts +224 -0
- package/esm/expressions/aggregate-expressions.d.mts.map +1 -0
- package/esm/expressions/aggregate-expressions.mjs +232 -0
- package/esm/expressions/aggregate-expressions.mjs.map +1 -0
- package/esm/index.d.mts +67 -0
- package/esm/index.mjs +53 -0
- package/esm/migration/column-builder.d.mts +420 -0
- package/esm/migration/column-builder.d.mts.map +1 -0
- package/esm/migration/column-builder.mjs +532 -0
- package/esm/migration/column-builder.mjs.map +1 -0
- package/esm/migration/column-helpers.d.mts +280 -0
- package/esm/migration/column-helpers.d.mts.map +1 -0
- package/esm/migration/column-helpers.mjs +376 -0
- package/esm/migration/column-helpers.mjs.map +1 -0
- package/esm/migration/foreign-key-builder.d.mts +106 -0
- package/esm/migration/foreign-key-builder.d.mts.map +1 -0
- package/esm/migration/foreign-key-builder.mjs +126 -0
- package/esm/migration/foreign-key-builder.mjs.map +1 -0
- package/esm/migration/index.d.mts +6 -0
- package/esm/migration/index.mjs +7 -0
- package/esm/migration/migration-runner.d.mts +279 -0
- package/esm/migration/migration-runner.d.mts.map +1 -0
- package/esm/migration/migration-runner.mjs +662 -0
- package/esm/migration/migration-runner.mjs.map +1 -0
- package/esm/migration/migration.d.mts +2035 -0
- package/esm/migration/migration.d.mts.map +1 -0
- package/esm/migration/migration.mjs +2083 -0
- package/esm/migration/migration.mjs.map +1 -0
- package/esm/migration/sql-grammar.mjs +115 -0
- package/esm/migration/sql-grammar.mjs.map +1 -0
- package/esm/migration/sql-serializer.d.mts +26 -0
- package/esm/migration/sql-serializer.d.mts.map +1 -0
- package/esm/migration/sql-serializer.mjs +26 -0
- package/esm/migration/sql-serializer.mjs.map +1 -0
- package/esm/migration/types.d.mts +136 -0
- package/esm/migration/types.d.mts.map +1 -0
- package/esm/model/methods/accessor-methods.mjs +54 -0
- package/esm/model/methods/accessor-methods.mjs.map +1 -0
- package/esm/model/methods/delete-methods.mjs +16 -0
- package/esm/model/methods/delete-methods.mjs.map +1 -0
- package/esm/model/methods/dirty-methods.mjs +20 -0
- package/esm/model/methods/dirty-methods.mjs.map +1 -0
- package/esm/model/methods/hydration-methods.mjs +51 -0
- package/esm/model/methods/hydration-methods.mjs.map +1 -0
- package/esm/model/methods/instance-event-methods.mjs +22 -0
- package/esm/model/methods/instance-event-methods.mjs.map +1 -0
- package/esm/model/methods/meta-methods.mjs +36 -0
- package/esm/model/methods/meta-methods.mjs.map +1 -0
- package/esm/model/methods/pivot-methods.mjs +48 -0
- package/esm/model/methods/pivot-methods.mjs.map +1 -0
- package/esm/model/methods/query-methods.mjs +121 -0
- package/esm/model/methods/query-methods.mjs.map +1 -0
- package/esm/model/methods/restore-methods.mjs +16 -0
- package/esm/model/methods/restore-methods.mjs.map +1 -0
- package/esm/model/methods/scope-methods.mjs +20 -0
- package/esm/model/methods/scope-methods.mjs.map +1 -0
- package/esm/model/methods/serialization-methods.mjs +20 -0
- package/esm/model/methods/serialization-methods.mjs.map +1 -0
- package/esm/model/methods/static-event-methods.mjs +37 -0
- package/esm/model/methods/static-event-methods.mjs.map +1 -0
- package/esm/model/methods/write-methods.mjs +69 -0
- package/esm/model/methods/write-methods.mjs.map +1 -0
- package/esm/model/model.d.mts +1778 -0
- package/esm/model/model.d.mts.map +1 -0
- package/esm/model/model.mjs +1762 -0
- package/esm/model/model.mjs.map +1 -0
- package/esm/model/model.types.d.mts +47 -0
- package/esm/model/model.types.d.mts.map +1 -0
- package/esm/model/register-model.d.mts +140 -0
- package/esm/model/register-model.d.mts.map +1 -0
- package/esm/model/register-model.mjs +175 -0
- package/esm/model/register-model.mjs.map +1 -0
- package/esm/model/relation-decorators.d.mts +88 -0
- package/esm/model/relation-decorators.d.mts.map +1 -0
- package/esm/model/relation-decorators.mjs +191 -0
- package/esm/model/relation-decorators.mjs.map +1 -0
- package/esm/operations/database.d.mts +46 -0
- package/esm/operations/database.d.mts.map +1 -0
- package/esm/operations/database.mjs +40 -0
- package/esm/operations/database.mjs.map +1 -0
- package/esm/operations/index.d.mts +2 -0
- package/esm/operations/index.mjs +4 -0
- package/esm/operations/migrations.d.mts +71 -0
- package/esm/operations/migrations.d.mts.map +1 -0
- package/esm/operations/migrations.mjs +70 -0
- package/esm/operations/migrations.mjs.map +1 -0
- package/esm/query-builder/query-builder.d.mts +564 -0
- package/esm/query-builder/query-builder.d.mts.map +1 -0
- package/esm/query-builder/query-builder.mjs +1097 -0
- package/esm/query-builder/query-builder.mjs.map +1 -0
- package/esm/relations/index.d.mts +4 -0
- package/esm/relations/index.mjs +5 -0
- package/esm/relations/key-conventions.mjs +119 -0
- package/esm/relations/key-conventions.mjs.map +1 -0
- package/esm/relations/pivot-operations.d.mts +155 -0
- package/esm/relations/pivot-operations.d.mts.map +1 -0
- package/esm/relations/pivot-operations.mjs +232 -0
- package/esm/relations/pivot-operations.mjs.map +1 -0
- package/esm/relations/relation-hydrator.d.mts +55 -0
- package/esm/relations/relation-hydrator.d.mts.map +1 -0
- package/esm/relations/relation-hydrator.mjs +52 -0
- package/esm/relations/relation-hydrator.mjs.map +1 -0
- package/esm/relations/relation-loader.d.mts +190 -0
- package/esm/relations/relation-loader.d.mts.map +1 -0
- package/esm/relations/relation-loader.mjs +416 -0
- package/esm/relations/relation-loader.mjs.map +1 -0
- package/esm/relations/types.d.mts +317 -0
- package/esm/relations/types.d.mts.map +1 -0
- package/esm/remover/database-remover.d.mts +104 -0
- package/esm/remover/database-remover.d.mts.map +1 -0
- package/esm/remover/database-remover.mjs +174 -0
- package/esm/remover/database-remover.mjs.map +1 -0
- package/esm/restorer/database-restorer.d.mts +135 -0
- package/esm/restorer/database-restorer.d.mts.map +1 -0
- package/esm/restorer/database-restorer.mjs +316 -0
- package/esm/restorer/database-restorer.mjs.map +1 -0
- package/esm/sql-database-dirty-tracker.d.mts +17 -0
- package/esm/sql-database-dirty-tracker.d.mts.map +1 -0
- package/esm/sql-database-dirty-tracker.mjs +20 -0
- package/esm/sql-database-dirty-tracker.mjs.map +1 -0
- package/esm/sync/model-events.mjs +46 -0
- package/esm/sync/model-events.mjs.map +1 -0
- package/esm/sync/model-sync-operation.d.mts +159 -0
- package/esm/sync/model-sync-operation.d.mts.map +1 -0
- package/esm/sync/model-sync-operation.mjs +257 -0
- package/esm/sync/model-sync-operation.mjs.map +1 -0
- package/esm/sync/model-sync.d.mts +126 -0
- package/esm/sync/model-sync.d.mts.map +1 -0
- package/esm/sync/model-sync.mjs +157 -0
- package/esm/sync/model-sync.mjs.map +1 -0
- package/esm/sync/sync-context.d.mts +69 -0
- package/esm/sync/sync-context.d.mts.map +1 -0
- package/esm/sync/sync-context.mjs +95 -0
- package/esm/sync/sync-context.mjs.map +1 -0
- package/esm/sync/sync-manager.d.mts +213 -0
- package/esm/sync/sync-manager.d.mts.map +1 -0
- package/esm/sync/sync-manager.mjs +597 -0
- package/esm/sync/sync-manager.mjs.map +1 -0
- package/esm/sync/types.d.mts +215 -0
- package/esm/sync/types.d.mts.map +1 -0
- package/esm/types.d.mts +423 -0
- package/esm/types.d.mts.map +1 -0
- package/esm/utils/connect-to-database.d.mts +328 -0
- package/esm/utils/connect-to-database.d.mts.map +1 -0
- package/esm/utils/connect-to-database.mjs +130 -0
- package/esm/utils/connect-to-database.mjs.map +1 -0
- package/esm/utils/database-writer.utils.d.mts +18 -0
- package/esm/utils/database-writer.utils.d.mts.map +1 -0
- package/esm/utils/database-writer.utils.mjs +25 -0
- package/esm/utils/database-writer.utils.mjs.map +1 -0
- package/esm/utils/define-model.d.mts +185 -0
- package/esm/utils/define-model.d.mts.map +1 -0
- package/esm/utils/define-model.mjs +105 -0
- package/esm/utils/define-model.mjs.map +1 -0
- package/esm/utils/is-valid-date-value.mjs +22 -0
- package/esm/utils/is-valid-date-value.mjs.map +1 -0
- package/esm/utils/once-connected.d.mts +150 -0
- package/esm/utils/once-connected.d.mts.map +1 -0
- package/esm/utils/once-connected.mjs +203 -0
- package/esm/utils/once-connected.mjs.map +1 -0
- package/esm/validation/database-seal-plugins.d.mts +1 -0
- package/esm/validation/database-seal-plugins.mjs +11 -0
- package/esm/validation/database-seal-plugins.mjs.map +1 -0
- package/esm/validation/database-writer-validation-error.d.mts +101 -0
- package/esm/validation/database-writer-validation-error.d.mts.map +1 -0
- package/esm/validation/database-writer-validation-error.mjs +153 -0
- package/esm/validation/database-writer-validation-error.mjs.map +1 -0
- package/esm/validation/index.d.mts +2 -0
- package/esm/validation/index.mjs +4 -0
- package/esm/validation/mutators/embed-mutator.mjs +26 -0
- package/esm/validation/mutators/embed-mutator.mjs.map +1 -0
- package/esm/validation/plugins/database-rules-plugin.d.mts +28 -0
- package/esm/validation/plugins/database-rules-plugin.d.mts.map +1 -0
- package/esm/validation/plugins/database-rules-plugin.mjs +43 -0
- package/esm/validation/plugins/database-rules-plugin.mjs.map +1 -0
- package/esm/validation/plugins/embed-validator-plugin.d.mts +17 -0
- package/esm/validation/plugins/embed-validator-plugin.d.mts.map +1 -0
- package/esm/validation/plugins/embed-validator-plugin.mjs +20 -0
- package/esm/validation/plugins/embed-validator-plugin.mjs.map +1 -0
- package/esm/validation/rules/database-model-rule.mjs +32 -0
- package/esm/validation/rules/database-model-rule.mjs.map +1 -0
- package/esm/validation/rules/exists-rule.mjs +29 -0
- package/esm/validation/rules/exists-rule.mjs.map +1 -0
- package/esm/validation/rules/unique-rule.mjs +43 -0
- package/esm/validation/rules/unique-rule.mjs.map +1 -0
- package/esm/validation/transformers/embed-model-transformer.mjs +17 -0
- package/esm/validation/transformers/embed-model-transformer.mjs.map +1 -0
- package/esm/validation/types.d.mts +43 -0
- package/esm/validation/types.d.mts.map +1 -0
- package/esm/validation/validators/embed-validator.d.mts +25 -0
- package/esm/validation/validators/embed-validator.d.mts.map +1 -0
- package/esm/validation/validators/embed-validator.mjs +42 -0
- package/esm/validation/validators/embed-validator.mjs.map +1 -0
- package/esm/writer/database-writer.d.mts +178 -0
- package/esm/writer/database-writer.d.mts.map +1 -0
- package/esm/writer/database-writer.mjs +317 -0
- package/esm/writer/database-writer.mjs.map +1 -0
- package/llms-full.txt +2027 -0
- package/llms.txt +23 -0
- package/package.json +60 -51
- package/skills/README.md +65 -0
- package/skills/aggregate-data/SKILL.md +102 -0
- package/skills/cascade-basics/SKILL.md +93 -0
- package/skills/configure-delete-strategy/SKILL.md +126 -0
- package/skills/define-model/SKILL.md +170 -0
- package/skills/define-relations/SKILL.md +171 -0
- package/skills/manage-data-sources/SKILL.md +140 -0
- package/skills/manage-transactions/SKILL.md +118 -0
- package/skills/paginate-results/SKILL.md +122 -0
- package/skills/perform-atomic-ops/SKILL.md +98 -0
- package/skills/query-data/SKILL.md +168 -0
- package/skills/run-cascade-cli/SKILL.md +125 -0
- package/skills/search-by-vector/SKILL.md +127 -0
- package/skills/subscribe-to-model-events/SKILL.md +148 -0
- package/skills/track-changes/SKILL.md +109 -0
- package/skills/write-migration/SKILL.md +144 -0
- package/cjs/context/database-data-source-context.d.ts +0 -29
- package/cjs/context/database-data-source-context.d.ts.map +0 -1
- package/cjs/context/database-data-source-context.js +0 -28
- package/cjs/context/database-data-source-context.js.map +0 -1
- package/cjs/context/database-transaction-context.d.ts +0 -35
- package/cjs/context/database-transaction-context.d.ts.map +0 -1
- package/cjs/context/database-transaction-context.js +0 -40
- package/cjs/context/database-transaction-context.js.map +0 -1
- package/cjs/contracts/database-driver.contract.d.ts +0 -450
- package/cjs/contracts/database-driver.contract.d.ts.map +0 -1
- package/cjs/contracts/database-id-generator.contract.d.ts +0 -109
- package/cjs/contracts/database-id-generator.contract.d.ts.map +0 -1
- package/cjs/contracts/database-remover.contract.d.ts +0 -104
- package/cjs/contracts/database-remover.contract.d.ts.map +0 -1
- package/cjs/contracts/database-restorer.contract.d.ts +0 -143
- package/cjs/contracts/database-restorer.contract.d.ts.map +0 -1
- package/cjs/contracts/database-writer.contract.d.ts +0 -119
- package/cjs/contracts/database-writer.contract.d.ts.map +0 -1
- package/cjs/contracts/driver-blueprint.contract.d.ts +0 -49
- package/cjs/contracts/driver-blueprint.contract.d.ts.map +0 -1
- package/cjs/contracts/index.d.ts +0 -10
- package/cjs/contracts/index.d.ts.map +0 -1
- package/cjs/contracts/migration-driver.contract.d.ts +0 -522
- package/cjs/contracts/migration-driver.contract.d.ts.map +0 -1
- package/cjs/contracts/query-builder.contract.d.ts +0 -1609
- package/cjs/contracts/query-builder.contract.d.ts.map +0 -1
- package/cjs/contracts/sync-adapter.contract.d.ts +0 -58
- package/cjs/contracts/sync-adapter.contract.d.ts.map +0 -1
- package/cjs/data-source/data-source-registry.d.ts +0 -108
- package/cjs/data-source/data-source-registry.d.ts.map +0 -1
- package/cjs/data-source/data-source-registry.js +0 -145
- package/cjs/data-source/data-source-registry.js.map +0 -1
- package/cjs/data-source/data-source.d.ts +0 -147
- package/cjs/data-source/data-source.d.ts.map +0 -1
- package/cjs/data-source/data-source.js +0 -83
- package/cjs/data-source/data-source.js.map +0 -1
- package/cjs/database-dirty-tracker.d.ts +0 -252
- package/cjs/database-dirty-tracker.d.ts.map +0 -1
- package/cjs/database-dirty-tracker.js +0 -386
- package/cjs/database-dirty-tracker.js.map +0 -1
- package/cjs/drivers/mongodb/mongodb-blueprint.d.ts +0 -30
- package/cjs/drivers/mongodb/mongodb-blueprint.d.ts.map +0 -1
- package/cjs/drivers/mongodb/mongodb-blueprint.js +0 -51
- package/cjs/drivers/mongodb/mongodb-blueprint.js.map +0 -1
- package/cjs/drivers/mongodb/mongodb-driver.d.ts +0 -325
- package/cjs/drivers/mongodb/mongodb-driver.d.ts.map +0 -1
- package/cjs/drivers/mongodb/mongodb-driver.js +0 -845
- package/cjs/drivers/mongodb/mongodb-driver.js.map +0 -1
- package/cjs/drivers/mongodb/mongodb-id-generator.d.ts +0 -116
- package/cjs/drivers/mongodb/mongodb-id-generator.d.ts.map +0 -1
- package/cjs/drivers/mongodb/mongodb-id-generator.js +0 -149
- package/cjs/drivers/mongodb/mongodb-id-generator.js.map +0 -1
- package/cjs/drivers/mongodb/mongodb-migration-driver.d.ts +0 -317
- package/cjs/drivers/mongodb/mongodb-migration-driver.d.ts.map +0 -1
- package/cjs/drivers/mongodb/mongodb-migration-driver.js +0 -666
- package/cjs/drivers/mongodb/mongodb-migration-driver.js.map +0 -1
- package/cjs/drivers/mongodb/mongodb-query-builder.d.ts +0 -1122
- package/cjs/drivers/mongodb/mongodb-query-builder.d.ts.map +0 -1
- package/cjs/drivers/mongodb/mongodb-query-builder.js +0 -1988
- package/cjs/drivers/mongodb/mongodb-query-builder.js.map +0 -1
- package/cjs/drivers/mongodb/mongodb-query-operations.d.ts +0 -226
- package/cjs/drivers/mongodb/mongodb-query-operations.d.ts.map +0 -1
- package/cjs/drivers/mongodb/mongodb-query-operations.js +0 -270
- package/cjs/drivers/mongodb/mongodb-query-operations.js.map +0 -1
- package/cjs/drivers/mongodb/mongodb-query-parser.d.ts +0 -262
- package/cjs/drivers/mongodb/mongodb-query-parser.d.ts.map +0 -1
- package/cjs/drivers/mongodb/mongodb-query-parser.js +0 -1351
- package/cjs/drivers/mongodb/mongodb-query-parser.js.map +0 -1
- package/cjs/drivers/mongodb/mongodb-sync-adapter.d.ts +0 -79
- package/cjs/drivers/mongodb/mongodb-sync-adapter.d.ts.map +0 -1
- package/cjs/drivers/mongodb/mongodb-sync-adapter.js +0 -146
- package/cjs/drivers/mongodb/mongodb-sync-adapter.js.map +0 -1
- package/cjs/drivers/mongodb/types.d.ts +0 -43
- package/cjs/drivers/mongodb/types.d.ts.map +0 -1
- package/cjs/drivers/postgres/index.d.ts +0 -16
- package/cjs/drivers/postgres/index.d.ts.map +0 -1
- package/cjs/drivers/postgres/postgres-blueprint.d.ts +0 -64
- package/cjs/drivers/postgres/postgres-blueprint.d.ts.map +0 -1
- package/cjs/drivers/postgres/postgres-blueprint.js +0 -121
- package/cjs/drivers/postgres/postgres-blueprint.js.map +0 -1
- package/cjs/drivers/postgres/postgres-dialect.d.ts +0 -136
- package/cjs/drivers/postgres/postgres-dialect.d.ts.map +0 -1
- package/cjs/drivers/postgres/postgres-dialect.js +0 -268
- package/cjs/drivers/postgres/postgres-dialect.js.map +0 -1
- package/cjs/drivers/postgres/postgres-driver.d.ts +0 -432
- package/cjs/drivers/postgres/postgres-driver.d.ts.map +0 -1
- package/cjs/drivers/postgres/postgres-driver.js +0 -1008
- package/cjs/drivers/postgres/postgres-driver.js.map +0 -1
- package/cjs/drivers/postgres/postgres-migration-driver.d.ts +0 -397
- package/cjs/drivers/postgres/postgres-migration-driver.d.ts.map +0 -1
- package/cjs/drivers/postgres/postgres-migration-driver.js +0 -900
- package/cjs/drivers/postgres/postgres-migration-driver.js.map +0 -1
- package/cjs/drivers/postgres/postgres-query-builder.d.ts +0 -254
- package/cjs/drivers/postgres/postgres-query-builder.d.ts.map +0 -1
- package/cjs/drivers/postgres/postgres-query-builder.js +0 -933
- package/cjs/drivers/postgres/postgres-query-builder.js.map +0 -1
- package/cjs/drivers/postgres/postgres-query-parser.d.ts +0 -328
- package/cjs/drivers/postgres/postgres-query-parser.d.ts.map +0 -1
- package/cjs/drivers/postgres/postgres-query-parser.js +0 -868
- package/cjs/drivers/postgres/postgres-query-parser.js.map +0 -1
- package/cjs/drivers/postgres/postgres-sql-serializer.d.ts +0 -37
- package/cjs/drivers/postgres/postgres-sql-serializer.d.ts.map +0 -1
- package/cjs/drivers/postgres/postgres-sql-serializer.js +0 -400
- package/cjs/drivers/postgres/postgres-sql-serializer.js.map +0 -1
- package/cjs/drivers/postgres/postgres-sync-adapter.d.ts +0 -83
- package/cjs/drivers/postgres/postgres-sync-adapter.d.ts.map +0 -1
- package/cjs/drivers/postgres/postgres-sync-adapter.js +0 -204
- package/cjs/drivers/postgres/postgres-sync-adapter.js.map +0 -1
- package/cjs/drivers/postgres/types.d.ts +0 -144
- package/cjs/drivers/postgres/types.d.ts.map +0 -1
- package/cjs/drivers/sql/index.d.ts +0 -10
- package/cjs/drivers/sql/index.d.ts.map +0 -1
- package/cjs/drivers/sql/sql-dialect.contract.d.ts +0 -204
- package/cjs/drivers/sql/sql-dialect.contract.d.ts.map +0 -1
- package/cjs/drivers/sql/sql-types.d.ts +0 -202
- package/cjs/drivers/sql/sql-types.d.ts.map +0 -1
- package/cjs/errors/missing-data-source.error.d.ts +0 -22
- package/cjs/errors/missing-data-source.error.d.ts.map +0 -1
- package/cjs/errors/missing-data-source.error.js +0 -29
- package/cjs/errors/missing-data-source.error.js.map +0 -1
- package/cjs/errors/transaction-rollback.error.d.ts +0 -20
- package/cjs/errors/transaction-rollback.error.d.ts.map +0 -1
- package/cjs/errors/transaction-rollback.error.js +0 -27
- package/cjs/errors/transaction-rollback.error.js.map +0 -1
- package/cjs/events/model-events.d.ts +0 -231
- package/cjs/events/model-events.d.ts.map +0 -1
- package/cjs/events/model-events.js +0 -259
- package/cjs/events/model-events.js.map +0 -1
- package/cjs/expressions/aggregate-expressions.d.ts +0 -215
- package/cjs/expressions/aggregate-expressions.d.ts.map +0 -1
- package/cjs/expressions/aggregate-expressions.js +0 -221
- package/cjs/expressions/aggregate-expressions.js.map +0 -1
- package/cjs/expressions/index.d.ts +0 -2
- package/cjs/expressions/index.d.ts.map +0 -1
- package/cjs/index.d.ts +0 -45
- package/cjs/index.d.ts.map +0 -1
- package/cjs/index.js +0 -1
- package/cjs/index.js.map +0 -1
- package/cjs/migration/column-builder.d.ts +0 -417
- package/cjs/migration/column-builder.d.ts.map +0 -1
- package/cjs/migration/column-builder.js +0 -586
- package/cjs/migration/column-builder.js.map +0 -1
- package/cjs/migration/column-helpers.d.ts +0 -275
- package/cjs/migration/column-helpers.d.ts.map +0 -1
- package/cjs/migration/column-helpers.js +0 -389
- package/cjs/migration/column-helpers.js.map +0 -1
- package/cjs/migration/foreign-key-builder.d.ts +0 -103
- package/cjs/migration/foreign-key-builder.d.ts.map +0 -1
- package/cjs/migration/foreign-key-builder.js +0 -121
- package/cjs/migration/foreign-key-builder.js.map +0 -1
- package/cjs/migration/index.d.ts +0 -7
- package/cjs/migration/index.d.ts.map +0 -1
- package/cjs/migration/migration-runner.d.ts +0 -278
- package/cjs/migration/migration-runner.d.ts.map +0 -1
- package/cjs/migration/migration-runner.js +0 -815
- package/cjs/migration/migration-runner.js.map +0 -1
- package/cjs/migration/migration.d.ts +0 -1988
- package/cjs/migration/migration.d.ts.map +0 -1
- package/cjs/migration/migration.js +0 -2162
- package/cjs/migration/migration.js.map +0 -1
- package/cjs/migration/sql-grammar.d.ts +0 -61
- package/cjs/migration/sql-grammar.d.ts.map +0 -1
- package/cjs/migration/sql-grammar.js +0 -164
- package/cjs/migration/sql-grammar.js.map +0 -1
- package/cjs/migration/sql-serializer.d.ts +0 -22
- package/cjs/migration/sql-serializer.d.ts.map +0 -1
- package/cjs/migration/sql-serializer.js +0 -26
- package/cjs/migration/sql-serializer.js.map +0 -1
- package/cjs/migration/types.d.ts +0 -155
- package/cjs/migration/types.d.ts.map +0 -1
- package/cjs/model/methods/accessor-methods.d.ts +0 -13
- package/cjs/model/methods/accessor-methods.d.ts.map +0 -1
- package/cjs/model/methods/accessor-methods.js +0 -51
- package/cjs/model/methods/accessor-methods.js.map +0 -1
- package/cjs/model/methods/delete-methods.d.ts +0 -10
- package/cjs/model/methods/delete-methods.d.ts.map +0 -1
- package/cjs/model/methods/delete-methods.js +0 -10
- package/cjs/model/methods/delete-methods.js.map +0 -1
- package/cjs/model/methods/dirty-methods.d.ts +0 -10
- package/cjs/model/methods/dirty-methods.d.ts.map +0 -1
- package/cjs/model/methods/dirty-methods.js +0 -15
- package/cjs/model/methods/dirty-methods.js.map +0 -1
- package/cjs/model/methods/hydration-methods.d.ts +0 -10
- package/cjs/model/methods/hydration-methods.d.ts.map +0 -1
- package/cjs/model/methods/hydration-methods.js +0 -57
- package/cjs/model/methods/hydration-methods.js.map +0 -1
- package/cjs/model/methods/instance-event-methods.d.ts +0 -7
- package/cjs/model/methods/instance-event-methods.d.ts.map +0 -1
- package/cjs/model/methods/instance-event-methods.js +0 -15
- package/cjs/model/methods/instance-event-methods.js.map +0 -1
- package/cjs/model/methods/meta-methods.d.ts +0 -7
- package/cjs/model/methods/meta-methods.d.ts.map +0 -1
- package/cjs/model/methods/meta-methods.js +0 -78
- package/cjs/model/methods/meta-methods.js.map +0 -1
- package/cjs/model/methods/query-methods.d.ts +0 -24
- package/cjs/model/methods/query-methods.d.ts.map +0 -1
- package/cjs/model/methods/query-methods.js +0 -164
- package/cjs/model/methods/query-methods.js.map +0 -1
- package/cjs/model/methods/restore-methods.d.ts +0 -10
- package/cjs/model/methods/restore-methods.d.ts.map +0 -1
- package/cjs/model/methods/restore-methods.js +0 -13
- package/cjs/model/methods/restore-methods.js.map +0 -1
- package/cjs/model/methods/scope-methods.d.ts +0 -7
- package/cjs/model/methods/scope-methods.d.ts.map +0 -1
- package/cjs/model/methods/scope-methods.js +0 -15
- package/cjs/model/methods/scope-methods.js.map +0 -1
- package/cjs/model/methods/serialization-methods.d.ts +0 -3
- package/cjs/model/methods/serialization-methods.d.ts.map +0 -1
- package/cjs/model/methods/serialization-methods.js +0 -27
- package/cjs/model/methods/serialization-methods.js.map +0 -1
- package/cjs/model/methods/static-event-methods.d.ts +0 -9
- package/cjs/model/methods/static-event-methods.d.ts.map +0 -1
- package/cjs/model/methods/static-event-methods.js +0 -29
- package/cjs/model/methods/static-event-methods.js.map +0 -1
- package/cjs/model/methods/write-methods.d.ts +0 -10
- package/cjs/model/methods/write-methods.d.ts.map +0 -1
- package/cjs/model/methods/write-methods.js +0 -52
- package/cjs/model/methods/write-methods.js.map +0 -1
- package/cjs/model/model.d.ts +0 -1647
- package/cjs/model/model.d.ts.map +0 -1
- package/cjs/model/model.js +0 -1657
- package/cjs/model/model.js.map +0 -1
- package/cjs/model/model.types.d.ts +0 -44
- package/cjs/model/model.types.d.ts.map +0 -1
- package/cjs/model/register-model.d.ts +0 -81
- package/cjs/model/register-model.d.ts.map +0 -1
- package/cjs/model/register-model.js +0 -94
- package/cjs/model/register-model.js.map +0 -1
- package/cjs/query-builder/query-builder.d.ts +0 -556
- package/cjs/query-builder/query-builder.d.ts.map +0 -1
- package/cjs/query-builder/query-builder.js +0 -1070
- package/cjs/query-builder/query-builder.js.map +0 -1
- package/cjs/relations/helpers.d.ts +0 -156
- package/cjs/relations/helpers.d.ts.map +0 -1
- package/cjs/relations/helpers.js +0 -202
- package/cjs/relations/helpers.js.map +0 -1
- package/cjs/relations/index.d.ts +0 -35
- package/cjs/relations/index.d.ts.map +0 -1
- package/cjs/relations/pivot-operations.d.ts +0 -160
- package/cjs/relations/pivot-operations.d.ts.map +0 -1
- package/cjs/relations/pivot-operations.js +0 -293
- package/cjs/relations/pivot-operations.js.map +0 -1
- package/cjs/relations/relation-hydrator.d.ts +0 -68
- package/cjs/relations/relation-hydrator.d.ts.map +0 -1
- package/cjs/relations/relation-hydrator.js +0 -81
- package/cjs/relations/relation-hydrator.js.map +0 -1
- package/cjs/relations/relation-loader.d.ts +0 -194
- package/cjs/relations/relation-loader.d.ts.map +0 -1
- package/cjs/relations/relation-loader.js +0 -466
- package/cjs/relations/relation-loader.js.map +0 -1
- package/cjs/relations/types.d.ts +0 -306
- package/cjs/relations/types.d.ts.map +0 -1
- package/cjs/remover/database-remover.d.ts +0 -100
- package/cjs/remover/database-remover.d.ts.map +0 -1
- package/cjs/remover/database-remover.js +0 -214
- package/cjs/remover/database-remover.js.map +0 -1
- package/cjs/restorer/database-restorer.d.ts +0 -131
- package/cjs/restorer/database-restorer.d.ts.map +0 -1
- package/cjs/restorer/database-restorer.js +0 -434
- package/cjs/restorer/database-restorer.js.map +0 -1
- package/cjs/sql-database-dirty-tracker.d.ts +0 -13
- package/cjs/sql-database-dirty-tracker.d.ts.map +0 -1
- package/cjs/sql-database-dirty-tracker.js +0 -14
- package/cjs/sql-database-dirty-tracker.js.map +0 -1
- package/cjs/sync/index.d.ts +0 -12
- package/cjs/sync/index.d.ts.map +0 -1
- package/cjs/sync/model-events.d.ts +0 -62
- package/cjs/sync/model-events.d.ts.map +0 -1
- package/cjs/sync/model-events.js +0 -49
- package/cjs/sync/model-events.js.map +0 -1
- package/cjs/sync/model-sync-operation.d.ts +0 -163
- package/cjs/sync/model-sync-operation.d.ts.map +0 -1
- package/cjs/sync/model-sync-operation.js +0 -292
- package/cjs/sync/model-sync-operation.js.map +0 -1
- package/cjs/sync/model-sync.d.ts +0 -130
- package/cjs/sync/model-sync.d.ts.map +0 -1
- package/cjs/sync/model-sync.js +0 -178
- package/cjs/sync/model-sync.js.map +0 -1
- package/cjs/sync/sync-context.d.ts +0 -70
- package/cjs/sync/sync-context.d.ts.map +0 -1
- package/cjs/sync/sync-context.js +0 -101
- package/cjs/sync/sync-context.js.map +0 -1
- package/cjs/sync/sync-manager.d.ts +0 -213
- package/cjs/sync/sync-manager.d.ts.map +0 -1
- package/cjs/sync/sync-manager.js +0 -689
- package/cjs/sync/sync-manager.js.map +0 -1
- package/cjs/sync/types.d.ts +0 -289
- package/cjs/sync/types.d.ts.map +0 -1
- package/cjs/test-migrations/test-enhanced-features.migration.d.ts +0 -15
- package/cjs/test-migrations/test-enhanced-features.migration.d.ts.map +0 -1
- package/cjs/types.d.ts +0 -371
- package/cjs/types.d.ts.map +0 -1
- package/cjs/utils/connect-to-database.d.ts +0 -307
- package/cjs/utils/connect-to-database.d.ts.map +0 -1
- package/cjs/utils/connect-to-database.js +0 -130
- package/cjs/utils/connect-to-database.js.map +0 -1
- package/cjs/utils/database-writer.utils.d.ts +0 -15
- package/cjs/utils/database-writer.utils.d.ts.map +0 -1
- package/cjs/utils/database-writer.utils.js +0 -14
- package/cjs/utils/database-writer.utils.js.map +0 -1
- package/cjs/utils/define-model.js +0 -100
- package/cjs/utils/define-model.js.map +0 -1
- package/cjs/utils/is-valid-date-value.d.ts +0 -5
- package/cjs/utils/is-valid-date-value.d.ts.map +0 -1
- package/cjs/utils/is-valid-date-value.js +0 -25
- package/cjs/utils/is-valid-date-value.js.map +0 -1
- package/cjs/utils/once-connected.d.ts +0 -146
- package/cjs/utils/once-connected.d.ts.map +0 -1
- package/cjs/utils/once-connected.js +0 -251
- package/cjs/utils/once-connected.js.map +0 -1
- package/cjs/validation/database-seal-plugins.d.ts +0 -12
- package/cjs/validation/database-seal-plugins.d.ts.map +0 -1
- package/cjs/validation/database-seal-plugins.js +0 -1
- package/cjs/validation/database-seal-plugins.js.map +0 -1
- package/cjs/validation/database-writer-validation-error.d.ts +0 -97
- package/cjs/validation/database-writer-validation-error.d.ts.map +0 -1
- package/cjs/validation/database-writer-validation-error.js +0 -160
- package/cjs/validation/database-writer-validation-error.js.map +0 -1
- package/cjs/validation/index.d.ts +0 -3
- package/cjs/validation/index.d.ts.map +0 -1
- package/cjs/validation/mutators/embed-mutator.d.ts +0 -9
- package/cjs/validation/mutators/embed-mutator.d.ts.map +0 -1
- package/cjs/validation/mutators/embed-mutator.js +0 -33
- package/cjs/validation/mutators/embed-mutator.js.map +0 -1
- package/cjs/validation/plugins/embed-validator-plugin.d.ts +0 -24
- package/cjs/validation/plugins/embed-validator-plugin.d.ts.map +0 -1
- package/cjs/validation/plugins/embed-validator-plugin.js +0 -18
- package/cjs/validation/plugins/embed-validator-plugin.js.map +0 -1
- package/cjs/validation/rules/database-model-rule.d.ts +0 -7
- package/cjs/validation/rules/database-model-rule.d.ts.map +0 -1
- package/cjs/validation/rules/database-model-rule.js +0 -27
- package/cjs/validation/rules/database-model-rule.js.map +0 -1
- package/cjs/validation/transformers/embed-model-transformer.d.ts +0 -3
- package/cjs/validation/transformers/embed-model-transformer.d.ts.map +0 -1
- package/cjs/validation/transformers/embed-model-transformer.js +0 -18
- package/cjs/validation/transformers/embed-model-transformer.js.map +0 -1
- package/cjs/validation/validators/embed-validator.d.ts +0 -21
- package/cjs/validation/validators/embed-validator.d.ts.map +0 -1
- package/cjs/validation/validators/embed-validator.js +0 -43
- package/cjs/validation/validators/embed-validator.js.map +0 -1
- package/cjs/writer/database-writer.d.ts +0 -174
- package/cjs/writer/database-writer.d.ts.map +0 -1
- package/cjs/writer/database-writer.js +0 -400
- package/cjs/writer/database-writer.js.map +0 -1
- package/esm/context/database-data-source-context.d.ts +0 -29
- package/esm/context/database-data-source-context.d.ts.map +0 -1
- package/esm/context/database-data-source-context.js +0 -28
- package/esm/context/database-data-source-context.js.map +0 -1
- package/esm/context/database-transaction-context.d.ts +0 -35
- package/esm/context/database-transaction-context.d.ts.map +0 -1
- package/esm/context/database-transaction-context.js +0 -40
- package/esm/context/database-transaction-context.js.map +0 -1
- package/esm/contracts/database-driver.contract.d.ts +0 -450
- package/esm/contracts/database-driver.contract.d.ts.map +0 -1
- package/esm/contracts/database-id-generator.contract.d.ts +0 -109
- package/esm/contracts/database-id-generator.contract.d.ts.map +0 -1
- package/esm/contracts/database-remover.contract.d.ts +0 -104
- package/esm/contracts/database-remover.contract.d.ts.map +0 -1
- package/esm/contracts/database-restorer.contract.d.ts +0 -143
- package/esm/contracts/database-restorer.contract.d.ts.map +0 -1
- package/esm/contracts/database-writer.contract.d.ts +0 -119
- package/esm/contracts/database-writer.contract.d.ts.map +0 -1
- package/esm/contracts/driver-blueprint.contract.d.ts +0 -49
- package/esm/contracts/driver-blueprint.contract.d.ts.map +0 -1
- package/esm/contracts/index.d.ts +0 -10
- package/esm/contracts/index.d.ts.map +0 -1
- package/esm/contracts/migration-driver.contract.d.ts +0 -522
- package/esm/contracts/migration-driver.contract.d.ts.map +0 -1
- package/esm/contracts/query-builder.contract.d.ts +0 -1609
- package/esm/contracts/query-builder.contract.d.ts.map +0 -1
- package/esm/contracts/sync-adapter.contract.d.ts +0 -58
- package/esm/contracts/sync-adapter.contract.d.ts.map +0 -1
- package/esm/data-source/data-source-registry.d.ts +0 -108
- package/esm/data-source/data-source-registry.d.ts.map +0 -1
- package/esm/data-source/data-source-registry.js +0 -145
- package/esm/data-source/data-source-registry.js.map +0 -1
- package/esm/data-source/data-source.d.ts +0 -147
- package/esm/data-source/data-source.d.ts.map +0 -1
- package/esm/data-source/data-source.js +0 -83
- package/esm/data-source/data-source.js.map +0 -1
- package/esm/database-dirty-tracker.d.ts +0 -252
- package/esm/database-dirty-tracker.d.ts.map +0 -1
- package/esm/database-dirty-tracker.js +0 -386
- package/esm/database-dirty-tracker.js.map +0 -1
- package/esm/drivers/mongodb/mongodb-blueprint.d.ts +0 -30
- package/esm/drivers/mongodb/mongodb-blueprint.d.ts.map +0 -1
- package/esm/drivers/mongodb/mongodb-blueprint.js +0 -51
- package/esm/drivers/mongodb/mongodb-blueprint.js.map +0 -1
- package/esm/drivers/mongodb/mongodb-driver.d.ts +0 -325
- package/esm/drivers/mongodb/mongodb-driver.d.ts.map +0 -1
- package/esm/drivers/mongodb/mongodb-driver.js +0 -845
- package/esm/drivers/mongodb/mongodb-driver.js.map +0 -1
- package/esm/drivers/mongodb/mongodb-id-generator.d.ts +0 -116
- package/esm/drivers/mongodb/mongodb-id-generator.d.ts.map +0 -1
- package/esm/drivers/mongodb/mongodb-id-generator.js +0 -149
- package/esm/drivers/mongodb/mongodb-id-generator.js.map +0 -1
- package/esm/drivers/mongodb/mongodb-migration-driver.d.ts +0 -317
- package/esm/drivers/mongodb/mongodb-migration-driver.d.ts.map +0 -1
- package/esm/drivers/mongodb/mongodb-migration-driver.js +0 -666
- package/esm/drivers/mongodb/mongodb-migration-driver.js.map +0 -1
- package/esm/drivers/mongodb/mongodb-query-builder.d.ts +0 -1122
- package/esm/drivers/mongodb/mongodb-query-builder.d.ts.map +0 -1
- package/esm/drivers/mongodb/mongodb-query-builder.js +0 -1988
- package/esm/drivers/mongodb/mongodb-query-builder.js.map +0 -1
- package/esm/drivers/mongodb/mongodb-query-operations.d.ts +0 -226
- package/esm/drivers/mongodb/mongodb-query-operations.d.ts.map +0 -1
- package/esm/drivers/mongodb/mongodb-query-operations.js +0 -270
- package/esm/drivers/mongodb/mongodb-query-operations.js.map +0 -1
- package/esm/drivers/mongodb/mongodb-query-parser.d.ts +0 -262
- package/esm/drivers/mongodb/mongodb-query-parser.d.ts.map +0 -1
- package/esm/drivers/mongodb/mongodb-query-parser.js +0 -1351
- package/esm/drivers/mongodb/mongodb-query-parser.js.map +0 -1
- package/esm/drivers/mongodb/mongodb-sync-adapter.d.ts +0 -79
- package/esm/drivers/mongodb/mongodb-sync-adapter.d.ts.map +0 -1
- package/esm/drivers/mongodb/mongodb-sync-adapter.js +0 -146
- package/esm/drivers/mongodb/mongodb-sync-adapter.js.map +0 -1
- package/esm/drivers/mongodb/types.d.ts +0 -43
- package/esm/drivers/mongodb/types.d.ts.map +0 -1
- package/esm/drivers/postgres/index.d.ts +0 -16
- package/esm/drivers/postgres/index.d.ts.map +0 -1
- package/esm/drivers/postgres/postgres-blueprint.d.ts +0 -64
- package/esm/drivers/postgres/postgres-blueprint.d.ts.map +0 -1
- package/esm/drivers/postgres/postgres-blueprint.js +0 -121
- package/esm/drivers/postgres/postgres-blueprint.js.map +0 -1
- package/esm/drivers/postgres/postgres-dialect.d.ts +0 -136
- package/esm/drivers/postgres/postgres-dialect.d.ts.map +0 -1
- package/esm/drivers/postgres/postgres-dialect.js +0 -268
- package/esm/drivers/postgres/postgres-dialect.js.map +0 -1
- package/esm/drivers/postgres/postgres-driver.d.ts +0 -432
- package/esm/drivers/postgres/postgres-driver.d.ts.map +0 -1
- package/esm/drivers/postgres/postgres-driver.js +0 -1008
- package/esm/drivers/postgres/postgres-driver.js.map +0 -1
- package/esm/drivers/postgres/postgres-migration-driver.d.ts +0 -397
- package/esm/drivers/postgres/postgres-migration-driver.d.ts.map +0 -1
- package/esm/drivers/postgres/postgres-migration-driver.js +0 -900
- package/esm/drivers/postgres/postgres-migration-driver.js.map +0 -1
- package/esm/drivers/postgres/postgres-query-builder.d.ts +0 -254
- package/esm/drivers/postgres/postgres-query-builder.d.ts.map +0 -1
- package/esm/drivers/postgres/postgres-query-builder.js +0 -933
- package/esm/drivers/postgres/postgres-query-builder.js.map +0 -1
- package/esm/drivers/postgres/postgres-query-parser.d.ts +0 -328
- package/esm/drivers/postgres/postgres-query-parser.d.ts.map +0 -1
- package/esm/drivers/postgres/postgres-query-parser.js +0 -868
- package/esm/drivers/postgres/postgres-query-parser.js.map +0 -1
- package/esm/drivers/postgres/postgres-sql-serializer.d.ts +0 -37
- package/esm/drivers/postgres/postgres-sql-serializer.d.ts.map +0 -1
- package/esm/drivers/postgres/postgres-sql-serializer.js +0 -400
- package/esm/drivers/postgres/postgres-sql-serializer.js.map +0 -1
- package/esm/drivers/postgres/postgres-sync-adapter.d.ts +0 -83
- package/esm/drivers/postgres/postgres-sync-adapter.d.ts.map +0 -1
- package/esm/drivers/postgres/postgres-sync-adapter.js +0 -204
- package/esm/drivers/postgres/postgres-sync-adapter.js.map +0 -1
- package/esm/drivers/postgres/types.d.ts +0 -144
- package/esm/drivers/postgres/types.d.ts.map +0 -1
- package/esm/drivers/sql/index.d.ts +0 -10
- package/esm/drivers/sql/index.d.ts.map +0 -1
- package/esm/drivers/sql/sql-dialect.contract.d.ts +0 -204
- package/esm/drivers/sql/sql-dialect.contract.d.ts.map +0 -1
- package/esm/drivers/sql/sql-types.d.ts +0 -202
- package/esm/drivers/sql/sql-types.d.ts.map +0 -1
- package/esm/errors/missing-data-source.error.d.ts +0 -22
- package/esm/errors/missing-data-source.error.d.ts.map +0 -1
- package/esm/errors/missing-data-source.error.js +0 -29
- package/esm/errors/missing-data-source.error.js.map +0 -1
- package/esm/errors/transaction-rollback.error.d.ts +0 -20
- package/esm/errors/transaction-rollback.error.d.ts.map +0 -1
- package/esm/errors/transaction-rollback.error.js +0 -27
- package/esm/errors/transaction-rollback.error.js.map +0 -1
- package/esm/events/model-events.d.ts +0 -231
- package/esm/events/model-events.d.ts.map +0 -1
- package/esm/events/model-events.js +0 -259
- package/esm/events/model-events.js.map +0 -1
- package/esm/expressions/aggregate-expressions.d.ts +0 -215
- package/esm/expressions/aggregate-expressions.d.ts.map +0 -1
- package/esm/expressions/aggregate-expressions.js +0 -221
- package/esm/expressions/aggregate-expressions.js.map +0 -1
- package/esm/expressions/index.d.ts +0 -2
- package/esm/expressions/index.d.ts.map +0 -1
- package/esm/index.d.ts +0 -45
- package/esm/index.d.ts.map +0 -1
- package/esm/index.js +0 -1
- package/esm/index.js.map +0 -1
- package/esm/migration/column-builder.d.ts +0 -417
- package/esm/migration/column-builder.d.ts.map +0 -1
- package/esm/migration/column-builder.js +0 -586
- package/esm/migration/column-builder.js.map +0 -1
- package/esm/migration/column-helpers.d.ts +0 -275
- package/esm/migration/column-helpers.d.ts.map +0 -1
- package/esm/migration/column-helpers.js +0 -389
- package/esm/migration/column-helpers.js.map +0 -1
- package/esm/migration/foreign-key-builder.d.ts +0 -103
- package/esm/migration/foreign-key-builder.d.ts.map +0 -1
- package/esm/migration/foreign-key-builder.js +0 -121
- package/esm/migration/foreign-key-builder.js.map +0 -1
- package/esm/migration/index.d.ts +0 -7
- package/esm/migration/index.d.ts.map +0 -1
- package/esm/migration/migration-runner.d.ts +0 -278
- package/esm/migration/migration-runner.d.ts.map +0 -1
- package/esm/migration/migration-runner.js +0 -815
- package/esm/migration/migration-runner.js.map +0 -1
- package/esm/migration/migration.d.ts +0 -1988
- package/esm/migration/migration.d.ts.map +0 -1
- package/esm/migration/migration.js +0 -2162
- package/esm/migration/migration.js.map +0 -1
- package/esm/migration/sql-grammar.d.ts +0 -61
- package/esm/migration/sql-grammar.d.ts.map +0 -1
- package/esm/migration/sql-grammar.js +0 -164
- package/esm/migration/sql-grammar.js.map +0 -1
- package/esm/migration/sql-serializer.d.ts +0 -22
- package/esm/migration/sql-serializer.d.ts.map +0 -1
- package/esm/migration/sql-serializer.js +0 -26
- package/esm/migration/sql-serializer.js.map +0 -1
- package/esm/migration/types.d.ts +0 -155
- package/esm/migration/types.d.ts.map +0 -1
- package/esm/model/methods/accessor-methods.d.ts +0 -13
- package/esm/model/methods/accessor-methods.d.ts.map +0 -1
- package/esm/model/methods/accessor-methods.js +0 -51
- package/esm/model/methods/accessor-methods.js.map +0 -1
- package/esm/model/methods/delete-methods.d.ts +0 -10
- package/esm/model/methods/delete-methods.d.ts.map +0 -1
- package/esm/model/methods/delete-methods.js +0 -10
- package/esm/model/methods/delete-methods.js.map +0 -1
- package/esm/model/methods/dirty-methods.d.ts +0 -10
- package/esm/model/methods/dirty-methods.d.ts.map +0 -1
- package/esm/model/methods/dirty-methods.js +0 -15
- package/esm/model/methods/dirty-methods.js.map +0 -1
- package/esm/model/methods/hydration-methods.d.ts +0 -10
- package/esm/model/methods/hydration-methods.d.ts.map +0 -1
- package/esm/model/methods/hydration-methods.js +0 -57
- package/esm/model/methods/hydration-methods.js.map +0 -1
- package/esm/model/methods/instance-event-methods.d.ts +0 -7
- package/esm/model/methods/instance-event-methods.d.ts.map +0 -1
- package/esm/model/methods/instance-event-methods.js +0 -15
- package/esm/model/methods/instance-event-methods.js.map +0 -1
- package/esm/model/methods/meta-methods.d.ts +0 -7
- package/esm/model/methods/meta-methods.d.ts.map +0 -1
- package/esm/model/methods/meta-methods.js +0 -78
- package/esm/model/methods/meta-methods.js.map +0 -1
- package/esm/model/methods/query-methods.d.ts +0 -24
- package/esm/model/methods/query-methods.d.ts.map +0 -1
- package/esm/model/methods/query-methods.js +0 -164
- package/esm/model/methods/query-methods.js.map +0 -1
- package/esm/model/methods/restore-methods.d.ts +0 -10
- package/esm/model/methods/restore-methods.d.ts.map +0 -1
- package/esm/model/methods/restore-methods.js +0 -13
- package/esm/model/methods/restore-methods.js.map +0 -1
- package/esm/model/methods/scope-methods.d.ts +0 -7
- package/esm/model/methods/scope-methods.d.ts.map +0 -1
- package/esm/model/methods/scope-methods.js +0 -15
- package/esm/model/methods/scope-methods.js.map +0 -1
- package/esm/model/methods/serialization-methods.d.ts +0 -3
- package/esm/model/methods/serialization-methods.d.ts.map +0 -1
- package/esm/model/methods/serialization-methods.js +0 -27
- package/esm/model/methods/serialization-methods.js.map +0 -1
- package/esm/model/methods/static-event-methods.d.ts +0 -9
- package/esm/model/methods/static-event-methods.d.ts.map +0 -1
- package/esm/model/methods/static-event-methods.js +0 -29
- package/esm/model/methods/static-event-methods.js.map +0 -1
- package/esm/model/methods/write-methods.d.ts +0 -10
- package/esm/model/methods/write-methods.d.ts.map +0 -1
- package/esm/model/methods/write-methods.js +0 -52
- package/esm/model/methods/write-methods.js.map +0 -1
- package/esm/model/model.d.ts +0 -1647
- package/esm/model/model.d.ts.map +0 -1
- package/esm/model/model.js +0 -1657
- package/esm/model/model.js.map +0 -1
- package/esm/model/model.types.d.ts +0 -44
- package/esm/model/model.types.d.ts.map +0 -1
- package/esm/model/register-model.d.ts +0 -81
- package/esm/model/register-model.d.ts.map +0 -1
- package/esm/model/register-model.js +0 -94
- package/esm/model/register-model.js.map +0 -1
- package/esm/query-builder/query-builder.d.ts +0 -556
- package/esm/query-builder/query-builder.d.ts.map +0 -1
- package/esm/query-builder/query-builder.js +0 -1070
- package/esm/query-builder/query-builder.js.map +0 -1
- package/esm/relations/helpers.d.ts +0 -156
- package/esm/relations/helpers.d.ts.map +0 -1
- package/esm/relations/helpers.js +0 -202
- package/esm/relations/helpers.js.map +0 -1
- package/esm/relations/index.d.ts +0 -35
- package/esm/relations/index.d.ts.map +0 -1
- package/esm/relations/pivot-operations.d.ts +0 -160
- package/esm/relations/pivot-operations.d.ts.map +0 -1
- package/esm/relations/pivot-operations.js +0 -293
- package/esm/relations/pivot-operations.js.map +0 -1
- package/esm/relations/relation-hydrator.d.ts +0 -68
- package/esm/relations/relation-hydrator.d.ts.map +0 -1
- package/esm/relations/relation-hydrator.js +0 -81
- package/esm/relations/relation-hydrator.js.map +0 -1
- package/esm/relations/relation-loader.d.ts +0 -194
- package/esm/relations/relation-loader.d.ts.map +0 -1
- package/esm/relations/relation-loader.js +0 -466
- package/esm/relations/relation-loader.js.map +0 -1
- package/esm/relations/types.d.ts +0 -306
- package/esm/relations/types.d.ts.map +0 -1
- package/esm/remover/database-remover.d.ts +0 -100
- package/esm/remover/database-remover.d.ts.map +0 -1
- package/esm/remover/database-remover.js +0 -214
- package/esm/remover/database-remover.js.map +0 -1
- package/esm/restorer/database-restorer.d.ts +0 -131
- package/esm/restorer/database-restorer.d.ts.map +0 -1
- package/esm/restorer/database-restorer.js +0 -434
- package/esm/restorer/database-restorer.js.map +0 -1
- package/esm/sql-database-dirty-tracker.d.ts +0 -13
- package/esm/sql-database-dirty-tracker.d.ts.map +0 -1
- package/esm/sql-database-dirty-tracker.js +0 -14
- package/esm/sql-database-dirty-tracker.js.map +0 -1
- package/esm/sync/index.d.ts +0 -12
- package/esm/sync/index.d.ts.map +0 -1
- package/esm/sync/model-events.d.ts +0 -62
- package/esm/sync/model-events.d.ts.map +0 -1
- package/esm/sync/model-events.js +0 -49
- package/esm/sync/model-events.js.map +0 -1
- package/esm/sync/model-sync-operation.d.ts +0 -163
- package/esm/sync/model-sync-operation.d.ts.map +0 -1
- package/esm/sync/model-sync-operation.js +0 -292
- package/esm/sync/model-sync-operation.js.map +0 -1
- package/esm/sync/model-sync.d.ts +0 -130
- package/esm/sync/model-sync.d.ts.map +0 -1
- package/esm/sync/model-sync.js +0 -178
- package/esm/sync/model-sync.js.map +0 -1
- package/esm/sync/sync-context.d.ts +0 -70
- package/esm/sync/sync-context.d.ts.map +0 -1
- package/esm/sync/sync-context.js +0 -101
- package/esm/sync/sync-context.js.map +0 -1
- package/esm/sync/sync-manager.d.ts +0 -213
- package/esm/sync/sync-manager.d.ts.map +0 -1
- package/esm/sync/sync-manager.js +0 -689
- package/esm/sync/sync-manager.js.map +0 -1
- package/esm/sync/types.d.ts +0 -289
- package/esm/sync/types.d.ts.map +0 -1
- package/esm/test-migrations/test-enhanced-features.migration.d.ts +0 -15
- package/esm/test-migrations/test-enhanced-features.migration.d.ts.map +0 -1
- package/esm/types.d.ts +0 -371
- package/esm/types.d.ts.map +0 -1
- package/esm/utils/connect-to-database.d.ts +0 -307
- package/esm/utils/connect-to-database.d.ts.map +0 -1
- package/esm/utils/connect-to-database.js +0 -130
- package/esm/utils/connect-to-database.js.map +0 -1
- package/esm/utils/database-writer.utils.d.ts +0 -15
- package/esm/utils/database-writer.utils.d.ts.map +0 -1
- package/esm/utils/database-writer.utils.js +0 -14
- package/esm/utils/database-writer.utils.js.map +0 -1
- package/esm/utils/define-model.js +0 -100
- package/esm/utils/define-model.js.map +0 -1
- package/esm/utils/is-valid-date-value.d.ts +0 -5
- package/esm/utils/is-valid-date-value.d.ts.map +0 -1
- package/esm/utils/is-valid-date-value.js +0 -25
- package/esm/utils/is-valid-date-value.js.map +0 -1
- package/esm/utils/once-connected.d.ts +0 -146
- package/esm/utils/once-connected.d.ts.map +0 -1
- package/esm/utils/once-connected.js +0 -251
- package/esm/utils/once-connected.js.map +0 -1
- package/esm/validation/database-seal-plugins.d.ts +0 -12
- package/esm/validation/database-seal-plugins.d.ts.map +0 -1
- package/esm/validation/database-seal-plugins.js +0 -1
- package/esm/validation/database-seal-plugins.js.map +0 -1
- package/esm/validation/database-writer-validation-error.d.ts +0 -97
- package/esm/validation/database-writer-validation-error.d.ts.map +0 -1
- package/esm/validation/database-writer-validation-error.js +0 -160
- package/esm/validation/database-writer-validation-error.js.map +0 -1
- package/esm/validation/index.d.ts +0 -3
- package/esm/validation/index.d.ts.map +0 -1
- package/esm/validation/mutators/embed-mutator.d.ts +0 -9
- package/esm/validation/mutators/embed-mutator.d.ts.map +0 -1
- package/esm/validation/mutators/embed-mutator.js +0 -33
- package/esm/validation/mutators/embed-mutator.js.map +0 -1
- package/esm/validation/plugins/embed-validator-plugin.d.ts +0 -24
- package/esm/validation/plugins/embed-validator-plugin.d.ts.map +0 -1
- package/esm/validation/plugins/embed-validator-plugin.js +0 -18
- package/esm/validation/plugins/embed-validator-plugin.js.map +0 -1
- package/esm/validation/rules/database-model-rule.d.ts +0 -7
- package/esm/validation/rules/database-model-rule.d.ts.map +0 -1
- package/esm/validation/rules/database-model-rule.js +0 -27
- package/esm/validation/rules/database-model-rule.js.map +0 -1
- package/esm/validation/transformers/embed-model-transformer.d.ts +0 -3
- package/esm/validation/transformers/embed-model-transformer.d.ts.map +0 -1
- package/esm/validation/transformers/embed-model-transformer.js +0 -18
- package/esm/validation/transformers/embed-model-transformer.js.map +0 -1
- package/esm/validation/validators/embed-validator.d.ts +0 -21
- package/esm/validation/validators/embed-validator.d.ts.map +0 -1
- package/esm/validation/validators/embed-validator.js +0 -43
- package/esm/validation/validators/embed-validator.js.map +0 -1
- package/esm/writer/database-writer.d.ts +0 -174
- package/esm/writer/database-writer.d.ts.map +0 -1
- package/esm/writer/database-writer.js +0 -400
- package/esm/writer/database-writer.js.map +0 -1
|
@@ -0,0 +1,760 @@
|
|
|
1
|
+
import { databaseTransactionContext } from "../../context/database-transaction-context.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../@warlock.js/cascade/src/drivers/postgres/postgres-migration-driver.ts
|
|
4
|
+
/**
|
|
5
|
+
* PostgreSQL Migration Driver
|
|
6
|
+
*
|
|
7
|
+
* Implements the MigrationDriverContract for PostgreSQL DDL operations.
|
|
8
|
+
* Provides methods for creating/dropping tables, columns, indexes,
|
|
9
|
+
* and constraints.
|
|
10
|
+
*
|
|
11
|
+
* @module cascade/drivers/postgres
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* PostgreSQL Migration Driver.
|
|
15
|
+
*
|
|
16
|
+
* Handles database schema operations for PostgreSQL including:
|
|
17
|
+
* - Table creation and deletion
|
|
18
|
+
* - Column management
|
|
19
|
+
* - Index creation (B-tree, GIN, GiST, etc.)
|
|
20
|
+
* - Constraint management (foreign keys, unique, etc.)
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const migrationDriver = driver.migrationDriver();
|
|
25
|
+
*
|
|
26
|
+
* // Create a table
|
|
27
|
+
* await migrationDriver.createTable('users');
|
|
28
|
+
*
|
|
29
|
+
* // Add columns
|
|
30
|
+
* await migrationDriver.addColumn('users', {
|
|
31
|
+
* name: 'email',
|
|
32
|
+
* type: 'string',
|
|
33
|
+
* length: 255,
|
|
34
|
+
* nullable: false
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* // Create unique index
|
|
38
|
+
* await migrationDriver.createUniqueIndex('users', ['email']);
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
var PostgresMigrationDriver = class {
|
|
42
|
+
driver;
|
|
43
|
+
/**
|
|
44
|
+
* Active transaction client (if any).
|
|
45
|
+
*/
|
|
46
|
+
get transactionClient() {
|
|
47
|
+
return databaseTransactionContext.getSession();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Create a new migration driver.
|
|
51
|
+
*
|
|
52
|
+
* @param driver - The PostgreSQL driver instance
|
|
53
|
+
*/
|
|
54
|
+
constructor(driver) {
|
|
55
|
+
this.driver = driver;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Create a new table with a default id column.
|
|
59
|
+
*
|
|
60
|
+
* @param table - Table name
|
|
61
|
+
*/
|
|
62
|
+
async createTable(table) {
|
|
63
|
+
const quotedTable = this.driver.dialect.quoteIdentifier(table);
|
|
64
|
+
await this.execute(`CREATE TABLE ${quotedTable} ()`);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Create table if it doesn't exist.
|
|
68
|
+
*
|
|
69
|
+
* @param table - Table name
|
|
70
|
+
*/
|
|
71
|
+
async createTableIfNotExists(table) {
|
|
72
|
+
const quotedTable = this.driver.dialect.quoteIdentifier(table);
|
|
73
|
+
await this.execute(`CREATE TABLE IF NOT EXISTS ${quotedTable} ()`);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Drop an existing table.
|
|
77
|
+
*
|
|
78
|
+
* @param table - Table name
|
|
79
|
+
*/
|
|
80
|
+
async dropTable(table) {
|
|
81
|
+
const quotedTable = this.driver.dialect.quoteIdentifier(table);
|
|
82
|
+
await this.execute(`DROP TABLE ${quotedTable} CASCADE`);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Drop table if it exists.
|
|
86
|
+
*
|
|
87
|
+
* @param table - Table name
|
|
88
|
+
*/
|
|
89
|
+
async dropTableIfExists(table) {
|
|
90
|
+
const quotedTable = this.driver.dialect.quoteIdentifier(table);
|
|
91
|
+
await this.execute(`DROP TABLE IF EXISTS ${quotedTable} CASCADE`);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Rename a table.
|
|
95
|
+
*
|
|
96
|
+
* @param from - Current table name
|
|
97
|
+
* @param to - New table name
|
|
98
|
+
*/
|
|
99
|
+
async renameTable(from, to) {
|
|
100
|
+
const quotedFrom = this.driver.dialect.quoteIdentifier(from);
|
|
101
|
+
const quotedTo = this.driver.dialect.quoteIdentifier(to);
|
|
102
|
+
await this.execute(`ALTER TABLE ${quotedFrom} RENAME TO ${quotedTo}`);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Truncate a table — remove all rows efficiently.
|
|
106
|
+
*
|
|
107
|
+
* @param table - Table name
|
|
108
|
+
*/
|
|
109
|
+
async truncateTable(table) {
|
|
110
|
+
const quotedTable = this.driver.dialect.quoteIdentifier(table);
|
|
111
|
+
await this.execute(`TRUNCATE TABLE ${quotedTable}`);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Check if a table exists.
|
|
115
|
+
*
|
|
116
|
+
* @param table - Table name
|
|
117
|
+
* @returns Whether the table exists
|
|
118
|
+
*/
|
|
119
|
+
async tableExists(table) {
|
|
120
|
+
return (await this.driver.query(`SELECT EXISTS (
|
|
121
|
+
SELECT FROM information_schema.tables
|
|
122
|
+
WHERE table_schema = 'public'
|
|
123
|
+
AND table_name = $1
|
|
124
|
+
)`, [table])).rows[0]?.exists ?? false;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* List all columns in a table.
|
|
128
|
+
*
|
|
129
|
+
* @param table - Table name
|
|
130
|
+
* @returns Array of column definitions
|
|
131
|
+
*/
|
|
132
|
+
async listColumns(table) {
|
|
133
|
+
return (await this.driver.query(`SELECT
|
|
134
|
+
column_name,
|
|
135
|
+
data_type,
|
|
136
|
+
character_maximum_length,
|
|
137
|
+
numeric_precision,
|
|
138
|
+
numeric_scale,
|
|
139
|
+
is_nullable,
|
|
140
|
+
column_default
|
|
141
|
+
FROM information_schema.columns
|
|
142
|
+
WHERE table_schema = 'public'
|
|
143
|
+
AND table_name = $1
|
|
144
|
+
ORDER BY ordinal_position`, [table])).rows.map((row) => ({
|
|
145
|
+
name: row.column_name,
|
|
146
|
+
type: this.mapPostgresTypeToColumnType(row.data_type),
|
|
147
|
+
length: row.character_maximum_length ?? void 0,
|
|
148
|
+
precision: row.numeric_precision ?? void 0,
|
|
149
|
+
scale: row.numeric_scale ?? void 0,
|
|
150
|
+
nullable: row.is_nullable === "YES",
|
|
151
|
+
defaultValue: row.column_default ?? void 0
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* List all tables in the current database.
|
|
156
|
+
*
|
|
157
|
+
* @returns Array of table names
|
|
158
|
+
*/
|
|
159
|
+
async listTables() {
|
|
160
|
+
return (await this.driver.query(`SELECT table_name
|
|
161
|
+
FROM information_schema.tables
|
|
162
|
+
WHERE table_schema = 'public'
|
|
163
|
+
ORDER BY table_name`)).rows.map((row) => row.table_name);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Ensure the migrations tracking table exists.
|
|
167
|
+
*
|
|
168
|
+
* Creates the table with proper schema if it doesn't exist.
|
|
169
|
+
*
|
|
170
|
+
* @param tableName - Name of the migrations table
|
|
171
|
+
*/
|
|
172
|
+
async ensureMigrationsTable(tableName) {
|
|
173
|
+
const quotedTable = this.driver.dialect.quoteIdentifier(tableName);
|
|
174
|
+
await this.execute(`
|
|
175
|
+
CREATE TABLE IF NOT EXISTS ${quotedTable} (
|
|
176
|
+
"id" SERIAL PRIMARY KEY,
|
|
177
|
+
"name" VARCHAR(255) NOT NULL UNIQUE,
|
|
178
|
+
"batch" INTEGER NOT NULL,
|
|
179
|
+
"executedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
|
|
180
|
+
"createdAt" TIMESTAMP WITH TIME ZONE
|
|
181
|
+
)
|
|
182
|
+
`);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Add a column to an existing table.
|
|
186
|
+
*
|
|
187
|
+
* @param table - Table name
|
|
188
|
+
* @param column - Column definition
|
|
189
|
+
*/
|
|
190
|
+
async addColumn(table, column) {
|
|
191
|
+
const quotedTable = this.driver.dialect.quoteIdentifier(table);
|
|
192
|
+
const quotedColumn = this.driver.dialect.quoteIdentifier(column.name);
|
|
193
|
+
let sqlType;
|
|
194
|
+
if (column.autoIncrement) if (column.type === "bigInteger") sqlType = "BIGSERIAL";
|
|
195
|
+
else sqlType = "SERIAL";
|
|
196
|
+
else sqlType = this.driver.dialect.getSqlType(column.type, {
|
|
197
|
+
length: column.length,
|
|
198
|
+
precision: column.precision,
|
|
199
|
+
scale: column.scale,
|
|
200
|
+
dimensions: column.dimensions
|
|
201
|
+
});
|
|
202
|
+
let sql = `ALTER TABLE ${quotedTable} ADD COLUMN ${quotedColumn} ${sqlType}`;
|
|
203
|
+
if (column.generated) {
|
|
204
|
+
sql += ` GENERATED ALWAYS AS (${column.generated.expression})`;
|
|
205
|
+
if (column.generated.stored) sql += " STORED";
|
|
206
|
+
} else {
|
|
207
|
+
if (!column.autoIncrement && column.nullable === false) sql += " NOT NULL";
|
|
208
|
+
if (column.defaultValue !== void 0) if (typeof column.defaultValue === "object" && column.defaultValue !== null && column.defaultValue.__type === "CURRENT_TIMESTAMP") sql += " DEFAULT NOW()";
|
|
209
|
+
else if (column.isRawDefault === false) {
|
|
210
|
+
const escaped = String(column.defaultValue).replace(/'/g, "''");
|
|
211
|
+
sql += ` DEFAULT '${escaped}'`;
|
|
212
|
+
} else if (typeof column.defaultValue === "boolean") sql += ` DEFAULT ${column.defaultValue ? "TRUE" : "FALSE"}`;
|
|
213
|
+
else if (typeof column.defaultValue === "number") sql += ` DEFAULT ${column.defaultValue}`;
|
|
214
|
+
else sql += ` DEFAULT ${column.defaultValue}`;
|
|
215
|
+
if (column.primary) sql += " PRIMARY KEY";
|
|
216
|
+
if (column.unique) sql += " UNIQUE";
|
|
217
|
+
}
|
|
218
|
+
await this.execute(sql);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Drop a column from a table.
|
|
222
|
+
*
|
|
223
|
+
* @param table - Table name
|
|
224
|
+
* @param column - Column name
|
|
225
|
+
*/
|
|
226
|
+
async dropColumn(table, column) {
|
|
227
|
+
const quotedTable = this.driver.dialect.quoteIdentifier(table);
|
|
228
|
+
const quotedColumn = this.driver.dialect.quoteIdentifier(column);
|
|
229
|
+
await this.execute(`ALTER TABLE ${quotedTable} DROP COLUMN ${quotedColumn}`);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Drop multiple columns from a table.
|
|
233
|
+
*
|
|
234
|
+
* @param table - Table name
|
|
235
|
+
* @param columns - Column names
|
|
236
|
+
*/
|
|
237
|
+
async dropColumns(table, columns) {
|
|
238
|
+
for (const column of columns) await this.dropColumn(table, column);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Rename a column.
|
|
242
|
+
*
|
|
243
|
+
* @param table - Table name
|
|
244
|
+
* @param from - Current column name
|
|
245
|
+
* @param to - New column name
|
|
246
|
+
*/
|
|
247
|
+
async renameColumn(table, from, to) {
|
|
248
|
+
const quotedTable = this.driver.dialect.quoteIdentifier(table);
|
|
249
|
+
const quotedFrom = this.driver.dialect.quoteIdentifier(from);
|
|
250
|
+
const quotedTo = this.driver.dialect.quoteIdentifier(to);
|
|
251
|
+
await this.execute(`ALTER TABLE ${quotedTable} RENAME COLUMN ${quotedFrom} TO ${quotedTo}`);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Modify an existing column.
|
|
255
|
+
*
|
|
256
|
+
* @param table - Table name
|
|
257
|
+
* @param column - New column definition
|
|
258
|
+
*/
|
|
259
|
+
async modifyColumn(table, column) {
|
|
260
|
+
const quotedTable = this.driver.dialect.quoteIdentifier(table);
|
|
261
|
+
const quotedColumn = this.driver.dialect.quoteIdentifier(column.name);
|
|
262
|
+
const sqlType = this.driver.dialect.getSqlType(column.type, {
|
|
263
|
+
length: column.length,
|
|
264
|
+
precision: column.precision,
|
|
265
|
+
scale: column.scale,
|
|
266
|
+
dimensions: column.dimensions
|
|
267
|
+
});
|
|
268
|
+
await this.execute(`ALTER TABLE ${quotedTable} ALTER COLUMN ${quotedColumn} TYPE ${sqlType}`);
|
|
269
|
+
if (column.nullable === false) await this.execute(`ALTER TABLE ${quotedTable} ALTER COLUMN ${quotedColumn} SET NOT NULL`);
|
|
270
|
+
else if (column.nullable === true) await this.execute(`ALTER TABLE ${quotedTable} ALTER COLUMN ${quotedColumn} DROP NOT NULL`);
|
|
271
|
+
if (column.defaultValue !== void 0) {
|
|
272
|
+
let defaultVal;
|
|
273
|
+
if (typeof column.defaultValue === "object" && column.defaultValue !== null && column.defaultValue.__type === "CURRENT_TIMESTAMP") defaultVal = "NOW()";
|
|
274
|
+
else if (typeof column.defaultValue === "string") defaultVal = `'${column.defaultValue}'`;
|
|
275
|
+
else defaultVal = String(column.defaultValue);
|
|
276
|
+
await this.execute(`ALTER TABLE ${quotedTable} ALTER COLUMN ${quotedColumn} SET DEFAULT ${defaultVal}`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Create standard timestamp columns (created_at, updated_at).
|
|
281
|
+
*
|
|
282
|
+
* PostgreSQL implementation creates TIMESTAMPTZ columns with NOW() defaults.
|
|
283
|
+
*
|
|
284
|
+
* @param table - Table name
|
|
285
|
+
*/
|
|
286
|
+
async createTimestampColumns(table) {
|
|
287
|
+
await this.addColumn(table, {
|
|
288
|
+
name: "created_at",
|
|
289
|
+
type: "timestamp",
|
|
290
|
+
nullable: false,
|
|
291
|
+
defaultValue: "NOW()",
|
|
292
|
+
isRawDefault: true
|
|
293
|
+
});
|
|
294
|
+
await this.addColumn(table, {
|
|
295
|
+
name: "updated_at",
|
|
296
|
+
type: "timestamp",
|
|
297
|
+
nullable: false,
|
|
298
|
+
defaultValue: "NOW()",
|
|
299
|
+
isRawDefault: true
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Create an index on one or more columns.
|
|
304
|
+
*
|
|
305
|
+
* Supports:
|
|
306
|
+
* - Regular column indexes
|
|
307
|
+
* - Expression-based indexes (e.g., `lower(email)`)
|
|
308
|
+
* - Covering indexes (INCLUDE clause)
|
|
309
|
+
* - Concurrent index creation (CONCURRENTLY keyword)
|
|
310
|
+
*
|
|
311
|
+
* @param table - Table name
|
|
312
|
+
* @param index - Index definition
|
|
313
|
+
*/
|
|
314
|
+
async createIndex(table, index) {
|
|
315
|
+
const quotedTable = this.driver.dialect.quoteIdentifier(table);
|
|
316
|
+
const indexName = index.name ?? `idx_${table}_${index.columns.join("_")}`;
|
|
317
|
+
const quotedIndexName = this.driver.dialect.quoteIdentifier(indexName);
|
|
318
|
+
const uniqueKeyword = index.unique ? "UNIQUE " : "";
|
|
319
|
+
const concurrentlyKeyword = index.concurrently ? "CONCURRENTLY " : "";
|
|
320
|
+
let columnsPart;
|
|
321
|
+
if (index.expressions && index.expressions.length > 0) columnsPart = index.expressions.map((expr) => `(${expr})`).join(", ");
|
|
322
|
+
else columnsPart = index.columns.map((col, i) => {
|
|
323
|
+
const quotedCol = this.driver.dialect.quoteIdentifier(col);
|
|
324
|
+
const direction = index.directions?.[i]?.toUpperCase() ?? "";
|
|
325
|
+
return direction ? `${quotedCol} ${direction}` : quotedCol;
|
|
326
|
+
}).join(", ");
|
|
327
|
+
let sql = `CREATE ${uniqueKeyword}INDEX ${concurrentlyKeyword}${quotedIndexName} ON ${quotedTable} (${columnsPart})`;
|
|
328
|
+
if (index.include && index.include.length > 0) {
|
|
329
|
+
const includeCols = index.include.map((col) => this.driver.dialect.quoteIdentifier(col)).join(", ");
|
|
330
|
+
sql += ` INCLUDE (${includeCols})`;
|
|
331
|
+
}
|
|
332
|
+
if (index.where && Object.keys(index.where).length > 0) {
|
|
333
|
+
const conditions = Object.entries(index.where).map(([key, value]) => {
|
|
334
|
+
const quotedKey = this.driver.dialect.quoteIdentifier(key);
|
|
335
|
+
return typeof value === "string" ? `${quotedKey} = '${value}'` : `${quotedKey} = ${value}`;
|
|
336
|
+
}).join(" AND ");
|
|
337
|
+
sql += ` WHERE ${conditions}`;
|
|
338
|
+
}
|
|
339
|
+
await this.execute(sql);
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Drop an index.
|
|
343
|
+
*
|
|
344
|
+
* @param table - Table name
|
|
345
|
+
* @param indexNameOrColumns - Index name or columns
|
|
346
|
+
*/
|
|
347
|
+
async dropIndex(table, indexNameOrColumns) {
|
|
348
|
+
let indexName;
|
|
349
|
+
if (typeof indexNameOrColumns === "string") indexName = indexNameOrColumns;
|
|
350
|
+
else indexName = `idx_${table}_${indexNameOrColumns.join("_")}`;
|
|
351
|
+
const quotedIndexName = this.driver.dialect.quoteIdentifier(indexName);
|
|
352
|
+
await this.execute(`DROP INDEX IF EXISTS ${quotedIndexName}`);
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Create a unique index.
|
|
356
|
+
*
|
|
357
|
+
* @param table - Table name
|
|
358
|
+
* @param columns - Columns to include
|
|
359
|
+
* @param name - Optional index name
|
|
360
|
+
*/
|
|
361
|
+
async createUniqueIndex(table, columns, name) {
|
|
362
|
+
await this.createIndex(table, {
|
|
363
|
+
columns,
|
|
364
|
+
unique: true,
|
|
365
|
+
name
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Drop a unique index.
|
|
370
|
+
*
|
|
371
|
+
* @param table - Table name
|
|
372
|
+
* @param columns - Columns in the index
|
|
373
|
+
*/
|
|
374
|
+
async dropUniqueIndex(table, columns) {
|
|
375
|
+
await this.dropIndex(table, columns);
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Create a full-text search index using GIN.
|
|
379
|
+
*
|
|
380
|
+
* @param table - Table name
|
|
381
|
+
* @param columns - Columns to index
|
|
382
|
+
* @param options - Full-text options
|
|
383
|
+
*/
|
|
384
|
+
async createFullTextIndex(table, columns, options) {
|
|
385
|
+
const quotedTable = this.driver.dialect.quoteIdentifier(table);
|
|
386
|
+
const indexName = options?.name ?? `idx_${table}_fulltext_${columns.join("_")}`;
|
|
387
|
+
const quotedIndexName = this.driver.dialect.quoteIdentifier(indexName);
|
|
388
|
+
const language = options?.language ?? "english";
|
|
389
|
+
const tsvectors = columns.map((col) => {
|
|
390
|
+
const weight = options?.weights?.[col] ?? "A";
|
|
391
|
+
return `setweight(to_tsvector('${language}', COALESCE(${this.driver.dialect.quoteIdentifier(col)}, '')), '${weight}')`;
|
|
392
|
+
});
|
|
393
|
+
await this.execute(`CREATE INDEX ${quotedIndexName} ON ${quotedTable} USING GIN ((${tsvectors.join(" || ")}))`);
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Drop a full-text search index.
|
|
397
|
+
*
|
|
398
|
+
* @param table - Table name
|
|
399
|
+
* @param name - Index name
|
|
400
|
+
*/
|
|
401
|
+
async dropFullTextIndex(table, name) {
|
|
402
|
+
await this.dropIndex(table, name);
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Create a geo-spatial index using GiST.
|
|
406
|
+
*
|
|
407
|
+
* @param table - Table name
|
|
408
|
+
* @param column - Geo column
|
|
409
|
+
* @param options - Geo index options
|
|
410
|
+
*/
|
|
411
|
+
async createGeoIndex(table, column, options) {
|
|
412
|
+
const quotedTable = this.driver.dialect.quoteIdentifier(table);
|
|
413
|
+
const quotedColumn = this.driver.dialect.quoteIdentifier(column);
|
|
414
|
+
const indexName = options?.name ?? `idx_${table}_geo_${column}`;
|
|
415
|
+
const quotedIndexName = this.driver.dialect.quoteIdentifier(indexName);
|
|
416
|
+
await this.execute(`CREATE INDEX ${quotedIndexName} ON ${quotedTable} USING GIST (${quotedColumn})`);
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Drop a geo-spatial index.
|
|
420
|
+
*
|
|
421
|
+
* @param table - Table name
|
|
422
|
+
* @param column - Geo column
|
|
423
|
+
*/
|
|
424
|
+
async dropGeoIndex(table, column) {
|
|
425
|
+
await this.dropIndex(table, `idx_${table}_geo_${column}`);
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Create a vector search index (requires pgvector extension).
|
|
429
|
+
*
|
|
430
|
+
* @param table - Table name
|
|
431
|
+
* @param column - Vector column
|
|
432
|
+
* @param options - Vector index options
|
|
433
|
+
*/
|
|
434
|
+
async createVectorIndex(table, column, options) {
|
|
435
|
+
const quotedTable = this.driver.dialect.quoteIdentifier(table);
|
|
436
|
+
const quotedColumn = this.driver.dialect.quoteIdentifier(column);
|
|
437
|
+
const indexName = options.name ?? `idx_${table}_vector_${column}`;
|
|
438
|
+
const quotedIndexName = this.driver.dialect.quoteIdentifier(indexName);
|
|
439
|
+
const opClass = options.similarity === "euclidean" ? "vector_l2_ops" : options.similarity === "dotProduct" ? "vector_ip_ops" : "vector_cosine_ops";
|
|
440
|
+
const lists = options.lists ?? 100;
|
|
441
|
+
await this.execute(`CREATE INDEX ${quotedIndexName} ON ${quotedTable} USING ivfflat (${quotedColumn} ${opClass}) WITH (lists = ${lists})`);
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Drop a vector search index.
|
|
445
|
+
*
|
|
446
|
+
* @param table - Table name
|
|
447
|
+
* @param column - Vector column
|
|
448
|
+
*/
|
|
449
|
+
async dropVectorIndex(table, column) {
|
|
450
|
+
await this.dropIndex(table, `idx_${table}_vector_${column}`);
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Create a TTL index (not natively supported in PostgreSQL).
|
|
454
|
+
*
|
|
455
|
+
* Note: PostgreSQL doesn't have native TTL indexes like MongoDB.
|
|
456
|
+
* This creates a partial index and requires a scheduled job for cleanup.
|
|
457
|
+
*
|
|
458
|
+
* @param table - Table name
|
|
459
|
+
* @param column - Date column
|
|
460
|
+
* @param expireAfterSeconds - Expiration time in seconds
|
|
461
|
+
*/
|
|
462
|
+
async createTTLIndex(table, column, expireAfterSeconds) {
|
|
463
|
+
const quotedTable = this.driver.dialect.quoteIdentifier(table);
|
|
464
|
+
const quotedColumn = this.driver.dialect.quoteIdentifier(column);
|
|
465
|
+
const indexName = `idx_${table}_ttl_${column}`;
|
|
466
|
+
const quotedIndexName = this.driver.dialect.quoteIdentifier(indexName);
|
|
467
|
+
await this.execute(`CREATE INDEX ${quotedIndexName} ON ${quotedTable} (${quotedColumn}) WHERE ${quotedColumn} < NOW() - INTERVAL '${expireAfterSeconds} seconds'`);
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Drop a TTL index.
|
|
471
|
+
*
|
|
472
|
+
* @param table - Table name
|
|
473
|
+
* @param column - Column with TTL index
|
|
474
|
+
*/
|
|
475
|
+
async dropTTLIndex(table, column) {
|
|
476
|
+
await this.dropIndex(table, `idx_${table}_ttl_${column}`);
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* List all indexes on a table.
|
|
480
|
+
*
|
|
481
|
+
* @param table - Table name
|
|
482
|
+
* @returns Array of index metadata
|
|
483
|
+
*/
|
|
484
|
+
async listIndexes(table) {
|
|
485
|
+
return (await this.driver.query(`SELECT indexname, indexdef FROM pg_indexes WHERE schemaname = 'public' AND tablename = $1`, [table])).rows.map((row) => {
|
|
486
|
+
const isUnique = row.indexdef.includes("UNIQUE");
|
|
487
|
+
const isPrimary = row.indexname.endsWith("_pkey");
|
|
488
|
+
const columnsMatch = row.indexdef.match(/\(([^)]+)\)/);
|
|
489
|
+
const columns = columnsMatch ? columnsMatch[1].split(",").map((c) => c.trim().replace(/"/g, "")) : [];
|
|
490
|
+
let type = "btree";
|
|
491
|
+
if (row.indexdef.includes("USING GIN")) type = "gin";
|
|
492
|
+
else if (row.indexdef.includes("USING GIST")) type = "gist";
|
|
493
|
+
else if (row.indexdef.includes("USING HASH")) type = "hash";
|
|
494
|
+
else if (row.indexdef.includes("USING ivfflat")) type = "ivfflat";
|
|
495
|
+
return {
|
|
496
|
+
name: row.indexname,
|
|
497
|
+
columns,
|
|
498
|
+
type,
|
|
499
|
+
unique: isUnique || isPrimary,
|
|
500
|
+
partial: row.indexdef.includes("WHERE"),
|
|
501
|
+
options: {
|
|
502
|
+
primary: isPrimary,
|
|
503
|
+
definition: row.indexdef
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Check if a PostgreSQL extension is available on the database server.
|
|
510
|
+
*
|
|
511
|
+
* @param extension - Extension name (e.g., "vector")
|
|
512
|
+
*/
|
|
513
|
+
async isExtensionAvailable(extension) {
|
|
514
|
+
try {
|
|
515
|
+
return (await this.driver.query(`SELECT name FROM pg_available_extensions WHERE name = $1`, [extension]))?.rows?.length > 0;
|
|
516
|
+
} catch {
|
|
517
|
+
return true;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Get the official documentation or installation URL for a PostgreSQL extension.
|
|
522
|
+
*
|
|
523
|
+
* @param extension - Extension name
|
|
524
|
+
*/
|
|
525
|
+
getExtensionDocsUrl(extension) {
|
|
526
|
+
return {
|
|
527
|
+
vector: "https://github.com/pgvector/pgvector#installation",
|
|
528
|
+
postgis: "https://postgis.net/documentation/getting_started/",
|
|
529
|
+
pg_trgm: "https://www.postgresql.org/docs/current/pgtrgm.html",
|
|
530
|
+
uuid_ossp: "https://www.postgresql.org/docs/current/uuid-ossp.html"
|
|
531
|
+
}[extension] ?? `https://www.postgresql.org/docs/current/${extension}.html`;
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Add a foreign key constraint.
|
|
535
|
+
*
|
|
536
|
+
* @param table - Table name
|
|
537
|
+
* @param foreignKey - Foreign key definition
|
|
538
|
+
*/
|
|
539
|
+
async addForeignKey(table, foreignKey) {
|
|
540
|
+
const quotedTable = this.driver.dialect.quoteIdentifier(table);
|
|
541
|
+
const quotedColumn = this.driver.dialect.quoteIdentifier(foreignKey.column);
|
|
542
|
+
const quotedRefTable = this.driver.dialect.quoteIdentifier(foreignKey.referencesTable);
|
|
543
|
+
const quotedRefColumn = this.driver.dialect.quoteIdentifier(foreignKey.referencesColumn);
|
|
544
|
+
const constraintName = foreignKey.name ?? `fk_${table}_${foreignKey.column}_${foreignKey.referencesTable}`;
|
|
545
|
+
let sql = `ALTER TABLE ${quotedTable} ADD CONSTRAINT ${this.driver.dialect.quoteIdentifier(constraintName)} FOREIGN KEY (${quotedColumn}) REFERENCES ${quotedRefTable} (${quotedRefColumn})`;
|
|
546
|
+
if (foreignKey.onDelete) sql += ` ON DELETE ${this.mapForeignKeyAction(foreignKey.onDelete)}`;
|
|
547
|
+
if (foreignKey.onUpdate) sql += ` ON UPDATE ${this.mapForeignKeyAction(foreignKey.onUpdate)}`;
|
|
548
|
+
await this.execute(sql);
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Drop a foreign key constraint.
|
|
552
|
+
*
|
|
553
|
+
* @param table - Table name
|
|
554
|
+
* @param name - Constraint name
|
|
555
|
+
*/
|
|
556
|
+
async dropForeignKey(table, name) {
|
|
557
|
+
const quotedTable = this.driver.dialect.quoteIdentifier(table);
|
|
558
|
+
const quotedConstraint = this.driver.dialect.quoteIdentifier(name);
|
|
559
|
+
await this.execute(`ALTER TABLE ${quotedTable} DROP CONSTRAINT ${quotedConstraint}`);
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Add a primary key constraint.
|
|
563
|
+
*
|
|
564
|
+
* @param table - Table name
|
|
565
|
+
* @param columns - Primary key columns
|
|
566
|
+
*/
|
|
567
|
+
async addPrimaryKey(table, columns) {
|
|
568
|
+
const quotedTable = this.driver.dialect.quoteIdentifier(table);
|
|
569
|
+
const quotedColumns = columns.map((c) => this.driver.dialect.quoteIdentifier(c)).join(", ");
|
|
570
|
+
const constraintName = `pk_${table}`;
|
|
571
|
+
const quotedConstraint = this.driver.dialect.quoteIdentifier(constraintName);
|
|
572
|
+
await this.execute(`ALTER TABLE ${quotedTable} ADD CONSTRAINT ${quotedConstraint} PRIMARY KEY (${quotedColumns})`);
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Drop the primary key constraint.
|
|
576
|
+
*
|
|
577
|
+
* @param table - Table name
|
|
578
|
+
*/
|
|
579
|
+
async dropPrimaryKey(table) {
|
|
580
|
+
const quotedTable = this.driver.dialect.quoteIdentifier(table);
|
|
581
|
+
const constraintName = `pk_${table}`;
|
|
582
|
+
const quotedConstraint = this.driver.dialect.quoteIdentifier(constraintName);
|
|
583
|
+
await this.execute(`ALTER TABLE ${quotedTable} DROP CONSTRAINT ${quotedConstraint}`);
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Add a CHECK constraint.
|
|
587
|
+
*
|
|
588
|
+
* @param table - Table name
|
|
589
|
+
* @param name - Constraint name
|
|
590
|
+
* @param expression - SQL CHECK expression
|
|
591
|
+
*/
|
|
592
|
+
async addCheck(table, name, expression) {
|
|
593
|
+
const sql = `ALTER TABLE ${this.driver.dialect.quoteIdentifier(table)} ADD CONSTRAINT ${this.driver.dialect.quoteIdentifier(name)} CHECK (${expression})`;
|
|
594
|
+
await this.execute(sql);
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Drop a CHECK constraint.
|
|
598
|
+
*
|
|
599
|
+
* @param table - Table name
|
|
600
|
+
* @param name - Constraint name
|
|
601
|
+
*/
|
|
602
|
+
async dropCheck(table, name) {
|
|
603
|
+
const quotedTable = this.driver.dialect.quoteIdentifier(table);
|
|
604
|
+
const quotedName = this.driver.dialect.quoteIdentifier(name);
|
|
605
|
+
await this.execute(`ALTER TABLE ${quotedTable} DROP CONSTRAINT ${quotedName}`);
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* Set schema validation (no-op for PostgreSQL).
|
|
609
|
+
*
|
|
610
|
+
* PostgreSQL uses column constraints instead.
|
|
611
|
+
*/
|
|
612
|
+
async setSchemaValidation(_table, _schema) {}
|
|
613
|
+
/**
|
|
614
|
+
* Remove schema validation (no-op for PostgreSQL).
|
|
615
|
+
*/
|
|
616
|
+
async removeSchemaValidation(_table) {}
|
|
617
|
+
/**
|
|
618
|
+
* Begin a transaction.
|
|
619
|
+
*/
|
|
620
|
+
async beginTransaction() {
|
|
621
|
+
await this.execute("BEGIN");
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Commit the current transaction.
|
|
625
|
+
*/
|
|
626
|
+
async commit() {
|
|
627
|
+
await this.execute("COMMIT");
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Rollback the current transaction.
|
|
631
|
+
*/
|
|
632
|
+
async rollback() {
|
|
633
|
+
await this.execute("ROLLBACK");
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Whether transactions are supported.
|
|
637
|
+
*/
|
|
638
|
+
supportsTransactions() {
|
|
639
|
+
return true;
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Get the default transactional behavior for PostgreSQL.
|
|
643
|
+
*
|
|
644
|
+
* PostgreSQL supports transactional DDL operations, so migrations
|
|
645
|
+
* are wrapped in transactions by default for atomicity and safety.
|
|
646
|
+
*
|
|
647
|
+
* @returns true (PostgreSQL DDL is transactional)
|
|
648
|
+
*/
|
|
649
|
+
getDefaultTransactional() {
|
|
650
|
+
return true;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Get the default UUID generation expression for PostgreSQL.
|
|
654
|
+
*
|
|
655
|
+
* Resolution order:
|
|
656
|
+
* 1. `migrationDefaults.uuidExpression` → raw expression (escape hatch)
|
|
657
|
+
* 2. `migrationDefaults.uuidStrategy` → mapped to PG function
|
|
658
|
+
* 3. Fallback → `gen_random_uuid()` (v4, PG 13+)
|
|
659
|
+
*
|
|
660
|
+
* @param migrationDefaults - Optional overrides from DataSource config
|
|
661
|
+
* @returns PostgreSQL SQL expression for UUID generation
|
|
662
|
+
*
|
|
663
|
+
* @example
|
|
664
|
+
* ```typescript
|
|
665
|
+
* driver.getUuidDefault(); // "gen_random_uuid()"
|
|
666
|
+
* driver.getUuidDefault({ uuidStrategy: "v7" }); // "uuidv7()"
|
|
667
|
+
* driver.getUuidDefault({ uuidExpression: "uuid_generate_v1mc()" }); // "uuid_generate_v1mc()"
|
|
668
|
+
* ```
|
|
669
|
+
*/
|
|
670
|
+
getUuidDefault(migrationDefaults) {
|
|
671
|
+
if (migrationDefaults?.uuidExpression) return migrationDefaults.uuidExpression;
|
|
672
|
+
return {
|
|
673
|
+
v4: "gen_random_uuid()",
|
|
674
|
+
v7: "uuidv7()"
|
|
675
|
+
}[migrationDefaults?.uuidStrategy ?? "v4"];
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Execute raw operations with direct driver access.
|
|
679
|
+
*
|
|
680
|
+
* @param callback - Callback receiving the driver
|
|
681
|
+
*/
|
|
682
|
+
async raw(callback) {
|
|
683
|
+
return callback(this.driver);
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* Execute a SQL statement.
|
|
687
|
+
*
|
|
688
|
+
* @param sql - SQL to execute
|
|
689
|
+
* @param params - Query parameters
|
|
690
|
+
*/
|
|
691
|
+
async execute(sql, params = []) {
|
|
692
|
+
await this.driver.query(sql, params);
|
|
693
|
+
}
|
|
694
|
+
/**
|
|
695
|
+
* Map foreign key action to PostgreSQL syntax.
|
|
696
|
+
*/
|
|
697
|
+
mapForeignKeyAction(action) {
|
|
698
|
+
return {
|
|
699
|
+
cascade: "CASCADE",
|
|
700
|
+
restrict: "RESTRICT",
|
|
701
|
+
setNull: "SET NULL",
|
|
702
|
+
noAction: "NO ACTION"
|
|
703
|
+
}[action] ?? "NO ACTION";
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* Map PostgreSQL data type to ColumnType.
|
|
707
|
+
*/
|
|
708
|
+
mapPostgresTypeToColumnType(pgType) {
|
|
709
|
+
return {
|
|
710
|
+
"character varying": "string",
|
|
711
|
+
varchar: "string",
|
|
712
|
+
character: "char",
|
|
713
|
+
char: "char",
|
|
714
|
+
text: "text",
|
|
715
|
+
integer: "integer",
|
|
716
|
+
int: "integer",
|
|
717
|
+
smallint: "smallInteger",
|
|
718
|
+
bigint: "bigInteger",
|
|
719
|
+
real: "float",
|
|
720
|
+
"double precision": "double",
|
|
721
|
+
numeric: "decimal",
|
|
722
|
+
decimal: "decimal",
|
|
723
|
+
boolean: "boolean",
|
|
724
|
+
date: "date",
|
|
725
|
+
timestamp: "dateTime",
|
|
726
|
+
"timestamp without time zone": "dateTime",
|
|
727
|
+
"timestamp with time zone": "timestamp",
|
|
728
|
+
time: "time",
|
|
729
|
+
"time without time zone": "time",
|
|
730
|
+
json: "json",
|
|
731
|
+
jsonb: "json",
|
|
732
|
+
bytea: "binary",
|
|
733
|
+
uuid: "uuid",
|
|
734
|
+
inet: "ipAddress",
|
|
735
|
+
macaddr: "macAddress",
|
|
736
|
+
point: "point",
|
|
737
|
+
polygon: "polygon",
|
|
738
|
+
line: "lineString",
|
|
739
|
+
geometry: "geometry",
|
|
740
|
+
"integer[]": "arrayInt",
|
|
741
|
+
"int[]": "arrayInt",
|
|
742
|
+
"bigint[]": "arrayBigInt",
|
|
743
|
+
"real[]": "arrayFloat",
|
|
744
|
+
"decimal[]": "arrayDecimal",
|
|
745
|
+
"numeric[]": "arrayDecimal",
|
|
746
|
+
"boolean[]": "arrayBoolean",
|
|
747
|
+
"text[]": "arrayText",
|
|
748
|
+
"date[]": "arrayDate",
|
|
749
|
+
"timestamp with time zone[]": "arrayTimestamp",
|
|
750
|
+
"timestamptz[]": "arrayTimestamp",
|
|
751
|
+
"uuid[]": "arrayUuid",
|
|
752
|
+
"jsonb[]": "arrayJson",
|
|
753
|
+
"json[]": "arrayJson"
|
|
754
|
+
}[pgType.toLowerCase()] ?? "string";
|
|
755
|
+
}
|
|
756
|
+
};
|
|
757
|
+
|
|
758
|
+
//#endregion
|
|
759
|
+
export { PostgresMigrationDriver };
|
|
760
|
+
//# sourceMappingURL=postgres-migration-driver.mjs.map
|