@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,2083 @@
|
|
|
1
|
+
import { ColumnBuilder } from "./column-builder.mjs";
|
|
2
|
+
import { ForeignKeyBuilder } from "./foreign-key-builder.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../../@warlock.js/cascade/src/migration/migration.ts
|
|
5
|
+
/**
|
|
6
|
+
* Base class for all database migrations.
|
|
7
|
+
*
|
|
8
|
+
* Provides a fluent API for defining schema changes that work across
|
|
9
|
+
* both SQL and NoSQL databases. The migration driver handles translating
|
|
10
|
+
* operations to native database commands.
|
|
11
|
+
*
|
|
12
|
+
* Migrations are executed in order based on their `createdAt` timestamp,
|
|
13
|
+
* which is typically extracted from the filename (e.g., `2024-01-15_create-users`).
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // Using Migration.for() to bind to a model
|
|
18
|
+
* export default class extends Migration.for(User) {
|
|
19
|
+
* public up(): void {
|
|
20
|
+
* this.string("email").unique();
|
|
21
|
+
* this.integer("age").nullable();
|
|
22
|
+
* this.geoIndex("location");
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* public down(): void {
|
|
26
|
+
* this.dropColumn("email");
|
|
27
|
+
* this.dropColumn("age");
|
|
28
|
+
* this.dropGeoIndex("location");
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* // Manual table migration (without model binding)
|
|
36
|
+
* export default class CreateUsersTable extends Migration {
|
|
37
|
+
* public readonly table = "users";
|
|
38
|
+
*
|
|
39
|
+
* public up(): void {
|
|
40
|
+
* this.createTable();
|
|
41
|
+
* this.id();
|
|
42
|
+
* this.string("name");
|
|
43
|
+
* this.string("email").unique();
|
|
44
|
+
* this.timestamps();
|
|
45
|
+
* }
|
|
46
|
+
*
|
|
47
|
+
* public down(): void {
|
|
48
|
+
* this.dropTable();
|
|
49
|
+
* }
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
var Migration = class {
|
|
54
|
+
/**
|
|
55
|
+
* Migration name that will be labeled with
|
|
56
|
+
* If record is enabled in migration, it will be stored as migration name
|
|
57
|
+
* in database
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* "2024-01-15_create-users";
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
static migrationName;
|
|
65
|
+
/**
|
|
66
|
+
* Table/collection name for this migration.
|
|
67
|
+
*
|
|
68
|
+
* Must be defined by each migration class (either directly or via `Migration.for()`).
|
|
69
|
+
*/
|
|
70
|
+
table;
|
|
71
|
+
/**
|
|
72
|
+
* Sort order
|
|
73
|
+
* If not provided, it will be ordered alphabetically
|
|
74
|
+
*/
|
|
75
|
+
static order;
|
|
76
|
+
/**
|
|
77
|
+
* Optional data source override.
|
|
78
|
+
*
|
|
79
|
+
* If specified, this migration will use a specific data source
|
|
80
|
+
* instead of the default one. Can be a string name or DataSource instance.
|
|
81
|
+
*/
|
|
82
|
+
dataSource;
|
|
83
|
+
/**
|
|
84
|
+
* Optional timestamp override.
|
|
85
|
+
*
|
|
86
|
+
* By default, the migration runner extracts this from the filename.
|
|
87
|
+
* Set explicitly to override the execution order.
|
|
88
|
+
*
|
|
89
|
+
* Format: ISO 8601 or any parseable date string.
|
|
90
|
+
*/
|
|
91
|
+
static createdAt;
|
|
92
|
+
/**
|
|
93
|
+
* Whether to wrap migration in a transaction.
|
|
94
|
+
*
|
|
95
|
+
* Defaults to `true` for SQL databases that support DDL transactions.
|
|
96
|
+
* Set to `false` for operations that cannot be transactional.
|
|
97
|
+
*
|
|
98
|
+
* Note: MongoDB does not support transactions for most DDL operations.
|
|
99
|
+
*/
|
|
100
|
+
transactional;
|
|
101
|
+
/**
|
|
102
|
+
* Migration driver instance (injected by the runner).
|
|
103
|
+
*/
|
|
104
|
+
driver;
|
|
105
|
+
/**
|
|
106
|
+
* Migration defaults from the resolved DataSource.
|
|
107
|
+
* @internal
|
|
108
|
+
*/
|
|
109
|
+
/** @internal — readable by factory-generated subclasses */
|
|
110
|
+
_migrationDefaults;
|
|
111
|
+
/**
|
|
112
|
+
* Queued operations to execute.
|
|
113
|
+
*/
|
|
114
|
+
pendingOperations = [];
|
|
115
|
+
/**
|
|
116
|
+
* Create a migration class bound to a specific model.
|
|
117
|
+
*
|
|
118
|
+
* Automatically inherits the model's table name and data source,
|
|
119
|
+
* reducing boilerplate and ensuring consistency.
|
|
120
|
+
*
|
|
121
|
+
* @param model - Model class to bind
|
|
122
|
+
* @returns Abstract migration class bound to the model
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* export default class extends Migration.for(User) {
|
|
127
|
+
* public up(): void {
|
|
128
|
+
* this.string("avatar").nullable();
|
|
129
|
+
* }
|
|
130
|
+
*
|
|
131
|
+
* public down(): void {
|
|
132
|
+
* this.dropColumn("avatar");
|
|
133
|
+
* }
|
|
134
|
+
* }
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
static for(model) {
|
|
138
|
+
class BoundMigration extends Migration {
|
|
139
|
+
table = model.table;
|
|
140
|
+
dataSource = model.dataSource;
|
|
141
|
+
}
|
|
142
|
+
return BoundMigration;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Create a migration that executes raw SQL statements.
|
|
146
|
+
*
|
|
147
|
+
* Intended for external packages that ship engine-specific DDL — typically a
|
|
148
|
+
* one-shot `CREATE TABLE` bundle whose `up` is the only direction that matters.
|
|
149
|
+
* The `down` direction is optional; when omitted, rollback is a recorded no-op.
|
|
150
|
+
*
|
|
151
|
+
* Raw SQL is engine-locked by definition. This factory is rejected on MongoDB
|
|
152
|
+
* data sources at execute time — use the fluent builder for cross-engine work.
|
|
153
|
+
*
|
|
154
|
+
* @param options - Migration name, SQL statements, and optional overrides
|
|
155
|
+
* @returns Migration constructor ready to register with the runner
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* export const createAuthTables = Migration.rawSql({
|
|
160
|
+
* name: "create_auth_tables",
|
|
161
|
+
* up: [
|
|
162
|
+
* `CREATE TABLE users (id UUID PRIMARY KEY, email TEXT UNIQUE NOT NULL)`,
|
|
163
|
+
* `CREATE TABLE sessions (id UUID PRIMARY KEY, user_id UUID REFERENCES users(id))`,
|
|
164
|
+
* ],
|
|
165
|
+
* });
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
static rawSql(options) {
|
|
169
|
+
const { name, up, down, dataSource, transactional } = options;
|
|
170
|
+
const toStatements = (input) => Array.isArray(input) ? input : [input];
|
|
171
|
+
class RawSqlMigration extends Migration {
|
|
172
|
+
table = "";
|
|
173
|
+
dataSource = dataSource;
|
|
174
|
+
transactional = transactional;
|
|
175
|
+
up() {
|
|
176
|
+
this.guardEngine();
|
|
177
|
+
for (const sql of toStatements(up)) this.raw(sql);
|
|
178
|
+
}
|
|
179
|
+
down() {
|
|
180
|
+
if (down === void 0) return;
|
|
181
|
+
this.guardEngine();
|
|
182
|
+
for (const sql of toStatements(down)) this.raw(sql);
|
|
183
|
+
}
|
|
184
|
+
guardEngine() {
|
|
185
|
+
if (this.databaseEngine === "mongodb") throw new Error(`Migration.rawSql ("${name}") is not supported on mongodb data sources — use the fluent builder instead.`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
RawSqlMigration.migrationName = name;
|
|
189
|
+
return RawSqlMigration;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Set the migration driver.
|
|
193
|
+
*
|
|
194
|
+
* Called by the migration runner before executing up/down.
|
|
195
|
+
*
|
|
196
|
+
* @param driver - Migration driver instance
|
|
197
|
+
* @internal
|
|
198
|
+
*/
|
|
199
|
+
setDriver(driver) {
|
|
200
|
+
this.driver = driver;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Set migration defaults from the resolved DataSource.
|
|
204
|
+
*
|
|
205
|
+
* @param defaults - Migration defaults (UUID strategy, etc.)
|
|
206
|
+
* @internal
|
|
207
|
+
*/
|
|
208
|
+
setMigrationDefaults(defaults) {
|
|
209
|
+
this._migrationDefaults = defaults;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Get the migration driver.
|
|
213
|
+
*
|
|
214
|
+
* @returns The migration driver instance
|
|
215
|
+
*/
|
|
216
|
+
getDriver() {
|
|
217
|
+
return this.driver;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Get database engine (MongoDB, Postgress...etc)
|
|
221
|
+
*/
|
|
222
|
+
get databaseEngine() {
|
|
223
|
+
return this.driver.driver.name;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Execute all pending operations.
|
|
227
|
+
*
|
|
228
|
+
* @deprecated Use toSQL() instead — migrations now generate SQL rather than
|
|
229
|
+
* executing DDL directly through the driver.
|
|
230
|
+
* @internal
|
|
231
|
+
*/
|
|
232
|
+
async execute() {
|
|
233
|
+
for (const op of this.pendingOperations) await this.executeOperation(op);
|
|
234
|
+
this.pendingOperations.length = 0;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Serialize all queued pending operations into a flat list of SQL strings.
|
|
238
|
+
*
|
|
239
|
+
* Call this AFTER invoking `up()` or `down()` to extract the SQL for the
|
|
240
|
+
* operations that were queued during that call. The pending queue is cleared
|
|
241
|
+
* after serializing so the instance is safe to reuse.
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```typescript
|
|
245
|
+
* const migration = new CreateUsersTable();
|
|
246
|
+
* migration.setDriver(driver);
|
|
247
|
+
*
|
|
248
|
+
* // Up SQL
|
|
249
|
+
* await migration.up();
|
|
250
|
+
* const upSQL = migration.toSQL();
|
|
251
|
+
*
|
|
252
|
+
* // Down SQL — reuse the same instance
|
|
253
|
+
* await migration.down();
|
|
254
|
+
* const downSQL = migration.toSQL();
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
toSQL() {
|
|
258
|
+
const statements = this.driver.driver.getSQLSerializer().serializeAll(this.pendingOperations, this.table);
|
|
259
|
+
this.pendingOperations.length = 0;
|
|
260
|
+
return statements;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Execute a single pending operation.
|
|
264
|
+
*/
|
|
265
|
+
async executeOperation(op) {
|
|
266
|
+
switch (op.type) {
|
|
267
|
+
case "addColumn": {
|
|
268
|
+
const column = op.payload;
|
|
269
|
+
await this.driver.addColumn(this.table, column);
|
|
270
|
+
if (column.checkConstraint) await this.driver.addCheck(this.table, column.checkConstraint.name, column.checkConstraint.expression);
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
case "dropColumn":
|
|
274
|
+
await this.driver.dropColumn(this.table, op.payload);
|
|
275
|
+
break;
|
|
276
|
+
case "dropColumns":
|
|
277
|
+
await this.driver.dropColumns(this.table, op.payload);
|
|
278
|
+
break;
|
|
279
|
+
case "renameColumn": {
|
|
280
|
+
const { from, to } = op.payload;
|
|
281
|
+
await this.driver.renameColumn(this.table, from, to);
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
case "modifyColumn":
|
|
285
|
+
await this.driver.modifyColumn(this.table, op.payload);
|
|
286
|
+
break;
|
|
287
|
+
case "createIndex":
|
|
288
|
+
await this.driver.createIndex(this.table, op.payload);
|
|
289
|
+
break;
|
|
290
|
+
case "dropIndex":
|
|
291
|
+
await this.driver.dropIndex(this.table, op.payload);
|
|
292
|
+
break;
|
|
293
|
+
case "createUniqueIndex": {
|
|
294
|
+
const { columns, name } = op.payload;
|
|
295
|
+
await this.driver.createUniqueIndex(this.table, columns, name);
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
case "dropUniqueIndex":
|
|
299
|
+
await this.driver.dropUniqueIndex(this.table, op.payload);
|
|
300
|
+
break;
|
|
301
|
+
case "createFullTextIndex": {
|
|
302
|
+
const { columns, options } = op.payload;
|
|
303
|
+
await this.driver.createFullTextIndex(this.table, columns, options);
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
case "dropFullTextIndex":
|
|
307
|
+
await this.driver.dropFullTextIndex(this.table, op.payload);
|
|
308
|
+
break;
|
|
309
|
+
case "createGeoIndex": {
|
|
310
|
+
const { column, options } = op.payload;
|
|
311
|
+
await this.driver.createGeoIndex(this.table, column, options);
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
case "dropGeoIndex":
|
|
315
|
+
await this.driver.dropGeoIndex(this.table, op.payload);
|
|
316
|
+
break;
|
|
317
|
+
case "createVectorIndex": {
|
|
318
|
+
const { column, options } = op.payload;
|
|
319
|
+
await this.driver.createVectorIndex(this.table, column, options);
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
case "dropVectorIndex":
|
|
323
|
+
await this.driver.dropVectorIndex(this.table, op.payload);
|
|
324
|
+
break;
|
|
325
|
+
case "createTTLIndex": {
|
|
326
|
+
const { column, seconds } = op.payload;
|
|
327
|
+
await this.driver.createTTLIndex(this.table, column, seconds);
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
case "dropTTLIndex":
|
|
331
|
+
await this.driver.dropTTLIndex(this.table, op.payload);
|
|
332
|
+
break;
|
|
333
|
+
case "addForeignKey":
|
|
334
|
+
await this.driver.addForeignKey(this.table, op.payload);
|
|
335
|
+
break;
|
|
336
|
+
case "dropForeignKey":
|
|
337
|
+
await this.driver.dropForeignKey(this.table, op.payload);
|
|
338
|
+
break;
|
|
339
|
+
case "addPrimaryKey":
|
|
340
|
+
await this.driver.addPrimaryKey(this.table, op.payload);
|
|
341
|
+
break;
|
|
342
|
+
case "dropPrimaryKey":
|
|
343
|
+
await this.driver.dropPrimaryKey(this.table);
|
|
344
|
+
break;
|
|
345
|
+
case "addCheck": {
|
|
346
|
+
const { name, expression } = op.payload;
|
|
347
|
+
await this.driver.addCheck(this.table, name, expression);
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
case "dropCheck":
|
|
351
|
+
await this.driver.dropCheck(this.table, op.payload);
|
|
352
|
+
break;
|
|
353
|
+
case "createTable":
|
|
354
|
+
await this.driver.createTable(this.table);
|
|
355
|
+
break;
|
|
356
|
+
case "createTableIfNotExists":
|
|
357
|
+
await this.driver.createTableIfNotExists(this.table);
|
|
358
|
+
break;
|
|
359
|
+
case "dropTable":
|
|
360
|
+
await this.driver.dropTable(this.table);
|
|
361
|
+
break;
|
|
362
|
+
case "dropTableIfExists":
|
|
363
|
+
await this.driver.dropTableIfExists(this.table);
|
|
364
|
+
break;
|
|
365
|
+
case "renameTable":
|
|
366
|
+
await this.driver.renameTable(this.table, op.payload);
|
|
367
|
+
break;
|
|
368
|
+
case "truncateTable":
|
|
369
|
+
await this.driver.truncateTable(this.table);
|
|
370
|
+
break;
|
|
371
|
+
case "createTimestamps":
|
|
372
|
+
await this.driver.createTimestampColumns(this.table);
|
|
373
|
+
break;
|
|
374
|
+
case "rawStatement":
|
|
375
|
+
await this.driver.raw(async (client) => {
|
|
376
|
+
const sql = op.payload;
|
|
377
|
+
if (typeof client.query === "function") await client.query(sql);
|
|
378
|
+
else if (typeof client.command === "function") await client.command({ $eval: sql });
|
|
379
|
+
else throw new Error("Unsupported database driver for statement execution");
|
|
380
|
+
});
|
|
381
|
+
break;
|
|
382
|
+
case "setSchemaValidation":
|
|
383
|
+
await this.driver.setSchemaValidation(this.table, op.payload);
|
|
384
|
+
break;
|
|
385
|
+
case "removeSchemaValidation":
|
|
386
|
+
await this.driver.removeSchemaValidation(this.table);
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Check if a table exists.
|
|
392
|
+
*
|
|
393
|
+
* Useful for conditional migrations and idempotent operations.
|
|
394
|
+
*
|
|
395
|
+
* @param tableName - Table name to check
|
|
396
|
+
* @returns Promise resolving to true if table exists
|
|
397
|
+
*
|
|
398
|
+
* @example
|
|
399
|
+
* ```typescript
|
|
400
|
+
* public async up() {
|
|
401
|
+
* if (await this.hasTable("users_backup")) {
|
|
402
|
+
* this.dropTable("users_backup");
|
|
403
|
+
* }
|
|
404
|
+
* // ... rest of migration
|
|
405
|
+
* }
|
|
406
|
+
* ```
|
|
407
|
+
*/
|
|
408
|
+
async hasTable(tableName) {
|
|
409
|
+
return this.driver.tableExists(tableName);
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Check if a column exists in the current table.
|
|
413
|
+
*
|
|
414
|
+
* @param columnName - Column name to check
|
|
415
|
+
* @returns Promise resolving to true if column exists
|
|
416
|
+
*
|
|
417
|
+
* @example
|
|
418
|
+
* ```typescript
|
|
419
|
+
* public async up() {
|
|
420
|
+
* if (!(await this.hasColumn("email"))) {
|
|
421
|
+
* this.string("email").unique();
|
|
422
|
+
* }
|
|
423
|
+
* }
|
|
424
|
+
* ```
|
|
425
|
+
*/
|
|
426
|
+
async hasColumn(columnName) {
|
|
427
|
+
return (await this.getColumns()).some((col) => col.name === columnName);
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Get all columns in the current table.
|
|
431
|
+
*
|
|
432
|
+
* @returns Promise resolving to array of column definitions
|
|
433
|
+
*
|
|
434
|
+
* @example
|
|
435
|
+
* ```typescript
|
|
436
|
+
* const columns = await this.getColumns();
|
|
437
|
+
* if (columns.find(col => col.type === "string" && !col.length)) {
|
|
438
|
+
* // migrate all unbounded strings
|
|
439
|
+
* }
|
|
440
|
+
* ```
|
|
441
|
+
*/
|
|
442
|
+
async getColumns() {
|
|
443
|
+
return this.driver.listColumns(this.table);
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* List all tables in the current database/connection.
|
|
447
|
+
*
|
|
448
|
+
* @returns Promise resolving to array of table names
|
|
449
|
+
*
|
|
450
|
+
* @example
|
|
451
|
+
* ```typescript
|
|
452
|
+
* const tables = await this.listTables();
|
|
453
|
+
* for (const table of tables) {
|
|
454
|
+
* // process each table
|
|
455
|
+
* }
|
|
456
|
+
* ```
|
|
457
|
+
*/
|
|
458
|
+
async listTables() {
|
|
459
|
+
return this.driver.listTables();
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Get all indexes on the current table.
|
|
463
|
+
*/
|
|
464
|
+
async getIndexes() {
|
|
465
|
+
return this.driver.listIndexes(this.table);
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Check if a named index exists on the current table.
|
|
469
|
+
*/
|
|
470
|
+
async hasIndex(indexName) {
|
|
471
|
+
return (await this.getIndexes()).some((idx) => idx.name === indexName);
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Add a pending index definition.
|
|
475
|
+
*
|
|
476
|
+
* Called by ColumnBuilder when .unique() or .index() is chained.
|
|
477
|
+
* Routes into pendingOperations so indexes execute in definition order
|
|
478
|
+
* alongside columns and constraints.
|
|
479
|
+
*
|
|
480
|
+
* @param index - Index definition
|
|
481
|
+
* @internal
|
|
482
|
+
*/
|
|
483
|
+
addPendingIndex(index) {
|
|
484
|
+
if (index.unique) this.pendingOperations.push({
|
|
485
|
+
type: "createUniqueIndex",
|
|
486
|
+
payload: {
|
|
487
|
+
columns: index.columns,
|
|
488
|
+
name: index.name
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
else this.pendingOperations.push({
|
|
492
|
+
type: "createIndex",
|
|
493
|
+
payload: index
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Add a foreign key operation.
|
|
498
|
+
*
|
|
499
|
+
* Called by ForeignKeyBuilder or ColumnBuilder when .references() is called.
|
|
500
|
+
*
|
|
501
|
+
* @param fk - Foreign key definition
|
|
502
|
+
* @internal
|
|
503
|
+
*/
|
|
504
|
+
addForeignKeyOperation(fk) {
|
|
505
|
+
this.pendingOperations.push({
|
|
506
|
+
type: "addForeignKey",
|
|
507
|
+
payload: fk
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Create the table/collection.
|
|
512
|
+
*
|
|
513
|
+
* For SQL, this creates an empty table.
|
|
514
|
+
* For MongoDB, this creates the collection.
|
|
515
|
+
*
|
|
516
|
+
* @returns This migration for chaining
|
|
517
|
+
*/
|
|
518
|
+
createTable() {
|
|
519
|
+
this.pendingOperations.push({
|
|
520
|
+
type: "createTable",
|
|
521
|
+
payload: null
|
|
522
|
+
});
|
|
523
|
+
return this;
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Create table if not exists
|
|
527
|
+
*/
|
|
528
|
+
createTableIfNotExists() {
|
|
529
|
+
this.pendingOperations.push({
|
|
530
|
+
type: "createTableIfNotExists",
|
|
531
|
+
payload: null
|
|
532
|
+
});
|
|
533
|
+
return this;
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Drop the table/collection.
|
|
537
|
+
*
|
|
538
|
+
* @returns This migration for chaining
|
|
539
|
+
*/
|
|
540
|
+
dropTable() {
|
|
541
|
+
this.pendingOperations.push({
|
|
542
|
+
type: "dropTable",
|
|
543
|
+
payload: null
|
|
544
|
+
});
|
|
545
|
+
return this;
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Drop the table/collection if it exists.
|
|
549
|
+
*
|
|
550
|
+
* No error is thrown if the table doesn't exist.
|
|
551
|
+
*
|
|
552
|
+
* @returns This migration for chaining
|
|
553
|
+
*/
|
|
554
|
+
dropTableIfExists() {
|
|
555
|
+
this.pendingOperations.push({
|
|
556
|
+
type: "dropTableIfExists",
|
|
557
|
+
payload: null
|
|
558
|
+
});
|
|
559
|
+
return this;
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Rename the table/collection.
|
|
563
|
+
*
|
|
564
|
+
* @param newName - New table name
|
|
565
|
+
* @returns This migration for chaining
|
|
566
|
+
*/
|
|
567
|
+
renameTableTo(newName) {
|
|
568
|
+
this.pendingOperations.push({
|
|
569
|
+
type: "renameTable",
|
|
570
|
+
payload: newName
|
|
571
|
+
});
|
|
572
|
+
return this;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Truncate the table — remove all rows without logging or firing triggers.
|
|
576
|
+
*
|
|
577
|
+
* Faster than DELETE with no WHERE clause. Resets auto-increment counters
|
|
578
|
+
* on most databases.
|
|
579
|
+
*
|
|
580
|
+
* @returns This migration for chaining
|
|
581
|
+
*/
|
|
582
|
+
truncateTable() {
|
|
583
|
+
this.pendingOperations.push({
|
|
584
|
+
type: "truncateTable",
|
|
585
|
+
payload: null
|
|
586
|
+
});
|
|
587
|
+
return this;
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* Add a string/varchar column.
|
|
591
|
+
*
|
|
592
|
+
* @param column - Column name
|
|
593
|
+
* @param length - Max length (default: 255)
|
|
594
|
+
* @returns Column builder for chaining modifiers
|
|
595
|
+
*
|
|
596
|
+
* @example
|
|
597
|
+
* ```typescript
|
|
598
|
+
* this.string("name"); // VARCHAR(255)
|
|
599
|
+
* this.string("code", 10); // VARCHAR(10)
|
|
600
|
+
* ```
|
|
601
|
+
*/
|
|
602
|
+
string(column, length = 255) {
|
|
603
|
+
const builder = new ColumnBuilder(this, column, "string", { length });
|
|
604
|
+
this.pendingOperations.push({
|
|
605
|
+
type: "addColumn",
|
|
606
|
+
payload: builder.getDefinition()
|
|
607
|
+
});
|
|
608
|
+
return builder;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Add a fixed-length char column.
|
|
612
|
+
*
|
|
613
|
+
* @param column - Column name
|
|
614
|
+
* @param length - Exact length
|
|
615
|
+
* @returns Column builder for chaining modifiers
|
|
616
|
+
*/
|
|
617
|
+
char(column, length) {
|
|
618
|
+
const builder = new ColumnBuilder(this, column, "char", { length });
|
|
619
|
+
this.pendingOperations.push({
|
|
620
|
+
type: "addColumn",
|
|
621
|
+
payload: builder.getDefinition()
|
|
622
|
+
});
|
|
623
|
+
return builder;
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Add a text column (unlimited length).
|
|
627
|
+
*
|
|
628
|
+
* @param column - Column name
|
|
629
|
+
* @returns Column builder for chaining modifiers
|
|
630
|
+
*/
|
|
631
|
+
text(column) {
|
|
632
|
+
const builder = new ColumnBuilder(this, column, "text");
|
|
633
|
+
this.pendingOperations.push({
|
|
634
|
+
type: "addColumn",
|
|
635
|
+
payload: builder.getDefinition()
|
|
636
|
+
});
|
|
637
|
+
return builder;
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Add a medium text column.
|
|
641
|
+
*
|
|
642
|
+
* @param column - Column name
|
|
643
|
+
* @returns Column builder for chaining modifiers
|
|
644
|
+
*/
|
|
645
|
+
mediumText(column) {
|
|
646
|
+
const builder = new ColumnBuilder(this, column, "mediumText");
|
|
647
|
+
this.pendingOperations.push({
|
|
648
|
+
type: "addColumn",
|
|
649
|
+
payload: builder.getDefinition()
|
|
650
|
+
});
|
|
651
|
+
return builder;
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Add a long text column.
|
|
655
|
+
*
|
|
656
|
+
* @param column - Column name
|
|
657
|
+
* @returns Column builder for chaining modifiers
|
|
658
|
+
*/
|
|
659
|
+
longText(column) {
|
|
660
|
+
const builder = new ColumnBuilder(this, column, "longText");
|
|
661
|
+
this.pendingOperations.push({
|
|
662
|
+
type: "addColumn",
|
|
663
|
+
payload: builder.getDefinition()
|
|
664
|
+
});
|
|
665
|
+
return builder;
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Add an integer column.
|
|
669
|
+
*
|
|
670
|
+
* @param column - Column name
|
|
671
|
+
* @returns Column builder for chaining modifiers
|
|
672
|
+
*/
|
|
673
|
+
integer(column) {
|
|
674
|
+
const builder = new ColumnBuilder(this, column, "integer");
|
|
675
|
+
this.pendingOperations.push({
|
|
676
|
+
type: "addColumn",
|
|
677
|
+
payload: builder.getDefinition()
|
|
678
|
+
});
|
|
679
|
+
return builder;
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* Alias for integer().
|
|
683
|
+
*/
|
|
684
|
+
int(column) {
|
|
685
|
+
return this.integer(column);
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* Add a small integer column.
|
|
689
|
+
*
|
|
690
|
+
* @param column - Column name
|
|
691
|
+
* @returns Column builder for chaining modifiers
|
|
692
|
+
*/
|
|
693
|
+
smallInteger(column) {
|
|
694
|
+
const builder = new ColumnBuilder(this, column, "smallInteger");
|
|
695
|
+
this.pendingOperations.push({
|
|
696
|
+
type: "addColumn",
|
|
697
|
+
payload: builder.getDefinition()
|
|
698
|
+
});
|
|
699
|
+
return builder;
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Alias for smallInteger().
|
|
703
|
+
*/
|
|
704
|
+
smallInt(column) {
|
|
705
|
+
return this.smallInteger(column);
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* Add a tiny integer column.
|
|
709
|
+
*
|
|
710
|
+
* @param column - Column name
|
|
711
|
+
* @returns Column builder for chaining modifiers
|
|
712
|
+
*/
|
|
713
|
+
tinyInteger(column) {
|
|
714
|
+
const builder = new ColumnBuilder(this, column, "tinyInteger");
|
|
715
|
+
this.pendingOperations.push({
|
|
716
|
+
type: "addColumn",
|
|
717
|
+
payload: builder.getDefinition()
|
|
718
|
+
});
|
|
719
|
+
return builder;
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* Alias for tinyInteger().
|
|
723
|
+
*/
|
|
724
|
+
tinyInt(column) {
|
|
725
|
+
return this.tinyInteger(column);
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* Add a big integer column.
|
|
729
|
+
*
|
|
730
|
+
* @param column - Column name
|
|
731
|
+
* @returns Column builder for chaining modifiers
|
|
732
|
+
*/
|
|
733
|
+
bigInteger(column) {
|
|
734
|
+
const builder = new ColumnBuilder(this, column, "bigInteger");
|
|
735
|
+
this.pendingOperations.push({
|
|
736
|
+
type: "addColumn",
|
|
737
|
+
payload: builder.getDefinition()
|
|
738
|
+
});
|
|
739
|
+
return builder;
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* Alias for bigInteger().
|
|
743
|
+
*/
|
|
744
|
+
bigInt(column) {
|
|
745
|
+
return this.bigInteger(column);
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Add a float column.
|
|
749
|
+
*
|
|
750
|
+
* @param column - Column name
|
|
751
|
+
* @returns Column builder for chaining modifiers
|
|
752
|
+
*/
|
|
753
|
+
float(column) {
|
|
754
|
+
const builder = new ColumnBuilder(this, column, "float");
|
|
755
|
+
this.pendingOperations.push({
|
|
756
|
+
type: "addColumn",
|
|
757
|
+
payload: builder.getDefinition()
|
|
758
|
+
});
|
|
759
|
+
return builder;
|
|
760
|
+
}
|
|
761
|
+
/**
|
|
762
|
+
* Add a double precision column.
|
|
763
|
+
*
|
|
764
|
+
* @param column - Column name
|
|
765
|
+
* @returns Column builder for chaining modifiers
|
|
766
|
+
*/
|
|
767
|
+
double(column) {
|
|
768
|
+
const builder = new ColumnBuilder(this, column, "double");
|
|
769
|
+
this.pendingOperations.push({
|
|
770
|
+
type: "addColumn",
|
|
771
|
+
payload: builder.getDefinition()
|
|
772
|
+
});
|
|
773
|
+
return builder;
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* Add a decimal column with precision and scale.
|
|
777
|
+
*
|
|
778
|
+
* @param column - Column name
|
|
779
|
+
* @param precision - Total digits (default: 8)
|
|
780
|
+
* @param scale - Decimal places (default: 2)
|
|
781
|
+
* @returns Column builder for chaining modifiers
|
|
782
|
+
*
|
|
783
|
+
* @example
|
|
784
|
+
* ```typescript
|
|
785
|
+
* this.decimal("price", 10, 2); // DECIMAL(10,2) - up to 99999999.99
|
|
786
|
+
* ```
|
|
787
|
+
*/
|
|
788
|
+
decimal(column, precision = 8, scale = 2) {
|
|
789
|
+
const builder = new ColumnBuilder(this, column, "decimal", {
|
|
790
|
+
precision,
|
|
791
|
+
scale
|
|
792
|
+
});
|
|
793
|
+
this.pendingOperations.push({
|
|
794
|
+
type: "addColumn",
|
|
795
|
+
payload: builder.getDefinition()
|
|
796
|
+
});
|
|
797
|
+
return builder;
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* Add a boolean column.
|
|
801
|
+
*
|
|
802
|
+
* @param column - Column name
|
|
803
|
+
* @returns Column builder for chaining modifiers
|
|
804
|
+
*/
|
|
805
|
+
boolean(column) {
|
|
806
|
+
const builder = new ColumnBuilder(this, column, "boolean");
|
|
807
|
+
this.pendingOperations.push({
|
|
808
|
+
type: "addColumn",
|
|
809
|
+
payload: builder.getDefinition()
|
|
810
|
+
});
|
|
811
|
+
return builder;
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* Alias for boolean().
|
|
815
|
+
*/
|
|
816
|
+
bool(column) {
|
|
817
|
+
return this.boolean(column);
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* Add a date column (date only, no time).
|
|
821
|
+
*
|
|
822
|
+
* @param column - Column name
|
|
823
|
+
* @returns Column builder for chaining modifiers
|
|
824
|
+
*/
|
|
825
|
+
date(column) {
|
|
826
|
+
const builder = new ColumnBuilder(this, column, "date");
|
|
827
|
+
this.pendingOperations.push({
|
|
828
|
+
type: "addColumn",
|
|
829
|
+
payload: builder.getDefinition()
|
|
830
|
+
});
|
|
831
|
+
return builder;
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* Add a datetime column (date and time).
|
|
835
|
+
*
|
|
836
|
+
* @param column - Column name
|
|
837
|
+
* @returns Column builder for chaining modifiers
|
|
838
|
+
*/
|
|
839
|
+
dateTime(column) {
|
|
840
|
+
const builder = new ColumnBuilder(this, column, "dateTime");
|
|
841
|
+
this.pendingOperations.push({
|
|
842
|
+
type: "addColumn",
|
|
843
|
+
payload: builder.getDefinition()
|
|
844
|
+
});
|
|
845
|
+
return builder;
|
|
846
|
+
}
|
|
847
|
+
/**
|
|
848
|
+
* Add a timestamp column.
|
|
849
|
+
*
|
|
850
|
+
* @param column - Column name
|
|
851
|
+
* @returns Column builder for chaining modifiers
|
|
852
|
+
*/
|
|
853
|
+
timestamp(column) {
|
|
854
|
+
const builder = new ColumnBuilder(this, column, "timestamp");
|
|
855
|
+
this.pendingOperations.push({
|
|
856
|
+
type: "addColumn",
|
|
857
|
+
payload: builder.getDefinition()
|
|
858
|
+
});
|
|
859
|
+
return builder;
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* Add a time column (time only, no date).
|
|
863
|
+
*
|
|
864
|
+
* @param column - Column name
|
|
865
|
+
* @returns Column builder for chaining modifiers
|
|
866
|
+
*/
|
|
867
|
+
time(column) {
|
|
868
|
+
const builder = new ColumnBuilder(this, column, "time");
|
|
869
|
+
this.pendingOperations.push({
|
|
870
|
+
type: "addColumn",
|
|
871
|
+
payload: builder.getDefinition()
|
|
872
|
+
});
|
|
873
|
+
return builder;
|
|
874
|
+
}
|
|
875
|
+
/**
|
|
876
|
+
* Add a year column.
|
|
877
|
+
*
|
|
878
|
+
* @param column - Column name
|
|
879
|
+
* @returns Column builder for chaining modifiers
|
|
880
|
+
*/
|
|
881
|
+
year(column) {
|
|
882
|
+
const builder = new ColumnBuilder(this, column, "year");
|
|
883
|
+
this.pendingOperations.push({
|
|
884
|
+
type: "addColumn",
|
|
885
|
+
payload: builder.getDefinition()
|
|
886
|
+
});
|
|
887
|
+
return builder;
|
|
888
|
+
}
|
|
889
|
+
/**
|
|
890
|
+
* Add a JSON column.
|
|
891
|
+
*
|
|
892
|
+
* @param column - Column name
|
|
893
|
+
* @returns Column builder for chaining modifiers
|
|
894
|
+
*/
|
|
895
|
+
json(column) {
|
|
896
|
+
const builder = new ColumnBuilder(this, column, "json");
|
|
897
|
+
this.pendingOperations.push({
|
|
898
|
+
type: "addColumn",
|
|
899
|
+
payload: builder.getDefinition()
|
|
900
|
+
});
|
|
901
|
+
return builder;
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
904
|
+
* Alias for json().
|
|
905
|
+
*/
|
|
906
|
+
object(column) {
|
|
907
|
+
return this.json(column);
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* Add a binary/blob column.
|
|
911
|
+
*
|
|
912
|
+
* @param column - Column name
|
|
913
|
+
* @returns Column builder for chaining modifiers
|
|
914
|
+
*/
|
|
915
|
+
binary(column) {
|
|
916
|
+
const builder = new ColumnBuilder(this, column, "binary");
|
|
917
|
+
this.pendingOperations.push({
|
|
918
|
+
type: "addColumn",
|
|
919
|
+
payload: builder.getDefinition()
|
|
920
|
+
});
|
|
921
|
+
return builder;
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* Alias for binary().
|
|
925
|
+
*/
|
|
926
|
+
blob(column) {
|
|
927
|
+
return this.binary(column);
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* Add a UUID column.
|
|
931
|
+
*
|
|
932
|
+
* @param column - Column name
|
|
933
|
+
* @returns Column builder for chaining modifiers
|
|
934
|
+
*/
|
|
935
|
+
uuid(column) {
|
|
936
|
+
const builder = new ColumnBuilder(this, column, "uuid");
|
|
937
|
+
this.pendingOperations.push({
|
|
938
|
+
type: "addColumn",
|
|
939
|
+
payload: builder.getDefinition()
|
|
940
|
+
});
|
|
941
|
+
return builder;
|
|
942
|
+
}
|
|
943
|
+
/**
|
|
944
|
+
* Add a ULID column.
|
|
945
|
+
*
|
|
946
|
+
* @param column - Column name
|
|
947
|
+
* @returns Column builder for chaining modifiers
|
|
948
|
+
*/
|
|
949
|
+
ulid(column) {
|
|
950
|
+
const builder = new ColumnBuilder(this, column, "ulid");
|
|
951
|
+
this.pendingOperations.push({
|
|
952
|
+
type: "addColumn",
|
|
953
|
+
payload: builder.getDefinition()
|
|
954
|
+
});
|
|
955
|
+
return builder;
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* Add an IP address column.
|
|
959
|
+
*
|
|
960
|
+
* @param column - Column name
|
|
961
|
+
* @returns Column builder for chaining modifiers
|
|
962
|
+
*/
|
|
963
|
+
ipAddress(column) {
|
|
964
|
+
const builder = new ColumnBuilder(this, column, "ipAddress");
|
|
965
|
+
this.pendingOperations.push({
|
|
966
|
+
type: "addColumn",
|
|
967
|
+
payload: builder.getDefinition()
|
|
968
|
+
});
|
|
969
|
+
return builder;
|
|
970
|
+
}
|
|
971
|
+
/**
|
|
972
|
+
* Add a MAC address column.
|
|
973
|
+
*
|
|
974
|
+
* @param column - Column name
|
|
975
|
+
* @returns Column builder for chaining modifiers
|
|
976
|
+
*/
|
|
977
|
+
macAddress(column) {
|
|
978
|
+
const builder = new ColumnBuilder(this, column, "macAddress");
|
|
979
|
+
this.pendingOperations.push({
|
|
980
|
+
type: "addColumn",
|
|
981
|
+
payload: builder.getDefinition()
|
|
982
|
+
});
|
|
983
|
+
return builder;
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* Add a geo point column.
|
|
987
|
+
*
|
|
988
|
+
* @param column - Column name
|
|
989
|
+
* @returns Column builder for chaining modifiers
|
|
990
|
+
*/
|
|
991
|
+
point(column) {
|
|
992
|
+
const builder = new ColumnBuilder(this, column, "point");
|
|
993
|
+
this.pendingOperations.push({
|
|
994
|
+
type: "addColumn",
|
|
995
|
+
payload: builder.getDefinition()
|
|
996
|
+
});
|
|
997
|
+
return builder;
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* Add a polygon column.
|
|
1001
|
+
*
|
|
1002
|
+
* @param column - Column name
|
|
1003
|
+
* @returns Column builder for chaining modifiers
|
|
1004
|
+
*/
|
|
1005
|
+
polygon(column) {
|
|
1006
|
+
const builder = new ColumnBuilder(this, column, "polygon");
|
|
1007
|
+
this.pendingOperations.push({
|
|
1008
|
+
type: "addColumn",
|
|
1009
|
+
payload: builder.getDefinition()
|
|
1010
|
+
});
|
|
1011
|
+
return builder;
|
|
1012
|
+
}
|
|
1013
|
+
/**
|
|
1014
|
+
* Add a line string column.
|
|
1015
|
+
*
|
|
1016
|
+
* @param column - Column name
|
|
1017
|
+
* @returns Column builder for chaining modifiers
|
|
1018
|
+
*/
|
|
1019
|
+
lineString(column) {
|
|
1020
|
+
const builder = new ColumnBuilder(this, column, "lineString");
|
|
1021
|
+
this.pendingOperations.push({
|
|
1022
|
+
type: "addColumn",
|
|
1023
|
+
payload: builder.getDefinition()
|
|
1024
|
+
});
|
|
1025
|
+
return builder;
|
|
1026
|
+
}
|
|
1027
|
+
/**
|
|
1028
|
+
* Add a generic geometry column.
|
|
1029
|
+
*
|
|
1030
|
+
* @param column - Column name
|
|
1031
|
+
* @returns Column builder for chaining modifiers
|
|
1032
|
+
*/
|
|
1033
|
+
geometry(column) {
|
|
1034
|
+
const builder = new ColumnBuilder(this, column, "geometry");
|
|
1035
|
+
this.pendingOperations.push({
|
|
1036
|
+
type: "addColumn",
|
|
1037
|
+
payload: builder.getDefinition()
|
|
1038
|
+
});
|
|
1039
|
+
return builder;
|
|
1040
|
+
}
|
|
1041
|
+
/**
|
|
1042
|
+
* Add a vector column for AI embeddings.
|
|
1043
|
+
*
|
|
1044
|
+
* Used for storing and searching ML embeddings (e.g., OpenAI, Cohere).
|
|
1045
|
+
*
|
|
1046
|
+
* @param column - Column name
|
|
1047
|
+
* @param dimensions - Vector dimensions (e.g., 1536 for OpenAI ada-002)
|
|
1048
|
+
* @returns Column builder for chaining modifiers
|
|
1049
|
+
*
|
|
1050
|
+
* @example
|
|
1051
|
+
* ```typescript
|
|
1052
|
+
* this.vector("embedding", 1536); // OpenAI ada-002
|
|
1053
|
+
* this.vector("embedding", 384); // Sentence Transformers
|
|
1054
|
+
* ```
|
|
1055
|
+
*/
|
|
1056
|
+
vector(column, dimensions) {
|
|
1057
|
+
const builder = new ColumnBuilder(this, column, "vector", { dimensions });
|
|
1058
|
+
this.pendingOperations.push({
|
|
1059
|
+
type: "addColumn",
|
|
1060
|
+
payload: builder.getDefinition()
|
|
1061
|
+
});
|
|
1062
|
+
return builder;
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Add an enum column with allowed values.
|
|
1066
|
+
*
|
|
1067
|
+
* @param column - Column name
|
|
1068
|
+
* @param values - Allowed enum values
|
|
1069
|
+
* @returns Column builder for chaining modifiers
|
|
1070
|
+
*
|
|
1071
|
+
* @example
|
|
1072
|
+
* ```typescript
|
|
1073
|
+
* this.enum("status", ["pending", "active", "archived"]);
|
|
1074
|
+
* ```
|
|
1075
|
+
*/
|
|
1076
|
+
enum(column, values) {
|
|
1077
|
+
const builder = new ColumnBuilder(this, column, "enum", { values });
|
|
1078
|
+
this.pendingOperations.push({
|
|
1079
|
+
type: "addColumn",
|
|
1080
|
+
payload: builder.getDefinition()
|
|
1081
|
+
});
|
|
1082
|
+
return builder;
|
|
1083
|
+
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Add a set column (multiple values from a set).
|
|
1086
|
+
*
|
|
1087
|
+
* @param column - Column name
|
|
1088
|
+
* @param values - Allowed set values
|
|
1089
|
+
* @returns Column builder for chaining modifiers
|
|
1090
|
+
*/
|
|
1091
|
+
set(column, values) {
|
|
1092
|
+
const builder = new ColumnBuilder(this, column, "set", { values });
|
|
1093
|
+
this.pendingOperations.push({
|
|
1094
|
+
type: "addColumn",
|
|
1095
|
+
payload: builder.getDefinition()
|
|
1096
|
+
});
|
|
1097
|
+
return builder;
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* Add an INTEGER[] column (array of integers).
|
|
1101
|
+
*
|
|
1102
|
+
* @example
|
|
1103
|
+
* ```typescript
|
|
1104
|
+
* this.arrayInt("scores"); // INTEGER[]
|
|
1105
|
+
* ```
|
|
1106
|
+
*/
|
|
1107
|
+
arrayInt(column) {
|
|
1108
|
+
const builder = new ColumnBuilder(this, column, "arrayInt");
|
|
1109
|
+
this.pendingOperations.push({
|
|
1110
|
+
type: "addColumn",
|
|
1111
|
+
payload: builder.getDefinition()
|
|
1112
|
+
});
|
|
1113
|
+
return builder;
|
|
1114
|
+
}
|
|
1115
|
+
/**
|
|
1116
|
+
* Add a BIGINT[] column (array of big integers).
|
|
1117
|
+
*
|
|
1118
|
+
* @example
|
|
1119
|
+
* ```typescript
|
|
1120
|
+
* this.arrayBigInt("ids"); // BIGINT[]
|
|
1121
|
+
* ```
|
|
1122
|
+
*/
|
|
1123
|
+
arrayBigInt(column) {
|
|
1124
|
+
const builder = new ColumnBuilder(this, column, "arrayBigInt");
|
|
1125
|
+
this.pendingOperations.push({
|
|
1126
|
+
type: "addColumn",
|
|
1127
|
+
payload: builder.getDefinition()
|
|
1128
|
+
});
|
|
1129
|
+
return builder;
|
|
1130
|
+
}
|
|
1131
|
+
/**
|
|
1132
|
+
* Add a REAL[] column (array of floats).
|
|
1133
|
+
*
|
|
1134
|
+
* @example
|
|
1135
|
+
* ```typescript
|
|
1136
|
+
* this.arrayFloat("weights"); // REAL[]
|
|
1137
|
+
* ```
|
|
1138
|
+
*/
|
|
1139
|
+
arrayFloat(column) {
|
|
1140
|
+
const builder = new ColumnBuilder(this, column, "arrayFloat");
|
|
1141
|
+
this.pendingOperations.push({
|
|
1142
|
+
type: "addColumn",
|
|
1143
|
+
payload: builder.getDefinition()
|
|
1144
|
+
});
|
|
1145
|
+
return builder;
|
|
1146
|
+
}
|
|
1147
|
+
/**
|
|
1148
|
+
* Add a DECIMAL[] column (array of decimals).
|
|
1149
|
+
*
|
|
1150
|
+
* @param precision - Total digits
|
|
1151
|
+
* @param scale - Digits after decimal point
|
|
1152
|
+
*
|
|
1153
|
+
* @example
|
|
1154
|
+
* ```typescript
|
|
1155
|
+
* this.arrayDecimal("prices", 10, 2); // DECIMAL(10,2)[]
|
|
1156
|
+
* this.arrayDecimal("amounts"); // DECIMAL[]
|
|
1157
|
+
* ```
|
|
1158
|
+
*/
|
|
1159
|
+
arrayDecimal(column, precision, scale) {
|
|
1160
|
+
const builder = new ColumnBuilder(this, column, "arrayDecimal", {
|
|
1161
|
+
precision,
|
|
1162
|
+
scale
|
|
1163
|
+
});
|
|
1164
|
+
this.pendingOperations.push({
|
|
1165
|
+
type: "addColumn",
|
|
1166
|
+
payload: builder.getDefinition()
|
|
1167
|
+
});
|
|
1168
|
+
return builder;
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Add a BOOLEAN[] column (array of booleans).
|
|
1172
|
+
*
|
|
1173
|
+
* @example
|
|
1174
|
+
* ```typescript
|
|
1175
|
+
* this.arrayBoolean("flags"); // BOOLEAN[]
|
|
1176
|
+
* ```
|
|
1177
|
+
*/
|
|
1178
|
+
arrayBoolean(column) {
|
|
1179
|
+
const builder = new ColumnBuilder(this, column, "arrayBoolean");
|
|
1180
|
+
this.pendingOperations.push({
|
|
1181
|
+
type: "addColumn",
|
|
1182
|
+
payload: builder.getDefinition()
|
|
1183
|
+
});
|
|
1184
|
+
return builder;
|
|
1185
|
+
}
|
|
1186
|
+
/**
|
|
1187
|
+
* Add a TEXT[] column (array of text values).
|
|
1188
|
+
*
|
|
1189
|
+
* @example
|
|
1190
|
+
* ```typescript
|
|
1191
|
+
* this.arrayText("tags"); // TEXT[]
|
|
1192
|
+
* ```
|
|
1193
|
+
*/
|
|
1194
|
+
arrayText(column) {
|
|
1195
|
+
const builder = new ColumnBuilder(this, column, "arrayText");
|
|
1196
|
+
this.pendingOperations.push({
|
|
1197
|
+
type: "addColumn",
|
|
1198
|
+
payload: builder.getDefinition()
|
|
1199
|
+
});
|
|
1200
|
+
return builder;
|
|
1201
|
+
}
|
|
1202
|
+
/**
|
|
1203
|
+
* Add a DATE[] column (array of dates).
|
|
1204
|
+
*
|
|
1205
|
+
* @example
|
|
1206
|
+
* ```typescript
|
|
1207
|
+
* this.arrayDate("holidays"); // DATE[]
|
|
1208
|
+
* ```
|
|
1209
|
+
*/
|
|
1210
|
+
arrayDate(column) {
|
|
1211
|
+
const builder = new ColumnBuilder(this, column, "arrayDate");
|
|
1212
|
+
this.pendingOperations.push({
|
|
1213
|
+
type: "addColumn",
|
|
1214
|
+
payload: builder.getDefinition()
|
|
1215
|
+
});
|
|
1216
|
+
return builder;
|
|
1217
|
+
}
|
|
1218
|
+
/**
|
|
1219
|
+
* Add a TIMESTAMPTZ[] column (array of timestamps with time zone).
|
|
1220
|
+
*
|
|
1221
|
+
* @example
|
|
1222
|
+
* ```typescript
|
|
1223
|
+
* this.arrayTimestamp("events"); // TIMESTAMPTZ[]
|
|
1224
|
+
* ```
|
|
1225
|
+
*/
|
|
1226
|
+
arrayTimestamp(column) {
|
|
1227
|
+
const builder = new ColumnBuilder(this, column, "arrayTimestamp");
|
|
1228
|
+
this.pendingOperations.push({
|
|
1229
|
+
type: "addColumn",
|
|
1230
|
+
payload: builder.getDefinition()
|
|
1231
|
+
});
|
|
1232
|
+
return builder;
|
|
1233
|
+
}
|
|
1234
|
+
/**
|
|
1235
|
+
* Add a UUID[] column (array of UUIDs).
|
|
1236
|
+
*
|
|
1237
|
+
* @example
|
|
1238
|
+
* ```typescript
|
|
1239
|
+
* this.arrayUuid("relatedIds"); // UUID[]
|
|
1240
|
+
* ```
|
|
1241
|
+
*/
|
|
1242
|
+
arrayUuid(column) {
|
|
1243
|
+
const builder = new ColumnBuilder(this, column, "arrayUuid");
|
|
1244
|
+
this.pendingOperations.push({
|
|
1245
|
+
type: "addColumn",
|
|
1246
|
+
payload: builder.getDefinition()
|
|
1247
|
+
});
|
|
1248
|
+
return builder;
|
|
1249
|
+
}
|
|
1250
|
+
/**
|
|
1251
|
+
* Add a JSONB[] column — array of JSON objects.
|
|
1252
|
+
*
|
|
1253
|
+
* @example
|
|
1254
|
+
* ```typescript
|
|
1255
|
+
* this.arrayJson("metadata"); // JSONB[]
|
|
1256
|
+
* ```
|
|
1257
|
+
*/
|
|
1258
|
+
arrayJson(column) {
|
|
1259
|
+
const builder = new ColumnBuilder(this, column, "arrayJson");
|
|
1260
|
+
this.pendingOperations.push({
|
|
1261
|
+
type: "addColumn",
|
|
1262
|
+
payload: builder.getDefinition()
|
|
1263
|
+
});
|
|
1264
|
+
return builder;
|
|
1265
|
+
}
|
|
1266
|
+
/**
|
|
1267
|
+
* Add an auto-increment primary key column.
|
|
1268
|
+
*
|
|
1269
|
+
* Creates an unsigned integer with primary key and auto-increment.
|
|
1270
|
+
*
|
|
1271
|
+
* @param name - Column name (default: "id")
|
|
1272
|
+
* @returns Column builder for chaining modifiers
|
|
1273
|
+
*
|
|
1274
|
+
* @example
|
|
1275
|
+
* ```typescript
|
|
1276
|
+
* this.id(); // Creates "id" column
|
|
1277
|
+
* this.id("userId"); // Creates "userId" column
|
|
1278
|
+
* ```
|
|
1279
|
+
*/
|
|
1280
|
+
id(name = "id") {
|
|
1281
|
+
return this.integer(name).primary().autoIncrement().unsigned();
|
|
1282
|
+
}
|
|
1283
|
+
/**
|
|
1284
|
+
* Add a big integer auto-increment primary key column.
|
|
1285
|
+
*
|
|
1286
|
+
* @param name - Column name (default: "id")
|
|
1287
|
+
* @returns Column builder for chaining modifiers
|
|
1288
|
+
*/
|
|
1289
|
+
bigId(name = "id") {
|
|
1290
|
+
return this.bigInteger(name).primary().autoIncrement().unsigned();
|
|
1291
|
+
}
|
|
1292
|
+
/**
|
|
1293
|
+
* Add a UUID primary key column.
|
|
1294
|
+
*
|
|
1295
|
+
* @param name - Column name (default: "id")
|
|
1296
|
+
* @returns Column builder for chaining modifiers
|
|
1297
|
+
*/
|
|
1298
|
+
uuidId(name = "id") {
|
|
1299
|
+
return this.uuid(name).primary();
|
|
1300
|
+
}
|
|
1301
|
+
/**
|
|
1302
|
+
* Add a UUID primary key column with automatic generation.
|
|
1303
|
+
*
|
|
1304
|
+
* Delegates UUID expression to the migration driver, which resolves
|
|
1305
|
+
* the default based on `migrationDefaults` from the DataSource config.
|
|
1306
|
+
*
|
|
1307
|
+
* Resolution order:
|
|
1308
|
+
* 1. `migrationDefaults.uuidExpression` (raw escape hatch)
|
|
1309
|
+
* 2. `migrationDefaults.uuidStrategy` (mapped per driver)
|
|
1310
|
+
* 3. Driver default (PostgreSQL: `gen_random_uuid()`, MongoDB: undefined)
|
|
1311
|
+
*
|
|
1312
|
+
* @param name - Column name (default: "id")
|
|
1313
|
+
* @returns Column builder for chaining modifiers
|
|
1314
|
+
*
|
|
1315
|
+
* @example
|
|
1316
|
+
* ```typescript
|
|
1317
|
+
* this.primaryUuid(); // id UUID PRIMARY KEY DEFAULT gen_random_uuid()
|
|
1318
|
+
* this.primaryUuid("organization_id"); // Custom column name
|
|
1319
|
+
* ```
|
|
1320
|
+
*/
|
|
1321
|
+
primaryUuid(name = "id") {
|
|
1322
|
+
const uuidDefault = this.driver.getUuidDefault(this._migrationDefaults);
|
|
1323
|
+
const builder = this.uuid(name).primary();
|
|
1324
|
+
if (uuidDefault) builder.default(uuidDefault);
|
|
1325
|
+
return builder;
|
|
1326
|
+
}
|
|
1327
|
+
/**
|
|
1328
|
+
* Add createdAt and updatedAt timestamp columns.
|
|
1329
|
+
*
|
|
1330
|
+
* Behavior varies by database driver:
|
|
1331
|
+
* - PostgreSQL: Creates TIMESTAMPTZ columns with NOW() defaults
|
|
1332
|
+
* - MongoDB: No-op (timestamps handled at application level)
|
|
1333
|
+
*
|
|
1334
|
+
* @returns This migration for chaining
|
|
1335
|
+
*
|
|
1336
|
+
* @example
|
|
1337
|
+
* ```typescript
|
|
1338
|
+
* this.timestamps(); // Driver-specific implementation
|
|
1339
|
+
* ```
|
|
1340
|
+
*/
|
|
1341
|
+
timestamps() {
|
|
1342
|
+
this.pendingOperations.push({
|
|
1343
|
+
type: "createTimestamps",
|
|
1344
|
+
payload: null
|
|
1345
|
+
});
|
|
1346
|
+
return this;
|
|
1347
|
+
}
|
|
1348
|
+
/**
|
|
1349
|
+
* Add a deletedAt column for soft deletes.
|
|
1350
|
+
*
|
|
1351
|
+
* @param column - Column name (default: "deletedAt")
|
|
1352
|
+
* @returns Column builder for chaining modifiers
|
|
1353
|
+
*/
|
|
1354
|
+
softDeletes(column = "deletedAt") {
|
|
1355
|
+
return this.dateTime(column).nullable();
|
|
1356
|
+
}
|
|
1357
|
+
/**
|
|
1358
|
+
* Drop a column.
|
|
1359
|
+
*
|
|
1360
|
+
* @param column - Column name to drop
|
|
1361
|
+
* @returns This migration for chaining
|
|
1362
|
+
*/
|
|
1363
|
+
dropColumn(column) {
|
|
1364
|
+
this.pendingOperations.push({
|
|
1365
|
+
type: "dropColumn",
|
|
1366
|
+
payload: column
|
|
1367
|
+
});
|
|
1368
|
+
return this;
|
|
1369
|
+
}
|
|
1370
|
+
/**
|
|
1371
|
+
* Drop multiple columns.
|
|
1372
|
+
*
|
|
1373
|
+
* @param columns - Column names to drop
|
|
1374
|
+
* @returns This migration for chaining
|
|
1375
|
+
*/
|
|
1376
|
+
dropColumns(...columns) {
|
|
1377
|
+
this.pendingOperations.push({
|
|
1378
|
+
type: "dropColumns",
|
|
1379
|
+
payload: columns
|
|
1380
|
+
});
|
|
1381
|
+
return this;
|
|
1382
|
+
}
|
|
1383
|
+
/**
|
|
1384
|
+
* Rename a column.
|
|
1385
|
+
*
|
|
1386
|
+
* @param from - Current column name
|
|
1387
|
+
* @param to - New column name
|
|
1388
|
+
* @returns This migration for chaining
|
|
1389
|
+
*/
|
|
1390
|
+
renameColumn(from, to) {
|
|
1391
|
+
this.pendingOperations.push({
|
|
1392
|
+
type: "renameColumn",
|
|
1393
|
+
payload: {
|
|
1394
|
+
from,
|
|
1395
|
+
to
|
|
1396
|
+
}
|
|
1397
|
+
});
|
|
1398
|
+
return this;
|
|
1399
|
+
}
|
|
1400
|
+
/**
|
|
1401
|
+
* Create an index on one or more columns.
|
|
1402
|
+
*
|
|
1403
|
+
* @param columns - Column(s) to index
|
|
1404
|
+
* @param name - Optional index name
|
|
1405
|
+
* @param options - Optional index options (include, concurrently)
|
|
1406
|
+
* @returns This migration for chaining
|
|
1407
|
+
*
|
|
1408
|
+
* @example
|
|
1409
|
+
* ```typescript
|
|
1410
|
+
* this.index("email");
|
|
1411
|
+
* this.index(["firstName", "lastName"], "name_idx");
|
|
1412
|
+
* this.index("userId", "idx_user", { include: ["name", "email"] });
|
|
1413
|
+
* this.index("email", "idx_email", { concurrently: true });
|
|
1414
|
+
* ```
|
|
1415
|
+
*/
|
|
1416
|
+
index(columns, name, options) {
|
|
1417
|
+
const cols = Array.isArray(columns) ? columns : [columns];
|
|
1418
|
+
this.pendingOperations.push({
|
|
1419
|
+
type: "createIndex",
|
|
1420
|
+
payload: {
|
|
1421
|
+
columns: cols,
|
|
1422
|
+
name,
|
|
1423
|
+
include: options?.include,
|
|
1424
|
+
concurrently: options?.concurrently
|
|
1425
|
+
}
|
|
1426
|
+
});
|
|
1427
|
+
return this;
|
|
1428
|
+
}
|
|
1429
|
+
/**
|
|
1430
|
+
* Drop an index by name or columns.
|
|
1431
|
+
*
|
|
1432
|
+
* @param nameOrColumns - Index name (string) or columns array
|
|
1433
|
+
* @returns This migration for chaining
|
|
1434
|
+
*
|
|
1435
|
+
* @example
|
|
1436
|
+
* ```typescript
|
|
1437
|
+
* this.dropIndex("email_idx"); // Drop by name
|
|
1438
|
+
* this.dropIndex(["firstName", "lastName"]); // Drop by columns
|
|
1439
|
+
* ```
|
|
1440
|
+
*/
|
|
1441
|
+
dropIndex(nameOrColumns) {
|
|
1442
|
+
this.pendingOperations.push({
|
|
1443
|
+
type: "dropIndex",
|
|
1444
|
+
payload: nameOrColumns
|
|
1445
|
+
});
|
|
1446
|
+
return this;
|
|
1447
|
+
}
|
|
1448
|
+
/**
|
|
1449
|
+
* Create a unique constraint/index.
|
|
1450
|
+
*
|
|
1451
|
+
* @param columns - Column(s) to make unique
|
|
1452
|
+
* @param name - Optional constraint name
|
|
1453
|
+
* @param options - Optional index options (include, concurrently)
|
|
1454
|
+
* @returns This migration for chaining
|
|
1455
|
+
*
|
|
1456
|
+
* @example
|
|
1457
|
+
* ```typescript
|
|
1458
|
+
* this.unique("email");
|
|
1459
|
+
* this.unique(["userId", "roleId"], "unique_user_role");
|
|
1460
|
+
* this.unique("email", "unique_email", { include: ["name"] });
|
|
1461
|
+
* ```
|
|
1462
|
+
*/
|
|
1463
|
+
unique(columns, name, options) {
|
|
1464
|
+
const cols = Array.isArray(columns) ? columns : [columns];
|
|
1465
|
+
this.pendingOperations.push({
|
|
1466
|
+
type: "createUniqueIndex",
|
|
1467
|
+
payload: {
|
|
1468
|
+
columns: cols,
|
|
1469
|
+
name,
|
|
1470
|
+
include: options?.include,
|
|
1471
|
+
concurrently: options?.concurrently
|
|
1472
|
+
}
|
|
1473
|
+
});
|
|
1474
|
+
return this;
|
|
1475
|
+
}
|
|
1476
|
+
/**
|
|
1477
|
+
* Drop a unique constraint/index.
|
|
1478
|
+
*
|
|
1479
|
+
* @param columns - Columns in the unique constraint
|
|
1480
|
+
* @returns This migration for chaining
|
|
1481
|
+
*/
|
|
1482
|
+
dropUnique(columns) {
|
|
1483
|
+
const cols = Array.isArray(columns) ? columns : [columns];
|
|
1484
|
+
this.pendingOperations.push({
|
|
1485
|
+
type: "dropUniqueIndex",
|
|
1486
|
+
payload: cols
|
|
1487
|
+
});
|
|
1488
|
+
return this;
|
|
1489
|
+
}
|
|
1490
|
+
/**
|
|
1491
|
+
* Create an expression-based index.
|
|
1492
|
+
*
|
|
1493
|
+
* Allows indexing on SQL expressions rather than plain columns.
|
|
1494
|
+
* Useful for case-insensitive searches, computed values, etc.
|
|
1495
|
+
*
|
|
1496
|
+
* **Note**: PostgreSQL-specific feature. MongoDB will silently ignore this.
|
|
1497
|
+
*
|
|
1498
|
+
* @param expressions - SQL expression(s) to index
|
|
1499
|
+
* @param name - Optional index name
|
|
1500
|
+
* @param options - Optional index options (concurrently)
|
|
1501
|
+
* @returns This migration for chaining
|
|
1502
|
+
*
|
|
1503
|
+
* @example
|
|
1504
|
+
* ```typescript
|
|
1505
|
+
* // Case-insensitive email index
|
|
1506
|
+
* this.expressionIndex(['lower(email)'], 'idx_email_lower');
|
|
1507
|
+
*
|
|
1508
|
+
* // Multiple expressions
|
|
1509
|
+
* this.expressionIndex(['lower(firstName)', 'lower(lastName)'], 'idx_name_lower');
|
|
1510
|
+
*
|
|
1511
|
+
* // With concurrent creation (requires transactional = false)
|
|
1512
|
+
* this.expressionIndex(['lower(email)'], 'idx_email_lower', { concurrently: true });
|
|
1513
|
+
* ```
|
|
1514
|
+
*/
|
|
1515
|
+
expressionIndex(expressions, name, options) {
|
|
1516
|
+
const exprs = Array.isArray(expressions) ? expressions : [expressions];
|
|
1517
|
+
this.pendingOperations.push({
|
|
1518
|
+
type: "createIndex",
|
|
1519
|
+
payload: {
|
|
1520
|
+
columns: [],
|
|
1521
|
+
expressions: exprs,
|
|
1522
|
+
name,
|
|
1523
|
+
concurrently: options?.concurrently
|
|
1524
|
+
}
|
|
1525
|
+
});
|
|
1526
|
+
return this;
|
|
1527
|
+
}
|
|
1528
|
+
/**
|
|
1529
|
+
* Create a full-text search index.
|
|
1530
|
+
*
|
|
1531
|
+
* @param columns - Column(s) to index
|
|
1532
|
+
* @param options - Full-text options
|
|
1533
|
+
* @returns This migration for chaining
|
|
1534
|
+
*/
|
|
1535
|
+
fullText(columns, options) {
|
|
1536
|
+
const cols = Array.isArray(columns) ? columns : [columns];
|
|
1537
|
+
this.pendingOperations.push({
|
|
1538
|
+
type: "createFullTextIndex",
|
|
1539
|
+
payload: {
|
|
1540
|
+
columns: cols,
|
|
1541
|
+
options
|
|
1542
|
+
}
|
|
1543
|
+
});
|
|
1544
|
+
return this;
|
|
1545
|
+
}
|
|
1546
|
+
/**
|
|
1547
|
+
* Drop a full-text search index.
|
|
1548
|
+
*
|
|
1549
|
+
* @param name - Index name
|
|
1550
|
+
* @returns This migration for chaining
|
|
1551
|
+
*/
|
|
1552
|
+
dropFullText(name) {
|
|
1553
|
+
this.pendingOperations.push({
|
|
1554
|
+
type: "dropFullTextIndex",
|
|
1555
|
+
payload: name
|
|
1556
|
+
});
|
|
1557
|
+
return this;
|
|
1558
|
+
}
|
|
1559
|
+
/**
|
|
1560
|
+
* Create a geo-spatial index.
|
|
1561
|
+
*
|
|
1562
|
+
* @param column - Geo column
|
|
1563
|
+
* @param options - Geo index options
|
|
1564
|
+
* @returns This migration for chaining
|
|
1565
|
+
*
|
|
1566
|
+
* @example
|
|
1567
|
+
* ```typescript
|
|
1568
|
+
* this.geoIndex("location"); // 2dsphere index
|
|
1569
|
+
* this.geoIndex("coordinates", { type: "2d" }); // 2d index
|
|
1570
|
+
* ```
|
|
1571
|
+
*/
|
|
1572
|
+
geoIndex(column, options) {
|
|
1573
|
+
this.pendingOperations.push({
|
|
1574
|
+
type: "createGeoIndex",
|
|
1575
|
+
payload: {
|
|
1576
|
+
column,
|
|
1577
|
+
options
|
|
1578
|
+
}
|
|
1579
|
+
});
|
|
1580
|
+
return this;
|
|
1581
|
+
}
|
|
1582
|
+
/**
|
|
1583
|
+
* Drop a geo-spatial index.
|
|
1584
|
+
*
|
|
1585
|
+
* @param column - Geo column
|
|
1586
|
+
* @returns This migration for chaining
|
|
1587
|
+
*/
|
|
1588
|
+
dropGeoIndex(column) {
|
|
1589
|
+
this.pendingOperations.push({
|
|
1590
|
+
type: "dropGeoIndex",
|
|
1591
|
+
payload: column
|
|
1592
|
+
});
|
|
1593
|
+
return this;
|
|
1594
|
+
}
|
|
1595
|
+
/**
|
|
1596
|
+
* Create a vector search index for AI embeddings.
|
|
1597
|
+
*
|
|
1598
|
+
* @param column - Vector column
|
|
1599
|
+
* @param options - Vector index options
|
|
1600
|
+
* @returns This migration for chaining
|
|
1601
|
+
*
|
|
1602
|
+
* @example
|
|
1603
|
+
* ```typescript
|
|
1604
|
+
* this.vectorIndex("embedding", {
|
|
1605
|
+
* dimensions: 1536,
|
|
1606
|
+
* similarity: "cosine",
|
|
1607
|
+
* });
|
|
1608
|
+
* ```
|
|
1609
|
+
*/
|
|
1610
|
+
vectorIndex(column, options) {
|
|
1611
|
+
this.pendingOperations.push({
|
|
1612
|
+
type: "createVectorIndex",
|
|
1613
|
+
payload: {
|
|
1614
|
+
column,
|
|
1615
|
+
options
|
|
1616
|
+
}
|
|
1617
|
+
});
|
|
1618
|
+
return this;
|
|
1619
|
+
}
|
|
1620
|
+
/**
|
|
1621
|
+
* Drop a vector search index.
|
|
1622
|
+
*
|
|
1623
|
+
* @param column - Vector column
|
|
1624
|
+
* @returns This migration for chaining
|
|
1625
|
+
*/
|
|
1626
|
+
dropVectorIndex(column) {
|
|
1627
|
+
this.pendingOperations.push({
|
|
1628
|
+
type: "dropVectorIndex",
|
|
1629
|
+
payload: column
|
|
1630
|
+
});
|
|
1631
|
+
return this;
|
|
1632
|
+
}
|
|
1633
|
+
/**
|
|
1634
|
+
* Create a TTL (time-to-live) index for automatic document expiration.
|
|
1635
|
+
*
|
|
1636
|
+
* Primarily for MongoDB. Documents are automatically deleted after the
|
|
1637
|
+
* specified time has passed since the date in the column.
|
|
1638
|
+
*
|
|
1639
|
+
* @param column - Date column to check for expiration
|
|
1640
|
+
* @param expireAfterSeconds - Seconds after which documents expire
|
|
1641
|
+
* @returns This migration for chaining
|
|
1642
|
+
*
|
|
1643
|
+
* @example
|
|
1644
|
+
* ```typescript
|
|
1645
|
+
* // Delete sessions 24 hours after createdAt
|
|
1646
|
+
* this.ttlIndex("createdAt", 86400);
|
|
1647
|
+
* ```
|
|
1648
|
+
*/
|
|
1649
|
+
ttlIndex(column, expireAfterSeconds) {
|
|
1650
|
+
this.pendingOperations.push({
|
|
1651
|
+
type: "createTTLIndex",
|
|
1652
|
+
payload: {
|
|
1653
|
+
column,
|
|
1654
|
+
seconds: expireAfterSeconds
|
|
1655
|
+
}
|
|
1656
|
+
});
|
|
1657
|
+
return this;
|
|
1658
|
+
}
|
|
1659
|
+
/**
|
|
1660
|
+
* Drop a TTL index.
|
|
1661
|
+
*
|
|
1662
|
+
* @param column - Column with TTL
|
|
1663
|
+
* @returns This migration for chaining
|
|
1664
|
+
*/
|
|
1665
|
+
dropTTLIndex(column) {
|
|
1666
|
+
this.pendingOperations.push({
|
|
1667
|
+
type: "dropTTLIndex",
|
|
1668
|
+
payload: column
|
|
1669
|
+
});
|
|
1670
|
+
return this;
|
|
1671
|
+
}
|
|
1672
|
+
/**
|
|
1673
|
+
* Add a composite primary key.
|
|
1674
|
+
*
|
|
1675
|
+
* @param columns - Columns to include in the primary key
|
|
1676
|
+
* @returns This migration for chaining
|
|
1677
|
+
*/
|
|
1678
|
+
primaryKey(columns) {
|
|
1679
|
+
this.pendingOperations.push({
|
|
1680
|
+
type: "addPrimaryKey",
|
|
1681
|
+
payload: columns
|
|
1682
|
+
});
|
|
1683
|
+
return this;
|
|
1684
|
+
}
|
|
1685
|
+
/**
|
|
1686
|
+
* Drop the primary key constraint.
|
|
1687
|
+
*
|
|
1688
|
+
* @returns This migration for chaining
|
|
1689
|
+
*/
|
|
1690
|
+
dropPrimaryKey() {
|
|
1691
|
+
this.pendingOperations.push({
|
|
1692
|
+
type: "dropPrimaryKey",
|
|
1693
|
+
payload: null
|
|
1694
|
+
});
|
|
1695
|
+
return this;
|
|
1696
|
+
}
|
|
1697
|
+
/**
|
|
1698
|
+
* Add a CHECK constraint to the table.
|
|
1699
|
+
*
|
|
1700
|
+
* SQL-only feature. PostgreSQL, MySQL 8.0+, SQLite support this.
|
|
1701
|
+
* Validates that rows satisfy the given SQL expression.
|
|
1702
|
+
*
|
|
1703
|
+
* @param name - Constraint name
|
|
1704
|
+
* @param expression - SQL CHECK expression
|
|
1705
|
+
* @returns This migration for chaining
|
|
1706
|
+
*
|
|
1707
|
+
* @example
|
|
1708
|
+
* ```typescript
|
|
1709
|
+
* this.check("age_positive", "age >= 0");
|
|
1710
|
+
* this.check("valid_email", "email LIKE '%@%'");
|
|
1711
|
+
* this.check("price_range", "price BETWEEN 0 AND 1000000");
|
|
1712
|
+
* ```
|
|
1713
|
+
*/
|
|
1714
|
+
check(name, expression) {
|
|
1715
|
+
this.pendingOperations.push({
|
|
1716
|
+
type: "addCheck",
|
|
1717
|
+
payload: {
|
|
1718
|
+
name,
|
|
1719
|
+
expression
|
|
1720
|
+
}
|
|
1721
|
+
});
|
|
1722
|
+
return this;
|
|
1723
|
+
}
|
|
1724
|
+
/**
|
|
1725
|
+
* Drop a CHECK constraint by name.
|
|
1726
|
+
*
|
|
1727
|
+
* @param name - Constraint name
|
|
1728
|
+
* @returns This migration for chaining
|
|
1729
|
+
*
|
|
1730
|
+
* @example
|
|
1731
|
+
* ```typescript
|
|
1732
|
+
* this.dropCheck("age_positive");
|
|
1733
|
+
* ```
|
|
1734
|
+
*/
|
|
1735
|
+
dropCheck(name) {
|
|
1736
|
+
this.pendingOperations.push({
|
|
1737
|
+
type: "dropCheck",
|
|
1738
|
+
payload: name
|
|
1739
|
+
});
|
|
1740
|
+
return this;
|
|
1741
|
+
}
|
|
1742
|
+
/**
|
|
1743
|
+
* Start building a foreign key constraint on an existing column.
|
|
1744
|
+
*
|
|
1745
|
+
* Use this when adding a foreign key to a column that was defined in a
|
|
1746
|
+
* previous migration. For new columns, prefer the inline form:
|
|
1747
|
+
* `this.integer("user_id").references("users").onDelete("cascade")`
|
|
1748
|
+
*
|
|
1749
|
+
* SQL-only feature; NoSQL drivers ignore foreign keys.
|
|
1750
|
+
*
|
|
1751
|
+
* @param column - Local column that references another table
|
|
1752
|
+
* @returns Foreign key builder for chaining
|
|
1753
|
+
*
|
|
1754
|
+
* @example
|
|
1755
|
+
* ```typescript
|
|
1756
|
+
* this.foreign("user_id")
|
|
1757
|
+
* .references("users", "id")
|
|
1758
|
+
* .onDelete("cascade");
|
|
1759
|
+
* ```
|
|
1760
|
+
*/
|
|
1761
|
+
foreign(column) {
|
|
1762
|
+
return new ForeignKeyBuilder(this, column);
|
|
1763
|
+
}
|
|
1764
|
+
/**
|
|
1765
|
+
* Drop a foreign key constraint.
|
|
1766
|
+
*
|
|
1767
|
+
* Two calling forms:
|
|
1768
|
+
*
|
|
1769
|
+
* 1. Auto-compute the name (matches what `addForeignKey` generates):
|
|
1770
|
+
* ```typescript
|
|
1771
|
+
* this.dropForeign("unit_id", Unit.table);
|
|
1772
|
+
* // → drops: fk_{table}_unit_id_units
|
|
1773
|
+
* ```
|
|
1774
|
+
*
|
|
1775
|
+
* 2. Raw constraint name (use when the name was set explicitly):
|
|
1776
|
+
* ```typescript
|
|
1777
|
+
* this.dropForeign("my_custom_fk_name");
|
|
1778
|
+
* ```
|
|
1779
|
+
*
|
|
1780
|
+
* @param columnOrConstraint - Column name (auto mode) or raw constraint name (raw mode)
|
|
1781
|
+
* @param referencesTable - Referenced table name; triggers auto-name computation when provided
|
|
1782
|
+
* @returns This migration for chaining
|
|
1783
|
+
*/
|
|
1784
|
+
dropForeign(columnOrConstraint, referencesTable) {
|
|
1785
|
+
const constraintName = referencesTable ? `fk_${this.table}_${columnOrConstraint}_${referencesTable}` : columnOrConstraint;
|
|
1786
|
+
this.pendingOperations.push({
|
|
1787
|
+
type: "dropForeignKey",
|
|
1788
|
+
payload: constraintName
|
|
1789
|
+
});
|
|
1790
|
+
return this;
|
|
1791
|
+
}
|
|
1792
|
+
/**
|
|
1793
|
+
* Set JSON schema validation rules on the collection.
|
|
1794
|
+
*
|
|
1795
|
+
* MongoDB-only feature. SQL databases ignore this.
|
|
1796
|
+
*
|
|
1797
|
+
* @param schema - JSON Schema object
|
|
1798
|
+
* @returns This migration for chaining
|
|
1799
|
+
*
|
|
1800
|
+
* @example
|
|
1801
|
+
* ```typescript
|
|
1802
|
+
* this.schemaValidation({
|
|
1803
|
+
* bsonType: "object",
|
|
1804
|
+
* required: ["name", "email"],
|
|
1805
|
+
* properties: {
|
|
1806
|
+
* name: { bsonType: "string" },
|
|
1807
|
+
* email: { bsonType: "string" },
|
|
1808
|
+
* },
|
|
1809
|
+
* });
|
|
1810
|
+
* ```
|
|
1811
|
+
*/
|
|
1812
|
+
schemaValidation(schema) {
|
|
1813
|
+
this.pendingOperations.push({
|
|
1814
|
+
type: "setSchemaValidation",
|
|
1815
|
+
payload: schema
|
|
1816
|
+
});
|
|
1817
|
+
return this;
|
|
1818
|
+
}
|
|
1819
|
+
/**
|
|
1820
|
+
* Remove schema validation rules from the collection.
|
|
1821
|
+
*
|
|
1822
|
+
* @returns This migration for chaining
|
|
1823
|
+
*/
|
|
1824
|
+
dropSchemaValidation() {
|
|
1825
|
+
this.pendingOperations.push({
|
|
1826
|
+
type: "removeSchemaValidation",
|
|
1827
|
+
payload: null
|
|
1828
|
+
});
|
|
1829
|
+
return this;
|
|
1830
|
+
}
|
|
1831
|
+
/**
|
|
1832
|
+
* Execute raw operations with direct driver/connection access.
|
|
1833
|
+
*
|
|
1834
|
+
* Use this when you need to bypass the migration API entirely and
|
|
1835
|
+
* interact with the native database driver directly.
|
|
1836
|
+
*
|
|
1837
|
+
* @param callback - Callback receiving the native connection
|
|
1838
|
+
* @returns Result from callback
|
|
1839
|
+
*
|
|
1840
|
+
* @example
|
|
1841
|
+
* ```typescript
|
|
1842
|
+
* await this.withConnection(async (db) => {
|
|
1843
|
+
* await db.collection("users").updateMany({}, { $set: { active: true } });
|
|
1844
|
+
* });
|
|
1845
|
+
* ```
|
|
1846
|
+
*/
|
|
1847
|
+
async withConnection(callback) {
|
|
1848
|
+
return this.driver.raw(callback);
|
|
1849
|
+
}
|
|
1850
|
+
/**
|
|
1851
|
+
* Queue a raw SQL string for execution within the migration.
|
|
1852
|
+
*
|
|
1853
|
+
* The statement is queued and executed in order with other migration
|
|
1854
|
+
* operations, within the transaction context if the migration is transactional.
|
|
1855
|
+
*
|
|
1856
|
+
* Use `withConnection()` instead if you need direct driver access.
|
|
1857
|
+
*
|
|
1858
|
+
* Works with PostgreSQL, MySQL, etc. For MongoDB, uses $eval command.
|
|
1859
|
+
*
|
|
1860
|
+
* @param sql - SQL statement to execute
|
|
1861
|
+
* @returns This migration for chaining
|
|
1862
|
+
*
|
|
1863
|
+
* @example
|
|
1864
|
+
* ```typescript
|
|
1865
|
+
* // Enable PostgreSQL extension
|
|
1866
|
+
* this.raw('CREATE EXTENSION IF NOT EXISTS "uuid-ossp"');
|
|
1867
|
+
*
|
|
1868
|
+
* // Create custom type
|
|
1869
|
+
* this.raw('CREATE TYPE mood AS ENUM (\'happy\', \'sad\', \'neutral\')');
|
|
1870
|
+
* ```
|
|
1871
|
+
*/
|
|
1872
|
+
raw(sql) {
|
|
1873
|
+
this.pendingOperations.push({
|
|
1874
|
+
type: "rawStatement",
|
|
1875
|
+
payload: sql
|
|
1876
|
+
});
|
|
1877
|
+
return this;
|
|
1878
|
+
}
|
|
1879
|
+
/**
|
|
1880
|
+
* Create a declarative initial-table migration.
|
|
1881
|
+
* Implemented and assigned below the class body.
|
|
1882
|
+
*/
|
|
1883
|
+
static create;
|
|
1884
|
+
/**
|
|
1885
|
+
* Create a declarative alteration migration.
|
|
1886
|
+
* Implemented and assigned below the class body.
|
|
1887
|
+
*/
|
|
1888
|
+
static alter;
|
|
1889
|
+
};
|
|
1890
|
+
function migrate(model, options) {
|
|
1891
|
+
return class AnonymousMigration extends Migration {
|
|
1892
|
+
static migrationName = options?.name;
|
|
1893
|
+
static createdAt = options?.createdAt;
|
|
1894
|
+
table = model.table;
|
|
1895
|
+
static transactional = options?.transactional;
|
|
1896
|
+
async up() {
|
|
1897
|
+
await options?.up?.call(this);
|
|
1898
|
+
}
|
|
1899
|
+
async down() {
|
|
1900
|
+
await options?.down?.call(this);
|
|
1901
|
+
}
|
|
1902
|
+
};
|
|
1903
|
+
}
|
|
1904
|
+
/**
|
|
1905
|
+
* Wire a `ColumnMap` onto an active migration instance.
|
|
1906
|
+
*
|
|
1907
|
+
* Fixes up the placeholder column name in each `DetachedColumnBuilder`,
|
|
1908
|
+
* pushes the `addColumn` operation, and transfers any pending FK / index
|
|
1909
|
+
* side effects from the detached sink to the real migration.
|
|
1910
|
+
*
|
|
1911
|
+
* @internal
|
|
1912
|
+
*/
|
|
1913
|
+
function wireColumns(migration, columns) {
|
|
1914
|
+
for (const [columnName, detached] of Object.entries(columns)) {
|
|
1915
|
+
const definition = detached.getDefinition();
|
|
1916
|
+
definition.name = columnName;
|
|
1917
|
+
migration.pendingOperations.push({
|
|
1918
|
+
type: "addColumn",
|
|
1919
|
+
payload: definition
|
|
1920
|
+
});
|
|
1921
|
+
for (const idx of detached.sink.pendingIndexes) {
|
|
1922
|
+
idx.columns = idx.columns.map((col) => col === "__placeholder__" ? columnName : col);
|
|
1923
|
+
migration.addPendingIndex(idx);
|
|
1924
|
+
}
|
|
1925
|
+
for (const fk of detached.sink.pendingForeignKeys) {
|
|
1926
|
+
fk.column = columnName;
|
|
1927
|
+
migration.addForeignKeyOperation(fk);
|
|
1928
|
+
}
|
|
1929
|
+
if (detached.sink.pendingVectorIndexes) for (const vIdx of detached.sink.pendingVectorIndexes) {
|
|
1930
|
+
vIdx.column = columnName;
|
|
1931
|
+
migration.vectorIndex(vIdx.column, vIdx.options);
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
/**
|
|
1936
|
+
* Create a declarative initial-table migration.
|
|
1937
|
+
*
|
|
1938
|
+
* Automatically handles:
|
|
1939
|
+
* - `createTableIfNotExists()`
|
|
1940
|
+
* - Primary key (type resolved from `migrationDefaults.primaryKey` → options → `"int"`)
|
|
1941
|
+
* - `timestamps()`
|
|
1942
|
+
* - `down()` → `dropTableIfExists()`
|
|
1943
|
+
*
|
|
1944
|
+
* The class-based API remains available for complex migrations (raw SQL,
|
|
1945
|
+
* data backfills, conditional logic).
|
|
1946
|
+
*
|
|
1947
|
+
* @param model - Model class to bind (provides table name + data source)
|
|
1948
|
+
* @param columns - Column definitions keyed by column name
|
|
1949
|
+
* @param options - Optional overrides
|
|
1950
|
+
*
|
|
1951
|
+
* @example
|
|
1952
|
+
* ```typescript
|
|
1953
|
+
* import { Migration, uuid, text, timestamp } from "@warlock.js/cascade";
|
|
1954
|
+
* import { Organization } from "app/organizations/models/organization";
|
|
1955
|
+
* import { Chat } from "../chat.model";
|
|
1956
|
+
*
|
|
1957
|
+
* export default Migration.create(Chat, {
|
|
1958
|
+
* organization_id: uuid().references(Organization).onDelete("cascade"),
|
|
1959
|
+
* title: text(),
|
|
1960
|
+
* status: text(),
|
|
1961
|
+
* started_at: timestamp().default("NOW()"),
|
|
1962
|
+
* closed_at: timestamp().nullable(),
|
|
1963
|
+
* }, { order: 5 });
|
|
1964
|
+
* ```
|
|
1965
|
+
*/
|
|
1966
|
+
Migration.create = function createMigration(model, columns, options = {}) {
|
|
1967
|
+
const { order = 0, createdAt, primaryKey: primaryKeyOverride, timestamps: withTimestamps = true, transactional } = options;
|
|
1968
|
+
return class DeclarativeMigration extends Migration {
|
|
1969
|
+
static order = order;
|
|
1970
|
+
static createdAt = createdAt;
|
|
1971
|
+
static transactional = transactional;
|
|
1972
|
+
table = model.table;
|
|
1973
|
+
dataSource = model.dataSource;
|
|
1974
|
+
async up() {
|
|
1975
|
+
this.createTableIfNotExists();
|
|
1976
|
+
const pkType = primaryKeyOverride !== void 0 ? primaryKeyOverride : this._migrationDefaults?.primaryKey ?? "int";
|
|
1977
|
+
if (pkType === "uuid") this.primaryUuid();
|
|
1978
|
+
else if (pkType === "bigInt") this.bigId();
|
|
1979
|
+
else if (pkType === "int") this.id();
|
|
1980
|
+
wireColumns(this, columns);
|
|
1981
|
+
if (withTimestamps) this.timestamps();
|
|
1982
|
+
if (options.index) for (const entry of options.index) this.index(entry.columns, entry.name, {
|
|
1983
|
+
include: entry.include,
|
|
1984
|
+
concurrently: entry.concurrently
|
|
1985
|
+
});
|
|
1986
|
+
if (options.unique) for (const entry of options.unique) this.unique(entry.columns, entry.name, {
|
|
1987
|
+
include: entry.include,
|
|
1988
|
+
concurrently: entry.concurrently
|
|
1989
|
+
});
|
|
1990
|
+
if (options.raw) {
|
|
1991
|
+
const rawQueries = Array.isArray(options.raw) ? options.raw : [options.raw];
|
|
1992
|
+
for (const query of rawQueries) this.raw(query);
|
|
1993
|
+
}
|
|
1994
|
+
if (options.up) await options.up.call(this);
|
|
1995
|
+
}
|
|
1996
|
+
async down() {
|
|
1997
|
+
if (options.down) await options.down.call(this);
|
|
1998
|
+
this.dropTableIfExists();
|
|
1999
|
+
}
|
|
2000
|
+
};
|
|
2001
|
+
};
|
|
2002
|
+
/**
|
|
2003
|
+
* Create a declarative alteration migration.
|
|
2004
|
+
*
|
|
2005
|
+
* @param model - Model class to bind
|
|
2006
|
+
* @param schema - What to add / drop / rename / modify
|
|
2007
|
+
* @param options - Optional overrides
|
|
2008
|
+
*
|
|
2009
|
+
* @example
|
|
2010
|
+
* ```typescript
|
|
2011
|
+
* import { Migration, text } from "@warlock.js/cascade";
|
|
2012
|
+
* import { User } from "../user.model";
|
|
2013
|
+
*
|
|
2014
|
+
* export default Migration.alter(User, {
|
|
2015
|
+
* add: {
|
|
2016
|
+
* phone: text().nullable(),
|
|
2017
|
+
* avatar: text().nullable(),
|
|
2018
|
+
* },
|
|
2019
|
+
* drop: ["legacy_field"],
|
|
2020
|
+
* rename: { old_name: "new_name" },
|
|
2021
|
+
* });
|
|
2022
|
+
* ```
|
|
2023
|
+
*/
|
|
2024
|
+
Migration.alter = function alterMigration(model, schema, options = {}) {
|
|
2025
|
+
const { order = 0, createdAt, transactional } = options;
|
|
2026
|
+
return class AlterMigration extends Migration {
|
|
2027
|
+
static order = order;
|
|
2028
|
+
static createdAt = createdAt;
|
|
2029
|
+
static transactional = transactional;
|
|
2030
|
+
table = model.table;
|
|
2031
|
+
dataSource = model.dataSource;
|
|
2032
|
+
async up() {
|
|
2033
|
+
if (schema.add) wireColumns(this, schema.add);
|
|
2034
|
+
if (schema.drop) for (const col of schema.drop) this.dropColumn(col);
|
|
2035
|
+
if (schema.rename) for (const [from, to] of Object.entries(schema.rename)) this.renameColumn(from, to);
|
|
2036
|
+
if (schema.modify) for (const [columnName, detached] of Object.entries(schema.modify)) {
|
|
2037
|
+
const definition = detached.getDefinition();
|
|
2038
|
+
definition.name = columnName;
|
|
2039
|
+
this.pendingOperations.push({
|
|
2040
|
+
type: "modifyColumn",
|
|
2041
|
+
payload: definition
|
|
2042
|
+
});
|
|
2043
|
+
for (const fk of detached.sink.pendingForeignKeys) {
|
|
2044
|
+
fk.column = columnName;
|
|
2045
|
+
this.addForeignKeyOperation(fk);
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
if (schema.addIndex) for (const { columns, name, options: opts } of schema.addIndex) this.index(columns, name, opts);
|
|
2049
|
+
if (schema.dropIndex) for (const target of schema.dropIndex) this.dropIndex(target);
|
|
2050
|
+
if (schema.addUnique) for (const { columns, name, options: opts } of schema.addUnique) this.unique(columns, name, opts);
|
|
2051
|
+
if (schema.dropUnique) for (const cols of schema.dropUnique) this.dropUnique(cols);
|
|
2052
|
+
if (schema.addExpressionIndex) for (const { expressions, name, options: opts } of schema.addExpressionIndex) this.expressionIndex(expressions, name, opts);
|
|
2053
|
+
if (schema.addFullText) for (const { columns, options: opts } of schema.addFullText) this.fullText(columns, opts);
|
|
2054
|
+
if (schema.dropFullText) for (const name of schema.dropFullText) this.dropFullText(name);
|
|
2055
|
+
if (schema.addGeoIndex) for (const { column, options: opts } of schema.addGeoIndex) this.geoIndex(column, opts);
|
|
2056
|
+
if (schema.dropGeoIndex) for (const column of schema.dropGeoIndex) this.dropGeoIndex(column);
|
|
2057
|
+
if (schema.addVectorIndex) for (const { column, options: opts } of schema.addVectorIndex) this.vectorIndex(column, opts);
|
|
2058
|
+
if (schema.dropVectorIndex) for (const column of schema.dropVectorIndex) this.dropVectorIndex(column);
|
|
2059
|
+
if (schema.addTTLIndex) for (const { column, expireAfterSeconds } of schema.addTTLIndex) this.ttlIndex(column, expireAfterSeconds);
|
|
2060
|
+
if (schema.dropTTLIndex) for (const column of schema.dropTTLIndex) this.dropTTLIndex(column);
|
|
2061
|
+
if (schema.addForeign) for (const fk of schema.addForeign) {
|
|
2062
|
+
const tableName = typeof fk.references === "string" ? fk.references : fk.references.table;
|
|
2063
|
+
this.foreign(fk.column).references(tableName, fk.on ?? "id").onDelete(fk.onDelete ?? "restrict").onUpdate(fk.onUpdate ?? "restrict");
|
|
2064
|
+
}
|
|
2065
|
+
if (schema.dropForeign) for (const { columnOrConstraint, referencesTable } of schema.dropForeign) this.dropForeign(columnOrConstraint, referencesTable);
|
|
2066
|
+
if (schema.addCheck) for (const { name, expression } of schema.addCheck) this.check(name, expression);
|
|
2067
|
+
if (schema.dropCheck) for (const name of schema.dropCheck) this.dropCheck(name);
|
|
2068
|
+
if (schema.raw) {
|
|
2069
|
+
const rawQueries = Array.isArray(schema.raw) ? schema.raw : [schema.raw];
|
|
2070
|
+
for (const query of rawQueries) this.raw(query);
|
|
2071
|
+
}
|
|
2072
|
+
if (options.up) await options.up.call(this);
|
|
2073
|
+
}
|
|
2074
|
+
async down() {
|
|
2075
|
+
if (options.down) await options.down.call(this);
|
|
2076
|
+
}
|
|
2077
|
+
};
|
|
2078
|
+
};
|
|
2079
|
+
Migration.__declarativeFactoriesAttached = true;
|
|
2080
|
+
|
|
2081
|
+
//#endregion
|
|
2082
|
+
export { Migration, migrate };
|
|
2083
|
+
//# sourceMappingURL=migration.mjs.map
|