@warlock.js/cascade 5.29.0 → 5.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +1 -5
- package/cjs/index.cjs +101 -102
- package/cjs/index.cjs.map +1 -1
- package/esm/context/database-data-source-context.d.mts +1 -1
- package/esm/context/database-data-source-context.d.mts.map +1 -1
- package/esm/context/database-data-source-context.mjs +1 -1
- package/esm/context/database-data-source-context.mjs.map +1 -1
- package/esm/context/database-transaction-context.d.mts +1 -1
- package/esm/context/database-transaction-context.d.mts.map +1 -1
- package/esm/context/database-transaction-context.mjs +1 -1
- package/esm/context/database-transaction-context.mjs.map +1 -1
- package/esm/contracts/database-driver.contract.d.mts +1 -1
- package/esm/contracts/database-driver.contract.d.mts.map +1 -1
- package/esm/contracts/database-id-generator.contract.d.mts +1 -1
- package/esm/contracts/database-id-generator.contract.d.mts.map +1 -1
- package/esm/contracts/database-remover.contract.d.mts +1 -1
- package/esm/contracts/database-remover.contract.d.mts.map +1 -1
- package/esm/contracts/database-restorer.contract.d.mts +1 -1
- package/esm/contracts/database-restorer.contract.d.mts.map +1 -1
- package/esm/contracts/database-writer.contract.d.mts +1 -1
- package/esm/contracts/database-writer.contract.d.mts.map +1 -1
- package/esm/contracts/driver-blueprint.contract.d.mts +1 -1
- package/esm/contracts/driver-blueprint.contract.d.mts.map +1 -1
- package/esm/contracts/migration-driver.contract.d.mts +1 -1
- package/esm/contracts/migration-driver.contract.d.mts.map +1 -1
- package/esm/contracts/query-builder.contract.d.mts +1 -1
- package/esm/contracts/query-builder.contract.d.mts.map +1 -1
- package/esm/contracts/sync-adapter.contract.d.mts +1 -1
- package/esm/contracts/sync-adapter.contract.d.mts.map +1 -1
- package/esm/data-source/data-source-registry.d.mts +1 -1
- package/esm/data-source/data-source-registry.d.mts.map +1 -1
- package/esm/data-source/data-source-registry.mjs +1 -1
- package/esm/data-source/data-source-registry.mjs.map +1 -1
- package/esm/data-source/data-source.d.mts +1 -1
- package/esm/data-source/data-source.d.mts.map +1 -1
- package/esm/data-source/data-source.mjs +1 -1
- package/esm/data-source/data-source.mjs.map +1 -1
- package/esm/database-dirty-tracker.d.mts +1 -1
- package/esm/database-dirty-tracker.d.mts.map +1 -1
- package/esm/database-dirty-tracker.mjs +1 -1
- package/esm/database-dirty-tracker.mjs.map +1 -1
- package/esm/drivers/mongodb/mongodb-blueprint.mjs +1 -1
- package/esm/drivers/mongodb/mongodb-blueprint.mjs.map +1 -1
- package/esm/drivers/mongodb/mongodb-driver.d.mts +1 -1
- package/esm/drivers/mongodb/mongodb-driver.d.mts.map +1 -1
- package/esm/drivers/mongodb/mongodb-driver.mjs +1 -1
- package/esm/drivers/mongodb/mongodb-driver.mjs.map +1 -1
- package/esm/drivers/mongodb/mongodb-id-generator.d.mts +1 -1
- package/esm/drivers/mongodb/mongodb-id-generator.d.mts.map +1 -1
- package/esm/drivers/mongodb/mongodb-id-generator.mjs +1 -1
- package/esm/drivers/mongodb/mongodb-id-generator.mjs.map +1 -1
- package/esm/drivers/mongodb/mongodb-migration-driver.d.mts +1 -1
- package/esm/drivers/mongodb/mongodb-migration-driver.d.mts.map +1 -1
- package/esm/drivers/mongodb/mongodb-migration-driver.mjs +1 -1
- package/esm/drivers/mongodb/mongodb-migration-driver.mjs.map +1 -1
- package/esm/drivers/mongodb/mongodb-query-builder.d.mts +1 -1
- package/esm/drivers/mongodb/mongodb-query-builder.d.mts.map +1 -1
- package/esm/drivers/mongodb/mongodb-query-builder.mjs +1 -1
- package/esm/drivers/mongodb/mongodb-query-builder.mjs.map +1 -1
- package/esm/drivers/mongodb/mongodb-query-operations.d.mts +1 -1
- package/esm/drivers/mongodb/mongodb-query-operations.d.mts.map +1 -1
- package/esm/drivers/mongodb/mongodb-query-operations.mjs +1 -1
- package/esm/drivers/mongodb/mongodb-query-operations.mjs.map +1 -1
- package/esm/drivers/mongodb/mongodb-query-parser.d.mts +1 -1
- package/esm/drivers/mongodb/mongodb-query-parser.d.mts.map +1 -1
- package/esm/drivers/mongodb/mongodb-query-parser.mjs +1 -1
- package/esm/drivers/mongodb/mongodb-query-parser.mjs.map +1 -1
- package/esm/drivers/mongodb/mongodb-sync-adapter.d.mts +1 -1
- package/esm/drivers/mongodb/mongodb-sync-adapter.d.mts.map +1 -1
- package/esm/drivers/mongodb/mongodb-sync-adapter.mjs +1 -1
- package/esm/drivers/mongodb/mongodb-sync-adapter.mjs.map +1 -1
- package/esm/drivers/mongodb/mongodb-update-translator.mjs +1 -1
- package/esm/drivers/mongodb/mongodb-update-translator.mjs.map +1 -1
- package/esm/drivers/mongodb/pipeline-stage-object.mjs +1 -1
- package/esm/drivers/mongodb/pipeline-stage-object.mjs.map +1 -1
- package/esm/drivers/mongodb/types.d.mts +1 -1
- package/esm/drivers/mongodb/types.d.mts.map +1 -1
- package/esm/drivers/postgres/naming.mjs +1 -1
- package/esm/drivers/postgres/naming.mjs.map +1 -1
- package/esm/drivers/postgres/postgres-blueprint.d.mts +1 -1
- package/esm/drivers/postgres/postgres-blueprint.d.mts.map +1 -1
- package/esm/drivers/postgres/postgres-blueprint.mjs +1 -1
- package/esm/drivers/postgres/postgres-blueprint.mjs.map +1 -1
- package/esm/drivers/postgres/postgres-dialect.d.mts +1 -1
- package/esm/drivers/postgres/postgres-dialect.d.mts.map +1 -1
- package/esm/drivers/postgres/postgres-dialect.mjs +1 -1
- package/esm/drivers/postgres/postgres-dialect.mjs.map +1 -1
- package/esm/drivers/postgres/postgres-driver.d.mts +1 -1
- package/esm/drivers/postgres/postgres-driver.d.mts.map +1 -1
- package/esm/drivers/postgres/postgres-driver.mjs +1 -1
- package/esm/drivers/postgres/postgres-driver.mjs.map +1 -1
- package/esm/drivers/postgres/postgres-migration-driver.d.mts +1 -1
- package/esm/drivers/postgres/postgres-migration-driver.d.mts.map +1 -1
- package/esm/drivers/postgres/postgres-migration-driver.mjs +1 -1
- package/esm/drivers/postgres/postgres-migration-driver.mjs.map +1 -1
- package/esm/drivers/postgres/postgres-query-builder.d.mts +1 -1
- package/esm/drivers/postgres/postgres-query-builder.d.mts.map +1 -1
- package/esm/drivers/postgres/postgres-query-builder.mjs +1 -1
- package/esm/drivers/postgres/postgres-query-builder.mjs.map +1 -1
- package/esm/drivers/postgres/postgres-query-parser.d.mts +1 -1
- package/esm/drivers/postgres/postgres-query-parser.d.mts.map +1 -1
- package/esm/drivers/postgres/postgres-query-parser.mjs +1 -2
- package/esm/drivers/postgres/postgres-query-parser.mjs.map +1 -1
- package/esm/drivers/postgres/postgres-sql-serializer.mjs +1 -1
- package/esm/drivers/postgres/postgres-sql-serializer.mjs.map +1 -1
- package/esm/drivers/postgres/postgres-ttl-purge.mjs +1 -1
- package/esm/drivers/postgres/postgres-ttl-purge.mjs.map +1 -1
- package/esm/drivers/postgres/postgres-type-converters.mjs +1 -1
- package/esm/drivers/postgres/postgres-type-converters.mjs.map +1 -1
- package/esm/drivers/postgres/postgres-update-validator.mjs +1 -1
- package/esm/drivers/postgres/postgres-update-validator.mjs.map +1 -1
- package/esm/drivers/postgres/types.d.mts +1 -1
- package/esm/drivers/postgres/types.d.mts.map +1 -1
- package/esm/drivers/sql/sql-dialect.contract.d.mts +1 -1
- package/esm/drivers/sql/sql-dialect.contract.d.mts.map +1 -1
- package/esm/drivers/sql/sql-types.d.mts +1 -1
- package/esm/drivers/sql/sql-types.d.mts.map +1 -1
- package/esm/errors/missing-data-source.error.d.mts +1 -1
- package/esm/errors/missing-data-source.error.d.mts.map +1 -1
- package/esm/errors/missing-data-source.error.mjs +1 -1
- package/esm/errors/missing-data-source.error.mjs.map +1 -1
- package/esm/errors/transaction-rollback.error.d.mts +1 -1
- package/esm/errors/transaction-rollback.error.d.mts.map +1 -1
- package/esm/errors/transaction-rollback.error.mjs +1 -1
- package/esm/errors/transaction-rollback.error.mjs.map +1 -1
- package/esm/errors/undefined-where-value.error.d.mts +1 -1
- package/esm/errors/undefined-where-value.error.d.mts.map +1 -1
- package/esm/errors/undefined-where-value.error.mjs +1 -1
- package/esm/errors/undefined-where-value.error.mjs.map +1 -1
- package/esm/errors/unsafe-filter.error.d.mts +1 -1
- package/esm/errors/unsafe-filter.error.d.mts.map +1 -1
- package/esm/errors/unsafe-filter.error.mjs +1 -1
- package/esm/errors/unsafe-filter.error.mjs.map +1 -1
- package/esm/errors/unsafe-raw-expression.error.d.mts +1 -1
- package/esm/errors/unsafe-raw-expression.error.d.mts.map +1 -1
- package/esm/errors/unsafe-raw-expression.error.mjs +1 -1
- package/esm/errors/unsafe-raw-expression.error.mjs.map +1 -1
- package/esm/errors/unsupported-lean-operation.error.d.mts +1 -1
- package/esm/errors/unsupported-lean-operation.error.d.mts.map +1 -1
- package/esm/errors/unsupported-lean-operation.error.mjs +1 -1
- package/esm/errors/unsupported-lean-operation.error.mjs.map +1 -1
- package/esm/errors/unsupported-lock-for-update.error.d.mts +1 -1
- package/esm/errors/unsupported-lock-for-update.error.d.mts.map +1 -1
- package/esm/errors/unsupported-lock-for-update.error.mjs +1 -1
- package/esm/errors/unsupported-lock-for-update.error.mjs.map +1 -1
- package/esm/errors/unsupported-query-operation.error.d.mts +1 -1
- package/esm/errors/unsupported-query-operation.error.d.mts.map +1 -1
- package/esm/errors/unsupported-query-operation.error.mjs +1 -1
- package/esm/errors/unsupported-query-operation.error.mjs.map +1 -1
- package/esm/errors/unsupported-update-operation.error.d.mts +1 -1
- package/esm/errors/unsupported-update-operation.error.d.mts.map +1 -1
- package/esm/errors/unsupported-update-operation.error.mjs +1 -1
- package/esm/errors/unsupported-update-operation.error.mjs.map +1 -1
- package/esm/events/model-events.d.mts +1 -1
- package/esm/events/model-events.d.mts.map +1 -1
- package/esm/events/model-events.mjs +1 -1
- package/esm/events/model-events.mjs.map +1 -1
- package/esm/expressions/aggregate-expressions.d.mts +1 -1
- package/esm/expressions/aggregate-expressions.d.mts.map +1 -1
- package/esm/expressions/aggregate-expressions.mjs +1 -1
- package/esm/expressions/aggregate-expressions.mjs.map +1 -1
- package/esm/expressions/column-expressions.d.mts +1 -1
- package/esm/expressions/column-expressions.d.mts.map +1 -1
- package/esm/expressions/column-expressions.mjs +1 -1
- package/esm/expressions/column-expressions.mjs.map +1 -1
- package/esm/migration/column-builder.d.mts +1 -1
- package/esm/migration/column-builder.d.mts.map +1 -1
- package/esm/migration/column-builder.mjs +1 -1
- package/esm/migration/column-builder.mjs.map +1 -1
- package/esm/migration/column-helpers.d.mts +1 -1
- package/esm/migration/column-helpers.d.mts.map +1 -1
- package/esm/migration/column-helpers.mjs +1 -1
- package/esm/migration/column-helpers.mjs.map +1 -1
- package/esm/migration/foreign-key-builder.d.mts +1 -1
- package/esm/migration/foreign-key-builder.d.mts.map +1 -1
- package/esm/migration/foreign-key-builder.mjs +1 -1
- package/esm/migration/foreign-key-builder.mjs.map +1 -1
- package/esm/migration/migration-order.mjs +1 -1
- package/esm/migration/migration-order.mjs.map +1 -1
- package/esm/migration/migration-runner.d.mts +1 -1
- package/esm/migration/migration-runner.d.mts.map +1 -1
- package/esm/migration/migration-runner.mjs +1 -1
- package/esm/migration/migration-runner.mjs.map +1 -1
- package/esm/migration/migration.d.mts +1 -1
- package/esm/migration/migration.d.mts.map +1 -1
- package/esm/migration/migration.mjs +1 -1
- package/esm/migration/migration.mjs.map +1 -1
- package/esm/migration/parse-created-at.mjs +1 -1
- package/esm/migration/parse-created-at.mjs.map +1 -1
- package/esm/migration/sql-grammar.mjs +1 -1
- package/esm/migration/sql-grammar.mjs.map +1 -1
- package/esm/migration/sql-serializer.d.mts +1 -1
- package/esm/migration/sql-serializer.d.mts.map +1 -1
- package/esm/migration/sql-serializer.mjs +1 -1
- package/esm/migration/sql-serializer.mjs.map +1 -1
- package/esm/migration/types.d.mts +1 -1
- package/esm/migration/types.d.mts.map +1 -1
- package/esm/model/generate-model-id.mjs +1 -1
- package/esm/model/generate-model-id.mjs.map +1 -1
- package/esm/model/methods/accessor-methods.mjs +1 -1
- package/esm/model/methods/accessor-methods.mjs.map +1 -1
- package/esm/model/methods/delete-methods.mjs +1 -1
- package/esm/model/methods/delete-methods.mjs.map +1 -1
- package/esm/model/methods/dirty-methods.mjs +1 -1
- package/esm/model/methods/dirty-methods.mjs.map +1 -1
- package/esm/model/methods/hydration-methods.mjs +1 -1
- package/esm/model/methods/hydration-methods.mjs.map +1 -1
- package/esm/model/methods/instance-event-methods.mjs +1 -1
- package/esm/model/methods/instance-event-methods.mjs.map +1 -1
- package/esm/model/methods/meta-methods.mjs +1 -1
- package/esm/model/methods/meta-methods.mjs.map +1 -1
- package/esm/model/methods/pivot-methods.mjs +1 -1
- package/esm/model/methods/pivot-methods.mjs.map +1 -1
- package/esm/model/methods/query-methods.mjs +1 -1
- package/esm/model/methods/query-methods.mjs.map +1 -1
- package/esm/model/methods/restore-methods.mjs +1 -1
- package/esm/model/methods/restore-methods.mjs.map +1 -1
- package/esm/model/methods/scope-methods.mjs +1 -1
- package/esm/model/methods/scope-methods.mjs.map +1 -1
- package/esm/model/methods/serialization-methods.mjs +1 -1
- package/esm/model/methods/serialization-methods.mjs.map +1 -1
- package/esm/model/methods/static-event-methods.mjs +1 -1
- package/esm/model/methods/static-event-methods.mjs.map +1 -1
- package/esm/model/methods/write-methods.d.mts +1 -1
- package/esm/model/methods/write-methods.d.mts.map +1 -1
- package/esm/model/methods/write-methods.mjs +1 -1
- package/esm/model/methods/write-methods.mjs.map +1 -1
- package/esm/model/model.d.mts +1 -1
- package/esm/model/model.d.mts.map +1 -1
- package/esm/model/model.mjs +1 -1
- package/esm/model/model.mjs.map +1 -1
- package/esm/model/model.types.d.mts +1 -1
- package/esm/model/model.types.d.mts.map +1 -1
- package/esm/model/register-model.d.mts +1 -1
- package/esm/model/register-model.d.mts.map +1 -1
- package/esm/model/register-model.mjs +1 -1
- package/esm/model/register-model.mjs.map +1 -1
- package/esm/model/relation-decorators.d.mts +1 -1
- package/esm/model/relation-decorators.d.mts.map +1 -1
- package/esm/model/relation-decorators.mjs +1 -1
- package/esm/model/relation-decorators.mjs.map +1 -1
- package/esm/operations/database.d.mts +1 -1
- package/esm/operations/database.d.mts.map +1 -1
- package/esm/operations/database.mjs +1 -1
- package/esm/operations/database.mjs.map +1 -1
- package/esm/operations/migrations.d.mts +1 -1
- package/esm/operations/migrations.d.mts.map +1 -1
- package/esm/operations/migrations.mjs +1 -1
- package/esm/operations/migrations.mjs.map +1 -1
- package/esm/query-builder/lean-records.mjs +1 -1
- package/esm/query-builder/lean-records.mjs.map +1 -1
- package/esm/query-builder/query-builder.d.mts +1 -1
- package/esm/query-builder/query-builder.d.mts.map +1 -1
- package/esm/query-builder/query-builder.mjs +1 -1
- package/esm/query-builder/query-builder.mjs.map +1 -1
- package/esm/relations/key-conventions.mjs +1 -1
- package/esm/relations/key-conventions.mjs.map +1 -1
- package/esm/relations/pivot-operations.d.mts +1 -1
- package/esm/relations/pivot-operations.d.mts.map +1 -1
- package/esm/relations/pivot-operations.mjs +1 -1
- package/esm/relations/pivot-operations.mjs.map +1 -1
- package/esm/relations/relation-hydrator.d.mts +1 -1
- package/esm/relations/relation-hydrator.d.mts.map +1 -1
- package/esm/relations/relation-hydrator.mjs +1 -1
- package/esm/relations/relation-hydrator.mjs.map +1 -1
- package/esm/relations/relation-loader.d.mts +1 -1
- package/esm/relations/relation-loader.d.mts.map +1 -1
- package/esm/relations/relation-loader.mjs +1 -1
- package/esm/relations/relation-loader.mjs.map +1 -1
- package/esm/relations/types.d.mts +1 -1
- package/esm/relations/types.d.mts.map +1 -1
- package/esm/remover/database-remover.d.mts +1 -1
- package/esm/remover/database-remover.d.mts.map +1 -1
- package/esm/remover/database-remover.mjs +1 -1
- package/esm/remover/database-remover.mjs.map +1 -1
- package/esm/restorer/database-restorer.d.mts +1 -1
- package/esm/restorer/database-restorer.d.mts.map +1 -1
- package/esm/restorer/database-restorer.mjs +1 -1
- package/esm/restorer/database-restorer.mjs.map +1 -1
- package/esm/sql-database-dirty-tracker.d.mts +1 -1
- package/esm/sql-database-dirty-tracker.d.mts.map +1 -1
- package/esm/sql-database-dirty-tracker.mjs +1 -1
- package/esm/sql-database-dirty-tracker.mjs.map +1 -1
- package/esm/sync/model-events.mjs +1 -1
- package/esm/sync/model-events.mjs.map +1 -1
- package/esm/sync/model-sync-operation.d.mts +1 -1
- package/esm/sync/model-sync-operation.d.mts.map +1 -1
- package/esm/sync/model-sync-operation.mjs +1 -1
- package/esm/sync/model-sync-operation.mjs.map +1 -1
- package/esm/sync/model-sync.d.mts +1 -1
- package/esm/sync/model-sync.d.mts.map +1 -1
- package/esm/sync/model-sync.mjs +1 -1
- package/esm/sync/model-sync.mjs.map +1 -1
- package/esm/sync/sync-context.d.mts +1 -1
- package/esm/sync/sync-context.d.mts.map +1 -1
- package/esm/sync/sync-context.mjs +1 -1
- package/esm/sync/sync-context.mjs.map +1 -1
- package/esm/sync/sync-fanout.mjs +1 -1
- package/esm/sync/sync-fanout.mjs.map +1 -1
- package/esm/sync/sync-manager.d.mts +1 -1
- package/esm/sync/sync-manager.d.mts.map +1 -1
- package/esm/sync/sync-manager.mjs +1 -1
- package/esm/sync/sync-manager.mjs.map +1 -1
- package/esm/sync/types.d.mts +1 -1
- package/esm/sync/types.d.mts.map +1 -1
- package/esm/transactions/after-commit.d.mts +1 -1
- package/esm/transactions/after-commit.d.mts.map +1 -1
- package/esm/transactions/after-commit.mjs +1 -1
- package/esm/transactions/after-commit.mjs.map +1 -1
- package/esm/types.d.mts +1 -1
- package/esm/types.d.mts.map +1 -1
- package/esm/utils/connect-to-database.d.mts +1 -1
- package/esm/utils/connect-to-database.d.mts.map +1 -1
- package/esm/utils/connect-to-database.mjs +1 -1
- package/esm/utils/connect-to-database.mjs.map +1 -1
- package/esm/utils/database-writer.utils.d.mts +1 -1
- package/esm/utils/database-writer.utils.d.mts.map +1 -1
- package/esm/utils/database-writer.utils.mjs +1 -1
- package/esm/utils/database-writer.utils.mjs.map +1 -1
- package/esm/utils/define-model.d.mts +1 -1
- package/esm/utils/define-model.d.mts.map +1 -1
- package/esm/utils/define-model.mjs +1 -1
- package/esm/utils/define-model.mjs.map +1 -1
- package/esm/utils/escape-regex.d.mts +1 -1
- package/esm/utils/escape-regex.d.mts.map +1 -1
- package/esm/utils/escape-regex.mjs +1 -1
- package/esm/utils/escape-regex.mjs.map +1 -1
- package/esm/utils/is-valid-date-value.mjs +1 -1
- package/esm/utils/is-valid-date-value.mjs.map +1 -1
- package/esm/utils/once-connected.d.mts +1 -1
- package/esm/utils/once-connected.d.mts.map +1 -1
- package/esm/utils/once-connected.mjs +1 -1
- package/esm/utils/once-connected.mjs.map +1 -1
- package/esm/utils/prune-empty-parents.mjs +1 -1
- package/esm/utils/prune-empty-parents.mjs.map +1 -1
- package/esm/utils/sanitize-filter.d.mts +1 -1
- package/esm/utils/sanitize-filter.d.mts.map +1 -1
- package/esm/utils/sanitize-filter.mjs +1 -1
- package/esm/utils/sanitize-filter.mjs.map +1 -1
- package/esm/validation/database-seal-plugins.mjs +1 -1
- package/esm/validation/database-seal-plugins.mjs.map +1 -1
- package/esm/validation/database-writer-validation-error.d.mts +1 -1
- package/esm/validation/database-writer-validation-error.d.mts.map +1 -1
- package/esm/validation/database-writer-validation-error.mjs +1 -1
- package/esm/validation/database-writer-validation-error.mjs.map +1 -1
- package/esm/validation/mutators/embed-mutator.mjs +1 -1
- package/esm/validation/mutators/embed-mutator.mjs.map +1 -1
- package/esm/validation/plugins/database-rules-plugin.d.mts +1 -1
- package/esm/validation/plugins/database-rules-plugin.d.mts.map +1 -1
- package/esm/validation/plugins/database-rules-plugin.mjs +1 -1
- package/esm/validation/plugins/database-rules-plugin.mjs.map +1 -1
- package/esm/validation/plugins/embed-validator-plugin.d.mts +1 -1
- package/esm/validation/plugins/embed-validator-plugin.d.mts.map +1 -1
- package/esm/validation/plugins/embed-validator-plugin.mjs +1 -1
- package/esm/validation/plugins/embed-validator-plugin.mjs.map +1 -1
- package/esm/validation/rules/database-model-rule.mjs +1 -1
- package/esm/validation/rules/database-model-rule.mjs.map +1 -1
- package/esm/validation/rules/exists-rule.mjs +1 -1
- package/esm/validation/rules/exists-rule.mjs.map +1 -1
- package/esm/validation/rules/unique-rule.mjs +1 -1
- package/esm/validation/rules/unique-rule.mjs.map +1 -1
- package/esm/validation/transformers/embed-model-transformer.mjs +1 -1
- package/esm/validation/transformers/embed-model-transformer.mjs.map +1 -1
- package/esm/validation/types.d.mts +1 -1
- package/esm/validation/types.d.mts.map +1 -1
- package/esm/validation/validators/embed-validator.d.mts +1 -1
- package/esm/validation/validators/embed-validator.d.mts.map +1 -1
- package/esm/validation/validators/embed-validator.mjs +1 -1
- package/esm/validation/validators/embed-validator.mjs.map +1 -1
- package/esm/writer/database-writer.d.mts +1 -1
- package/esm/writer/database-writer.d.mts.map +1 -1
- package/esm/writer/database-writer.mjs +1 -1
- package/esm/writer/database-writer.mjs.map +1 -1
- package/llms-full.txt +541 -434
- package/package.json +7 -6
- package/skills/aggregate-data/SKILL.md +28 -17
- package/skills/alter-migration/SKILL.md +325 -233
- package/skills/cascade-basics/SKILL.md +19 -19
- package/skills/configure-delete-strategy/SKILL.md +11 -11
- package/skills/define-model/SKILL.md +19 -17
- package/skills/define-relations/SKILL.md +13 -18
- package/skills/index.md +3 -0
- package/skills/manage-transactions/SKILL.md +18 -12
- package/skills/paginate-results/SKILL.md +6 -8
- package/skills/perform-atomic-ops/SKILL.md +26 -21
- package/skills/query-data/SKILL.md +27 -33
- package/skills/run-cascade-cli/SKILL.md +11 -10
- package/skills/search-by-vector/SKILL.md +8 -5
- package/skills/subscribe-to-model-events/SKILL.md +17 -17
- package/skills/track-changes/SKILL.md +9 -9
- package/skills/write-migration/SKILL.md +4 -4
|
@@ -17,15 +17,19 @@ Use `Migration.alter` to evolve an existing table — adding or dropping columns
|
|
|
17
17
|
import { Migration, text } from "@warlock.js/cascade";
|
|
18
18
|
import { User } from "../user.model";
|
|
19
19
|
|
|
20
|
-
export default Migration.alter(
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
export default Migration.alter(
|
|
21
|
+
User,
|
|
22
|
+
{
|
|
23
|
+
add: {
|
|
24
|
+
phone: text().nullable(),
|
|
25
|
+
},
|
|
23
26
|
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
{
|
|
28
|
+
down() {
|
|
29
|
+
this.dropColumn("phone");
|
|
30
|
+
},
|
|
27
31
|
},
|
|
28
|
-
|
|
32
|
+
);
|
|
29
33
|
```
|
|
30
34
|
|
|
31
35
|
---
|
|
@@ -55,21 +59,25 @@ import { Migration, text, integer, bool, uuid } from "@warlock.js/cascade";
|
|
|
55
59
|
import { Organization } from "app/organizations/models/organization";
|
|
56
60
|
import { User } from "../user.model";
|
|
57
61
|
|
|
58
|
-
export default Migration.alter(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
export default Migration.alter(
|
|
63
|
+
User,
|
|
64
|
+
{
|
|
65
|
+
add: {
|
|
66
|
+
phone: text().nullable(),
|
|
67
|
+
login_attempts: integer().notNullable().default(0),
|
|
68
|
+
is_verified: bool().notNullable().default(false),
|
|
69
|
+
organization_id: uuid().references(Organization.table).onDelete("cascade").notNullable(),
|
|
70
|
+
},
|
|
64
71
|
},
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
{
|
|
73
|
+
down() {
|
|
74
|
+
this.dropColumn("phone");
|
|
75
|
+
this.dropColumn("login_attempts");
|
|
76
|
+
this.dropColumn("is_verified");
|
|
77
|
+
this.dropColumn("organization_id");
|
|
78
|
+
},
|
|
71
79
|
},
|
|
72
|
-
|
|
80
|
+
);
|
|
73
81
|
```
|
|
74
82
|
|
|
75
83
|
Column helpers (`text`, `integer`, `bool`, `uuid`, `double`, `json`, `timestamp`, `date`, …) are imported from `@warlock.js/cascade` and support the same modifier chain as in `Migration.create`.
|
|
@@ -77,31 +85,39 @@ Column helpers (`text`, `integer`, `bool`, `uuid`, `double`, `json`, `timestamp`
|
|
|
77
85
|
### `drop` — remove columns
|
|
78
86
|
|
|
79
87
|
```ts
|
|
80
|
-
export default Migration.alter(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
// re-add with the original definition if rollback is meaningful
|
|
85
|
-
this.text("legacy_token").nullable();
|
|
86
|
-
this.text("old_avatar_url").nullable();
|
|
88
|
+
export default Migration.alter(
|
|
89
|
+
User,
|
|
90
|
+
{
|
|
91
|
+
drop: ["legacy_token", "old_avatar_url"],
|
|
87
92
|
},
|
|
88
|
-
|
|
93
|
+
{
|
|
94
|
+
down() {
|
|
95
|
+
// re-add with the original definition if rollback is meaningful
|
|
96
|
+
this.text("legacy_token").nullable();
|
|
97
|
+
this.text("old_avatar_url").nullable();
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
);
|
|
89
101
|
```
|
|
90
102
|
|
|
91
103
|
### `rename` — rename columns
|
|
92
104
|
|
|
93
105
|
```ts
|
|
94
|
-
export default Migration.alter(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
106
|
+
export default Migration.alter(
|
|
107
|
+
Post,
|
|
108
|
+
{
|
|
109
|
+
rename: {
|
|
110
|
+
body: "content",
|
|
111
|
+
thumb_url: "thumbnail_url",
|
|
112
|
+
},
|
|
98
113
|
},
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
114
|
+
{
|
|
115
|
+
down() {
|
|
116
|
+
this.renameColumn("content", "body");
|
|
117
|
+
this.renameColumn("thumbnail_url", "thumb_url");
|
|
118
|
+
},
|
|
103
119
|
},
|
|
104
|
-
|
|
120
|
+
);
|
|
105
121
|
```
|
|
106
122
|
|
|
107
123
|
### `modify` — change column type or nullability
|
|
@@ -110,17 +126,21 @@ export default Migration.alter(Post, {
|
|
|
110
126
|
import { Migration, string } from "@warlock.js/cascade";
|
|
111
127
|
import { User } from "../user.model";
|
|
112
128
|
|
|
113
|
-
export default Migration.alter(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
129
|
+
export default Migration.alter(
|
|
130
|
+
User,
|
|
131
|
+
{
|
|
132
|
+
modify: {
|
|
133
|
+
// widen email from text to varchar(320) and keep not-null
|
|
134
|
+
email: string(320).notNullable(),
|
|
135
|
+
},
|
|
117
136
|
},
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
137
|
+
{
|
|
138
|
+
down() {
|
|
139
|
+
// revert to unbounded text
|
|
140
|
+
this.text("email").notNullable();
|
|
141
|
+
},
|
|
122
142
|
},
|
|
123
|
-
|
|
143
|
+
);
|
|
124
144
|
```
|
|
125
145
|
|
|
126
146
|
> `modify` re-declares the column. Include every modifier you want to keep (`.notNullable()`, `.default(…)`, etc.) — the declaration replaces the old one entirely.
|
|
@@ -132,29 +152,37 @@ export default Migration.alter(User, {
|
|
|
132
152
|
### Regular indexes — `addIndex` / `dropIndex`
|
|
133
153
|
|
|
134
154
|
```ts
|
|
135
|
-
export default Migration.alter(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
this.dropIndex("status");
|
|
155
|
+
export default Migration.alter(
|
|
156
|
+
Order,
|
|
157
|
+
{
|
|
158
|
+
// single column
|
|
159
|
+
addIndex: [{ columns: "status" }],
|
|
141
160
|
},
|
|
142
|
-
|
|
161
|
+
{
|
|
162
|
+
down() {
|
|
163
|
+
this.dropIndex("status");
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
);
|
|
143
167
|
```
|
|
144
168
|
|
|
145
169
|
```ts
|
|
146
170
|
// composite index with an explicit name
|
|
147
|
-
export default Migration.alter(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
},
|
|
153
|
-
|
|
154
|
-
this.dropIndex("idx_org_status");
|
|
155
|
-
this.dropIndex("created_at");
|
|
171
|
+
export default Migration.alter(
|
|
172
|
+
Order,
|
|
173
|
+
{
|
|
174
|
+
addIndex: [
|
|
175
|
+
{ columns: ["organization_id", "status"], name: "idx_org_status" },
|
|
176
|
+
{ columns: "created_at" },
|
|
177
|
+
],
|
|
156
178
|
},
|
|
157
|
-
|
|
179
|
+
{
|
|
180
|
+
down() {
|
|
181
|
+
this.dropIndex("idx_org_status");
|
|
182
|
+
this.dropIndex("created_at");
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
);
|
|
158
186
|
```
|
|
159
187
|
|
|
160
188
|
`dropIndex` accepts a name string or a columns array:
|
|
@@ -168,63 +196,79 @@ export default Migration.alter(Order, {
|
|
|
168
196
|
`options.concurrently: true` builds the index without locking the table (Postgres):
|
|
169
197
|
|
|
170
198
|
```ts
|
|
171
|
-
addIndex: [{ columns: "email", options: { concurrently: true } }]
|
|
199
|
+
addIndex: [{ columns: "email", options: { concurrently: true } }];
|
|
172
200
|
```
|
|
173
201
|
|
|
174
202
|
### Unique constraints — `addUnique` / `dropUnique`
|
|
175
203
|
|
|
176
204
|
```ts
|
|
177
205
|
// promote an indexed column to unique
|
|
178
|
-
export default Migration.alter(
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
this.dropUnique("email");
|
|
206
|
+
export default Migration.alter(
|
|
207
|
+
User,
|
|
208
|
+
{
|
|
209
|
+
addUnique: [{ columns: "email" }],
|
|
183
210
|
},
|
|
184
|
-
|
|
211
|
+
{
|
|
212
|
+
down() {
|
|
213
|
+
this.dropUnique("email");
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
);
|
|
185
217
|
```
|
|
186
218
|
|
|
187
219
|
Composite unique constraint:
|
|
188
220
|
|
|
189
221
|
```ts
|
|
190
|
-
export default Migration.alter(
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
this.dropUnique(["organization_id", "user_id"]);
|
|
222
|
+
export default Migration.alter(
|
|
223
|
+
Membership,
|
|
224
|
+
{
|
|
225
|
+
addUnique: [{ columns: ["organization_id", "user_id"], name: "uq_org_member" }],
|
|
195
226
|
},
|
|
196
|
-
|
|
227
|
+
{
|
|
228
|
+
down() {
|
|
229
|
+
this.dropUnique(["organization_id", "user_id"]);
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
);
|
|
197
233
|
```
|
|
198
234
|
|
|
199
235
|
Downgrade a unique to a plain index (the pattern used in this session):
|
|
200
236
|
|
|
201
237
|
```ts
|
|
202
|
-
export default Migration.alter(
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
this.dropIndex("users_email_index");
|
|
208
|
-
this.unique("email");
|
|
238
|
+
export default Migration.alter(
|
|
239
|
+
User,
|
|
240
|
+
{
|
|
241
|
+
dropUnique: [["email"]],
|
|
242
|
+
addIndex: [{ columns: "email", name: "users_email_index" }],
|
|
209
243
|
},
|
|
210
|
-
|
|
244
|
+
{
|
|
245
|
+
down() {
|
|
246
|
+
this.dropIndex("users_email_index");
|
|
247
|
+
this.unique("email");
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
);
|
|
211
251
|
```
|
|
212
252
|
|
|
213
253
|
### Expression indexes — `addExpressionIndex` (Postgres)
|
|
214
254
|
|
|
215
255
|
```ts
|
|
216
|
-
export default Migration.alter(
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
},
|
|
223
|
-
|
|
224
|
-
this.dropIndex("idx_email_ci");
|
|
225
|
-
this.dropIndex("idx_name_ci");
|
|
256
|
+
export default Migration.alter(
|
|
257
|
+
User,
|
|
258
|
+
{
|
|
259
|
+
addExpressionIndex: [
|
|
260
|
+
{ expressions: "lower(email)", name: "idx_email_ci" },
|
|
261
|
+
{ expressions: "lower(name)", name: "idx_name_ci" },
|
|
262
|
+
{ expressions: ["year(created_at)", "status"] },
|
|
263
|
+
],
|
|
226
264
|
},
|
|
227
|
-
|
|
265
|
+
{
|
|
266
|
+
down() {
|
|
267
|
+
this.dropIndex("idx_email_ci");
|
|
268
|
+
this.dropIndex("idx_name_ci");
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
);
|
|
228
272
|
```
|
|
229
273
|
|
|
230
274
|
---
|
|
@@ -234,30 +278,38 @@ export default Migration.alter(User, {
|
|
|
234
278
|
### Full-text — `addFullText` / `dropFullText`
|
|
235
279
|
|
|
236
280
|
```ts
|
|
237
|
-
export default Migration.alter(
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
281
|
+
export default Migration.alter(
|
|
282
|
+
Article,
|
|
283
|
+
{
|
|
284
|
+
addFullText: [
|
|
285
|
+
{
|
|
286
|
+
columns: ["title", "body"],
|
|
287
|
+
options: { name: "ft_article_search", language: "english" },
|
|
288
|
+
},
|
|
289
|
+
],
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
down() {
|
|
293
|
+
this.dropFullText("ft_article_search");
|
|
242
294
|
},
|
|
243
|
-
],
|
|
244
|
-
}, {
|
|
245
|
-
down() {
|
|
246
|
-
this.dropFullText("ft_article_search");
|
|
247
295
|
},
|
|
248
|
-
|
|
296
|
+
);
|
|
249
297
|
```
|
|
250
298
|
|
|
251
299
|
### Geo-spatial — `addGeoIndex` / `dropGeoIndex`
|
|
252
300
|
|
|
253
301
|
```ts
|
|
254
|
-
export default Migration.alter(
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
this.dropGeoIndex("location");
|
|
302
|
+
export default Migration.alter(
|
|
303
|
+
Store,
|
|
304
|
+
{
|
|
305
|
+
addGeoIndex: [{ column: "location" }],
|
|
259
306
|
},
|
|
260
|
-
|
|
307
|
+
{
|
|
308
|
+
down() {
|
|
309
|
+
this.dropGeoIndex("location");
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
);
|
|
261
313
|
```
|
|
262
314
|
|
|
263
315
|
Options: `{ name?, type?: "2dsphere" | "2d", min?, max? }`
|
|
@@ -265,16 +317,22 @@ Options: `{ name?, type?: "2dsphere" | "2d", min?, max? }`
|
|
|
265
317
|
### Vector (AI embeddings) — `addVectorIndex` / `dropVectorIndex`
|
|
266
318
|
|
|
267
319
|
```ts
|
|
268
|
-
export default Migration.alter(
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
320
|
+
export default Migration.alter(
|
|
321
|
+
Document,
|
|
322
|
+
{
|
|
323
|
+
addVectorIndex: [
|
|
324
|
+
{
|
|
325
|
+
column: "embedding",
|
|
326
|
+
options: { dimensions: 1536, similarity: "cosine", name: "idx_doc_embedding" },
|
|
327
|
+
},
|
|
328
|
+
],
|
|
276
329
|
},
|
|
277
|
-
|
|
330
|
+
{
|
|
331
|
+
down() {
|
|
332
|
+
this.dropVectorIndex("embedding");
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
);
|
|
278
336
|
```
|
|
279
337
|
|
|
280
338
|
Similarity options: `"cosine"` | `"euclidean"` | `"dotProduct"`.
|
|
@@ -284,13 +342,17 @@ Similarity options: `"cosine"` | `"euclidean"` | `"dotProduct"`.
|
|
|
284
342
|
Expires documents automatically after a fixed duration:
|
|
285
343
|
|
|
286
344
|
```ts
|
|
287
|
-
export default Migration.alter(
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
this.dropTTLIndex("created_at");
|
|
345
|
+
export default Migration.alter(
|
|
346
|
+
Session,
|
|
347
|
+
{
|
|
348
|
+
addTTLIndex: [{ column: "created_at", expireAfterSeconds: 86400 }], // 24 h
|
|
292
349
|
},
|
|
293
|
-
|
|
350
|
+
{
|
|
351
|
+
down() {
|
|
352
|
+
this.dropTTLIndex("created_at");
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
);
|
|
294
356
|
```
|
|
295
357
|
|
|
296
358
|
---
|
|
@@ -306,17 +368,21 @@ import { Migration } from "@warlock.js/cascade";
|
|
|
306
368
|
import { Team } from "app/teams/models/team";
|
|
307
369
|
import { User } from "../user.model";
|
|
308
370
|
|
|
309
|
-
export default Migration.alter(
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
},
|
|
315
|
-
|
|
316
|
-
this.dropForeign("team_id", Team.table);
|
|
317
|
-
this.dropForeign("owner_id", "users");
|
|
371
|
+
export default Migration.alter(
|
|
372
|
+
User,
|
|
373
|
+
{
|
|
374
|
+
addForeign: [
|
|
375
|
+
{ column: "team_id", references: Team, onDelete: "cascade" },
|
|
376
|
+
{ column: "owner_id", references: "users", on: "id", onDelete: "setNull" },
|
|
377
|
+
],
|
|
318
378
|
},
|
|
319
|
-
|
|
379
|
+
{
|
|
380
|
+
down() {
|
|
381
|
+
this.dropForeign("team_id", Team.table);
|
|
382
|
+
this.dropForeign("owner_id", "users");
|
|
383
|
+
},
|
|
384
|
+
},
|
|
385
|
+
);
|
|
320
386
|
```
|
|
321
387
|
|
|
322
388
|
`onDelete` / `onUpdate` values: `"cascade"` | `"restrict"` | `"setNull"` | `"noAction"`. Both default to `"restrict"` when omitted.
|
|
@@ -324,23 +390,27 @@ export default Migration.alter(User, {
|
|
|
324
390
|
Drop by constraint name when you named it manually:
|
|
325
391
|
|
|
326
392
|
```ts
|
|
327
|
-
dropForeign: [{ columnOrConstraint: "fk_my_custom_name" }]
|
|
393
|
+
dropForeign: [{ columnOrConstraint: "fk_my_custom_name" }];
|
|
328
394
|
```
|
|
329
395
|
|
|
330
396
|
### CHECK constraints — `addCheck` / `dropCheck`
|
|
331
397
|
|
|
332
398
|
```ts
|
|
333
|
-
export default Migration.alter(
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
},
|
|
339
|
-
|
|
340
|
-
this.dropCheck("price_positive");
|
|
341
|
-
this.dropCheck("stock_non_negative");
|
|
399
|
+
export default Migration.alter(
|
|
400
|
+
Product,
|
|
401
|
+
{
|
|
402
|
+
addCheck: [
|
|
403
|
+
{ name: "price_positive", expression: "price_cents >= 0" },
|
|
404
|
+
{ name: "stock_non_negative", expression: "stock >= 0" },
|
|
405
|
+
],
|
|
342
406
|
},
|
|
343
|
-
|
|
407
|
+
{
|
|
408
|
+
down() {
|
|
409
|
+
this.dropCheck("price_positive");
|
|
410
|
+
this.dropCheck("stock_non_negative");
|
|
411
|
+
},
|
|
412
|
+
},
|
|
413
|
+
);
|
|
344
414
|
```
|
|
345
415
|
|
|
346
416
|
---
|
|
@@ -350,16 +420,20 @@ export default Migration.alter(Product, {
|
|
|
350
420
|
Use `raw` when you need a one-off SQL statement alongside declarative changes (e.g. backfilling a new column in the same migration when the table is small):
|
|
351
421
|
|
|
352
422
|
```ts
|
|
353
|
-
export default Migration.alter(
|
|
354
|
-
|
|
355
|
-
|
|
423
|
+
export default Migration.alter(
|
|
424
|
+
User,
|
|
425
|
+
{
|
|
426
|
+
add: {
|
|
427
|
+
full_name: text().nullable(),
|
|
428
|
+
},
|
|
429
|
+
raw: `UPDATE users SET full_name = first_name || ' ' || last_name`,
|
|
356
430
|
},
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
431
|
+
{
|
|
432
|
+
down() {
|
|
433
|
+
this.dropColumn("full_name");
|
|
434
|
+
},
|
|
361
435
|
},
|
|
362
|
-
|
|
436
|
+
);
|
|
363
437
|
```
|
|
364
438
|
|
|
365
439
|
Pass an array for multiple statements:
|
|
@@ -368,7 +442,7 @@ Pass an array for multiple statements:
|
|
|
368
442
|
raw: [
|
|
369
443
|
`UPDATE users SET status = 'active' WHERE status IS NULL`,
|
|
370
444
|
`UPDATE users SET role = 'member' WHERE role IS NULL`,
|
|
371
|
-
]
|
|
445
|
+
];
|
|
372
446
|
```
|
|
373
447
|
|
|
374
448
|
---
|
|
@@ -377,24 +451,24 @@ raw: [
|
|
|
377
451
|
|
|
378
452
|
`Migration.alter` **never** auto-infers rollback. Supply `down()` in options whenever you want `cascade migrate:rollback` to work. Inside `down()`, `this` is a full `Migration` instance — every class-form builder is available:
|
|
379
453
|
|
|
380
|
-
| Operation
|
|
381
|
-
|
|
382
|
-
| Drop an added column
|
|
383
|
-
| Re-add a dropped column
|
|
384
|
-
| Undo a rename
|
|
385
|
-
| Undo a column modify
|
|
386
|
-
| Drop a plain index (by name)
|
|
387
|
-
| Drop a plain index (by columns) | `this.dropIndex(["col_a", "col_b"])`
|
|
388
|
-
| Drop a unique constraint
|
|
389
|
-
| Add a unique constraint back
|
|
390
|
-
| Add a plain index back
|
|
391
|
-
| Drop a foreign key
|
|
392
|
-
| Drop a CHECK constraint
|
|
393
|
-
| Drop full-text index
|
|
394
|
-
| Drop geo index
|
|
395
|
-
| Drop vector index
|
|
396
|
-
| Drop TTL index
|
|
397
|
-
| Raw SQL
|
|
454
|
+
| Operation | Class-form call in `down()` |
|
|
455
|
+
| ------------------------------- | ----------------------------------------------------------- |
|
|
456
|
+
| Drop an added column | `this.dropColumn("name")` |
|
|
457
|
+
| Re-add a dropped column | `this.text("name").nullable()` |
|
|
458
|
+
| Undo a rename | `this.renameColumn("new", "old")` |
|
|
459
|
+
| Undo a column modify | `this.text("col").notNullable()` |
|
|
460
|
+
| Drop a plain index (by name) | `this.dropIndex("idx_name")` |
|
|
461
|
+
| Drop a plain index (by columns) | `this.dropIndex(["col_a", "col_b"])` |
|
|
462
|
+
| Drop a unique constraint | `this.dropUnique("email")` or `this.dropUnique(["a", "b"])` |
|
|
463
|
+
| Add a unique constraint back | `this.unique("email")` |
|
|
464
|
+
| Add a plain index back | `this.index("email", "idx_name")` |
|
|
465
|
+
| Drop a foreign key | `this.dropForeign("col", "ref_table")` |
|
|
466
|
+
| Drop a CHECK constraint | `this.dropCheck("constraint_name")` |
|
|
467
|
+
| Drop full-text index | `this.dropFullText("ft_name")` |
|
|
468
|
+
| Drop geo index | `this.dropGeoIndex("column")` |
|
|
469
|
+
| Drop vector index | `this.dropVectorIndex("column")` |
|
|
470
|
+
| Drop TTL index | `this.dropTTLIndex("column")` |
|
|
471
|
+
| Raw SQL | `this.raw("SQL statement")` |
|
|
398
472
|
|
|
399
473
|
If a migration is genuinely irreversible, throw inside `down()` so accidental rollbacks fail loudly:
|
|
400
474
|
|
|
@@ -410,28 +484,32 @@ If a migration is genuinely irreversible, throw inside `down()` so accidental ro
|
|
|
410
484
|
|
|
411
485
|
## Options (`MigrationAlterOptions`)
|
|
412
486
|
|
|
413
|
-
| Key
|
|
414
|
-
|
|
415
|
-
| `down`
|
|
416
|
-
| `up`
|
|
417
|
-
| `order`
|
|
418
|
-
| `createdAt`
|
|
419
|
-
| `transactional` | `boolean`
|
|
487
|
+
| Key | Type | Purpose |
|
|
488
|
+
| --------------- | -------------------------------------------- | ------------------------------------------------------- |
|
|
489
|
+
| `down` | `(this: Migration) => void \| Promise<void>` | Rollback logic (not auto-inferred) |
|
|
490
|
+
| `up` | `(this: Migration) => void \| Promise<void>` | Extra imperative logic to run after declarative changes |
|
|
491
|
+
| `order` | `number` | Execution order override (default `0`) |
|
|
492
|
+
| `createdAt` | `string` | ISO timestamp override for migration name ordering |
|
|
493
|
+
| `transactional` | `boolean` | Wrap the migration in a DB transaction |
|
|
420
494
|
|
|
421
495
|
The `up` hook runs **after** the declarative schema changes, making it useful for data backfills or conditional DDL that depends on the added schema:
|
|
422
496
|
|
|
423
497
|
```ts
|
|
424
|
-
export default Migration.alter(
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
// backfill: mark existing confirmed users as verified
|
|
429
|
-
this.raw(`UPDATE users SET verified_at = updated_at WHERE status = 'confirmed'`);
|
|
498
|
+
export default Migration.alter(
|
|
499
|
+
User,
|
|
500
|
+
{
|
|
501
|
+
add: { verified_at: timestamp().nullable() },
|
|
430
502
|
},
|
|
431
|
-
|
|
432
|
-
|
|
503
|
+
{
|
|
504
|
+
up() {
|
|
505
|
+
// backfill: mark existing confirmed users as verified
|
|
506
|
+
this.raw(`UPDATE users SET verified_at = updated_at WHERE status = 'confirmed'`);
|
|
507
|
+
},
|
|
508
|
+
down() {
|
|
509
|
+
this.dropColumn("verified_at");
|
|
510
|
+
},
|
|
433
511
|
},
|
|
434
|
-
|
|
512
|
+
);
|
|
435
513
|
```
|
|
436
514
|
|
|
437
515
|
---
|
|
@@ -445,48 +523,58 @@ import { Migration, uuid } from "@warlock.js/cascade";
|
|
|
445
523
|
import { Team } from "app/teams/models/team";
|
|
446
524
|
import { User } from "../user.model";
|
|
447
525
|
|
|
448
|
-
export default Migration.alter(
|
|
449
|
-
|
|
450
|
-
|
|
526
|
+
export default Migration.alter(
|
|
527
|
+
User,
|
|
528
|
+
{
|
|
529
|
+
add: {
|
|
530
|
+
team_id: uuid().nullable(),
|
|
531
|
+
},
|
|
532
|
+
addForeign: [{ column: "team_id", references: Team, onDelete: "setNull" }],
|
|
533
|
+
addIndex: [{ columns: "team_id" }],
|
|
451
534
|
},
|
|
452
|
-
|
|
453
|
-
{
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
this.dropForeign("team_id", Team.table);
|
|
459
|
-
this.dropIndex("team_id");
|
|
460
|
-
this.dropColumn("team_id");
|
|
535
|
+
{
|
|
536
|
+
down() {
|
|
537
|
+
this.dropForeign("team_id", Team.table);
|
|
538
|
+
this.dropIndex("team_id");
|
|
539
|
+
this.dropColumn("team_id");
|
|
540
|
+
},
|
|
461
541
|
},
|
|
462
|
-
|
|
542
|
+
);
|
|
463
543
|
```
|
|
464
544
|
|
|
465
545
|
### Swap unique → plain index
|
|
466
546
|
|
|
467
547
|
```ts
|
|
468
|
-
export default Migration.alter(
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
this.dropIndex("users_email_index");
|
|
474
|
-
this.unique("email");
|
|
548
|
+
export default Migration.alter(
|
|
549
|
+
User,
|
|
550
|
+
{
|
|
551
|
+
dropUnique: [["email"]],
|
|
552
|
+
addIndex: [{ columns: "email", name: "users_email_index" }],
|
|
475
553
|
},
|
|
476
|
-
|
|
554
|
+
{
|
|
555
|
+
down() {
|
|
556
|
+
this.dropIndex("users_email_index");
|
|
557
|
+
this.unique("email");
|
|
558
|
+
},
|
|
559
|
+
},
|
|
560
|
+
);
|
|
477
561
|
```
|
|
478
562
|
|
|
479
563
|
### Rename + widen a column
|
|
480
564
|
|
|
481
565
|
```ts
|
|
482
|
-
export default Migration.alter(
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
},
|
|
486
|
-
|
|
487
|
-
this.renameColumn("content", "body");
|
|
566
|
+
export default Migration.alter(
|
|
567
|
+
Post,
|
|
568
|
+
{
|
|
569
|
+
rename: { body: "content" },
|
|
570
|
+
modify: { content: text().notNullable() },
|
|
488
571
|
},
|
|
489
|
-
|
|
572
|
+
{
|
|
573
|
+
down() {
|
|
574
|
+
this.renameColumn("content", "body");
|
|
575
|
+
},
|
|
576
|
+
},
|
|
577
|
+
);
|
|
490
578
|
```
|
|
491
579
|
|
|
492
580
|
### Multiple operations in one migration
|
|
@@ -494,22 +582,26 @@ export default Migration.alter(Post, {
|
|
|
494
582
|
Combine freely — all operations run in a single `up()` call:
|
|
495
583
|
|
|
496
584
|
```ts
|
|
497
|
-
export default Migration.alter(
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
},
|
|
505
|
-
|
|
506
|
-
this.dropCheck("price_non_negative");
|
|
507
|
-
this.dropIndex("idx_cat_status");
|
|
508
|
-
this.renameColumn("price_cents", "price");
|
|
509
|
-
this.text("old_code").nullable();
|
|
510
|
-
this.dropColumn("sku");
|
|
585
|
+
export default Migration.alter(
|
|
586
|
+
Product,
|
|
587
|
+
{
|
|
588
|
+
add: { sku: text().unique().notNullable() },
|
|
589
|
+
drop: ["old_code"],
|
|
590
|
+
rename: { price: "price_cents" },
|
|
591
|
+
modify: { price_cents: integer().notNullable() },
|
|
592
|
+
addIndex: [{ columns: ["category_id", "status"], name: "idx_cat_status" }],
|
|
593
|
+
addCheck: [{ name: "price_non_negative", expression: "price_cents >= 0" }],
|
|
511
594
|
},
|
|
512
|
-
|
|
595
|
+
{
|
|
596
|
+
down() {
|
|
597
|
+
this.dropCheck("price_non_negative");
|
|
598
|
+
this.dropIndex("idx_cat_status");
|
|
599
|
+
this.renameColumn("price_cents", "price");
|
|
600
|
+
this.text("old_code").nullable();
|
|
601
|
+
this.dropColumn("sku");
|
|
602
|
+
},
|
|
603
|
+
},
|
|
604
|
+
);
|
|
513
605
|
```
|
|
514
606
|
|
|
515
607
|
---
|