@warlock.js/cascade 4.0.48 → 4.0.59
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/cjs/context/database-data-source-context.d.ts +29 -0
- package/cjs/context/database-data-source-context.d.ts.map +1 -0
- package/cjs/context/database-data-source-context.js +28 -0
- package/cjs/context/database-data-source-context.js.map +1 -0
- package/cjs/context/database-transaction-context.d.ts +31 -0
- package/cjs/context/database-transaction-context.d.ts.map +1 -0
- package/cjs/context/database-transaction-context.js +34 -0
- package/cjs/context/database-transaction-context.js.map +1 -0
- package/cjs/contracts/database-driver.contract.d.ts +143 -0
- package/cjs/contracts/database-driver.contract.d.ts.map +1 -0
- package/cjs/contracts/database-id-generator.contract.d.ts +109 -0
- package/cjs/contracts/database-id-generator.contract.d.ts.map +1 -0
- package/cjs/contracts/database-remover.contract.d.ts +104 -0
- package/cjs/contracts/database-remover.contract.d.ts.map +1 -0
- package/cjs/contracts/database-restorer.contract.d.ts +143 -0
- package/cjs/contracts/database-restorer.contract.d.ts.map +1 -0
- package/cjs/contracts/database-writer.contract.d.ts +119 -0
- package/cjs/contracts/database-writer.contract.d.ts.map +1 -0
- package/cjs/contracts/driver-blueprint.contract.d.ts +45 -0
- package/cjs/contracts/driver-blueprint.contract.d.ts.map +1 -0
- package/cjs/contracts/index.d.ts +10 -0
- package/cjs/contracts/index.d.ts.map +1 -0
- package/cjs/contracts/migration-driver.contract.d.ts +365 -0
- package/cjs/contracts/migration-driver.contract.d.ts.map +1 -0
- package/cjs/contracts/query-builder.contract.d.ts +1128 -0
- package/cjs/contracts/query-builder.contract.d.ts.map +1 -0
- package/cjs/contracts/sync-adapter.contract.d.ts +58 -0
- package/cjs/contracts/sync-adapter.contract.d.ts.map +1 -0
- package/cjs/data-source/data-source-registry.d.ts +104 -0
- package/cjs/data-source/data-source-registry.d.ts.map +1 -0
- package/cjs/data-source/data-source-registry.js +138 -0
- package/cjs/data-source/data-source-registry.js.map +1 -0
- package/cjs/data-source/data-source.d.ts +106 -0
- package/cjs/data-source/data-source.d.ts.map +1 -0
- package/cjs/data-source/data-source.js +77 -0
- package/cjs/data-source/data-source.js.map +1 -0
- package/cjs/database-dirty-tracker.d.ts +253 -0
- package/cjs/database-dirty-tracker.d.ts.map +1 -0
- package/cjs/database-dirty-tracker.js +389 -0
- package/cjs/database-dirty-tracker.js.map +1 -0
- package/cjs/drivers/mongo/mongo-id-generator.d.ts +116 -0
- package/cjs/drivers/mongo/mongo-id-generator.d.ts.map +1 -0
- package/cjs/drivers/mongo/mongo-id-generator.js +149 -0
- package/cjs/drivers/mongo/mongo-id-generator.js.map +1 -0
- package/cjs/drivers/mongo/mongo-migration-driver.d.ts +228 -0
- package/cjs/drivers/mongo/mongo-migration-driver.d.ts.map +1 -0
- package/cjs/drivers/mongo/mongo-migration-driver.js +524 -0
- package/cjs/drivers/mongo/mongo-migration-driver.js.map +1 -0
- package/cjs/drivers/mongo/mongo-query-builder.d.ts +922 -0
- package/cjs/drivers/mongo/mongo-query-builder.d.ts.map +1 -0
- package/cjs/drivers/mongo/mongo-query-builder.js +1740 -0
- package/cjs/drivers/mongo/mongo-query-builder.js.map +1 -0
- package/cjs/drivers/mongo/mongo-query-operations.d.ts +226 -0
- package/cjs/drivers/mongo/mongo-query-operations.d.ts.map +1 -0
- package/cjs/drivers/mongo/mongo-query-operations.js +270 -0
- package/cjs/drivers/mongo/mongo-query-operations.js.map +1 -0
- package/cjs/drivers/mongo/mongo-query-parser.d.ts +262 -0
- package/cjs/drivers/mongo/mongo-query-parser.d.ts.map +1 -0
- package/cjs/drivers/mongo/mongo-query-parser.js +1351 -0
- package/cjs/drivers/mongo/mongo-query-parser.js.map +1 -0
- package/cjs/drivers/mongo/mongo-sync-adapter.d.ts +79 -0
- package/cjs/drivers/mongo/mongo-sync-adapter.d.ts.map +1 -0
- package/cjs/drivers/mongo/mongo-sync-adapter.js +146 -0
- package/cjs/drivers/mongo/mongo-sync-adapter.js.map +1 -0
- package/cjs/drivers/mongo/mongodb-blueprint.d.ts +30 -0
- package/cjs/drivers/mongo/mongodb-blueprint.d.ts.map +1 -0
- package/cjs/drivers/mongo/mongodb-blueprint.js +51 -0
- package/cjs/drivers/mongo/mongodb-blueprint.js.map +1 -0
- package/cjs/drivers/mongo/mongodb-driver.d.ts +188 -0
- package/cjs/drivers/mongo/mongodb-driver.d.ts.map +1 -0
- package/cjs/drivers/mongo/mongodb-driver.js +411 -0
- package/cjs/drivers/mongo/mongodb-driver.js.map +1 -0
- package/cjs/drivers/mongo/types.d.ts +43 -0
- package/cjs/drivers/mongo/types.d.ts.map +1 -0
- package/cjs/errors/missing-data-source.error.d.ts +22 -0
- package/cjs/errors/missing-data-source.error.d.ts.map +1 -0
- package/cjs/errors/missing-data-source.error.js +29 -0
- package/cjs/errors/missing-data-source.error.js.map +1 -0
- package/cjs/events/model-events.d.ts +231 -0
- package/cjs/events/model-events.d.ts.map +1 -0
- package/cjs/events/model-events.js +259 -0
- package/cjs/events/model-events.js.map +1 -0
- package/cjs/expressions/aggregate-expressions.d.ts +215 -0
- package/cjs/expressions/aggregate-expressions.d.ts.map +1 -0
- package/cjs/expressions/aggregate-expressions.js +221 -0
- package/cjs/expressions/aggregate-expressions.js.map +1 -0
- package/cjs/expressions/index.d.ts +2 -0
- package/cjs/expressions/index.d.ts.map +1 -0
- package/cjs/index.d.ts +41 -0
- package/cjs/index.d.ts.map +1 -0
- package/cjs/index.js +1 -267
- package/cjs/index.js.map +1 -1
- package/cjs/migration/column-builder.d.ts +167 -0
- package/cjs/migration/column-builder.d.ts.map +1 -0
- package/cjs/migration/column-builder.js +217 -0
- package/cjs/migration/column-builder.js.map +1 -0
- package/cjs/migration/foreign-key-builder.d.ts +110 -0
- package/cjs/migration/foreign-key-builder.d.ts.map +1 -0
- package/cjs/migration/foreign-key-builder.js +129 -0
- package/cjs/migration/foreign-key-builder.js.map +1 -0
- package/cjs/migration/index.d.ts +6 -0
- package/cjs/migration/index.d.ts.map +1 -0
- package/cjs/migration/migration-runner.d.ts +231 -0
- package/cjs/migration/migration-runner.d.ts.map +1 -0
- package/cjs/migration/migration-runner.js +443 -0
- package/cjs/migration/migration-runner.js.map +1 -0
- package/cjs/migration/migration.js +1346 -0
- package/cjs/migration/migration.js.map +1 -0
- package/cjs/migration/types.d.ts +132 -0
- package/cjs/migration/types.d.ts.map +1 -0
- package/cjs/model/model.d.ts +1267 -0
- package/cjs/model/model.d.ts.map +1 -0
- package/cjs/model/model.js +1463 -0
- package/cjs/model/model.js.map +1 -0
- package/cjs/model/register-model.d.ts +80 -0
- package/cjs/model/register-model.d.ts.map +1 -0
- package/cjs/model/register-model.js +91 -0
- package/cjs/model/register-model.js.map +1 -0
- package/cjs/remover/database-remover.d.ts +100 -0
- package/cjs/remover/database-remover.d.ts.map +1 -0
- package/cjs/remover/database-remover.js +209 -0
- package/cjs/remover/database-remover.js.map +1 -0
- package/cjs/restorer/database-restorer.d.ts +131 -0
- package/cjs/restorer/database-restorer.d.ts.map +1 -0
- package/cjs/restorer/database-restorer.js +425 -0
- package/cjs/restorer/database-restorer.js.map +1 -0
- package/cjs/sync/index.d.ts +12 -0
- package/cjs/sync/index.d.ts.map +1 -0
- package/cjs/sync/model-events.d.ts +62 -0
- package/cjs/sync/model-events.d.ts.map +1 -0
- package/cjs/sync/model-events.js +49 -0
- package/cjs/sync/model-events.js.map +1 -0
- package/cjs/sync/model-sync-operation.d.ts +163 -0
- package/cjs/sync/model-sync-operation.d.ts.map +1 -0
- package/cjs/sync/model-sync-operation.js +292 -0
- package/cjs/sync/model-sync-operation.js.map +1 -0
- package/cjs/sync/model-sync.d.ts +130 -0
- package/cjs/sync/model-sync.d.ts.map +1 -0
- package/cjs/sync/model-sync.js +178 -0
- package/cjs/sync/model-sync.js.map +1 -0
- package/cjs/sync/sync-context.d.ts +70 -0
- package/cjs/sync/sync-context.d.ts.map +1 -0
- package/cjs/sync/sync-context.js +101 -0
- package/cjs/sync/sync-context.js.map +1 -0
- package/cjs/sync/sync-manager.d.ts +213 -0
- package/cjs/sync/sync-manager.d.ts.map +1 -0
- package/cjs/sync/sync-manager.js +689 -0
- package/cjs/sync/sync-manager.js.map +1 -0
- package/cjs/sync/types.d.ts +289 -0
- package/cjs/sync/types.d.ts.map +1 -0
- package/cjs/types.d.ts +45 -0
- package/cjs/types.d.ts.map +1 -0
- package/cjs/utils/connect-to-database.d.ts +246 -0
- package/cjs/utils/connect-to-database.d.ts.map +1 -0
- package/cjs/utils/connect-to-database.js +92 -0
- package/cjs/utils/connect-to-database.js.map +1 -0
- package/cjs/utils/database-writer.utils.d.ts +15 -0
- package/cjs/utils/database-writer.utils.d.ts.map +1 -0
- package/cjs/utils/database-writer.utils.js +14 -0
- package/cjs/utils/database-writer.utils.js.map +1 -0
- package/cjs/utils/define-model.js +100 -0
- package/cjs/utils/define-model.js.map +1 -0
- package/cjs/utils/once-connected.d.ts +146 -0
- package/cjs/utils/once-connected.d.ts.map +1 -0
- package/cjs/utils/once-connected.js +252 -0
- package/cjs/utils/once-connected.js.map +1 -0
- package/cjs/validation/database-seal-plugins.d.ts +2 -0
- package/cjs/validation/database-seal-plugins.d.ts.map +1 -0
- package/cjs/validation/database-seal-plugins.js +4 -0
- package/cjs/validation/database-seal-plugins.js.map +1 -0
- package/cjs/validation/database-writer-validation-error.d.ts +97 -0
- package/cjs/validation/database-writer-validation-error.d.ts.map +1 -0
- package/cjs/validation/database-writer-validation-error.js +160 -0
- package/cjs/validation/database-writer-validation-error.js.map +1 -0
- package/cjs/validation/index.d.ts +3 -0
- package/cjs/validation/index.d.ts.map +1 -0
- package/cjs/validation/mutators/embed-mutator.d.ts +9 -0
- package/cjs/validation/mutators/embed-mutator.d.ts.map +1 -0
- package/cjs/validation/mutators/embed-mutator.js +33 -0
- package/cjs/validation/mutators/embed-mutator.js.map +1 -0
- package/cjs/validation/plugins/embed-validator-plugin.d.ts +24 -0
- package/cjs/validation/plugins/embed-validator-plugin.d.ts.map +1 -0
- package/cjs/validation/plugins/embed-validator-plugin.js +18 -0
- package/cjs/validation/plugins/embed-validator-plugin.js.map +1 -0
- package/cjs/validation/rules/database-model-rule.d.ts +7 -0
- package/cjs/validation/rules/database-model-rule.d.ts.map +1 -0
- package/cjs/validation/rules/database-model-rule.js +27 -0
- package/cjs/validation/rules/database-model-rule.js.map +1 -0
- package/cjs/validation/transformers/embed-model-transformer.d.ts +3 -0
- package/cjs/validation/transformers/embed-model-transformer.d.ts.map +1 -0
- package/cjs/validation/transformers/embed-model-transformer.js +18 -0
- package/cjs/validation/transformers/embed-model-transformer.js.map +1 -0
- package/cjs/validation/validators/embed-validator.d.ts +21 -0
- package/cjs/validation/validators/embed-validator.d.ts.map +1 -0
- package/cjs/validation/validators/embed-validator.js +42 -0
- package/cjs/validation/validators/embed-validator.js.map +1 -0
- package/cjs/writer/database-writer.d.ts +181 -0
- package/cjs/writer/database-writer.d.ts.map +1 -0
- package/cjs/writer/database-writer.js +402 -0
- package/cjs/writer/database-writer.js.map +1 -0
- package/esm/context/database-data-source-context.d.ts +29 -0
- package/esm/context/database-data-source-context.d.ts.map +1 -0
- package/esm/context/database-data-source-context.js +28 -0
- package/esm/context/database-data-source-context.js.map +1 -0
- package/esm/context/database-transaction-context.d.ts +31 -0
- package/esm/context/database-transaction-context.d.ts.map +1 -0
- package/esm/context/database-transaction-context.js +34 -0
- package/esm/context/database-transaction-context.js.map +1 -0
- package/esm/contracts/database-driver.contract.d.ts +143 -0
- package/esm/contracts/database-driver.contract.d.ts.map +1 -0
- package/esm/contracts/database-id-generator.contract.d.ts +109 -0
- package/esm/contracts/database-id-generator.contract.d.ts.map +1 -0
- package/esm/contracts/database-remover.contract.d.ts +104 -0
- package/esm/contracts/database-remover.contract.d.ts.map +1 -0
- package/esm/contracts/database-restorer.contract.d.ts +143 -0
- package/esm/contracts/database-restorer.contract.d.ts.map +1 -0
- package/esm/contracts/database-writer.contract.d.ts +119 -0
- package/esm/contracts/database-writer.contract.d.ts.map +1 -0
- package/esm/contracts/driver-blueprint.contract.d.ts +45 -0
- package/esm/contracts/driver-blueprint.contract.d.ts.map +1 -0
- package/esm/contracts/index.d.ts +10 -0
- package/esm/contracts/index.d.ts.map +1 -0
- package/esm/contracts/migration-driver.contract.d.ts +365 -0
- package/esm/contracts/migration-driver.contract.d.ts.map +1 -0
- package/esm/contracts/query-builder.contract.d.ts +1128 -0
- package/esm/contracts/query-builder.contract.d.ts.map +1 -0
- package/esm/contracts/sync-adapter.contract.d.ts +58 -0
- package/esm/contracts/sync-adapter.contract.d.ts.map +1 -0
- package/esm/data-source/data-source-registry.d.ts +104 -0
- package/esm/data-source/data-source-registry.d.ts.map +1 -0
- package/esm/data-source/data-source-registry.js +138 -0
- package/esm/data-source/data-source-registry.js.map +1 -0
- package/esm/data-source/data-source.d.ts +106 -0
- package/esm/data-source/data-source.d.ts.map +1 -0
- package/esm/data-source/data-source.js +77 -0
- package/esm/data-source/data-source.js.map +1 -0
- package/esm/database-dirty-tracker.d.ts +253 -0
- package/esm/database-dirty-tracker.d.ts.map +1 -0
- package/esm/database-dirty-tracker.js +389 -0
- package/esm/database-dirty-tracker.js.map +1 -0
- package/esm/drivers/mongo/mongo-id-generator.d.ts +116 -0
- package/esm/drivers/mongo/mongo-id-generator.d.ts.map +1 -0
- package/esm/drivers/mongo/mongo-id-generator.js +149 -0
- package/esm/drivers/mongo/mongo-id-generator.js.map +1 -0
- package/esm/drivers/mongo/mongo-migration-driver.d.ts +228 -0
- package/esm/drivers/mongo/mongo-migration-driver.d.ts.map +1 -0
- package/esm/drivers/mongo/mongo-migration-driver.js +524 -0
- package/esm/drivers/mongo/mongo-migration-driver.js.map +1 -0
- package/esm/drivers/mongo/mongo-query-builder.d.ts +922 -0
- package/esm/drivers/mongo/mongo-query-builder.d.ts.map +1 -0
- package/esm/drivers/mongo/mongo-query-builder.js +1740 -0
- package/esm/drivers/mongo/mongo-query-builder.js.map +1 -0
- package/esm/drivers/mongo/mongo-query-operations.d.ts +226 -0
- package/esm/drivers/mongo/mongo-query-operations.d.ts.map +1 -0
- package/esm/drivers/mongo/mongo-query-operations.js +270 -0
- package/esm/drivers/mongo/mongo-query-operations.js.map +1 -0
- package/esm/drivers/mongo/mongo-query-parser.d.ts +262 -0
- package/esm/drivers/mongo/mongo-query-parser.d.ts.map +1 -0
- package/esm/drivers/mongo/mongo-query-parser.js +1351 -0
- package/esm/drivers/mongo/mongo-query-parser.js.map +1 -0
- package/esm/drivers/mongo/mongo-sync-adapter.d.ts +79 -0
- package/esm/drivers/mongo/mongo-sync-adapter.d.ts.map +1 -0
- package/esm/drivers/mongo/mongo-sync-adapter.js +146 -0
- package/esm/drivers/mongo/mongo-sync-adapter.js.map +1 -0
- package/esm/drivers/mongo/mongodb-blueprint.d.ts +30 -0
- package/esm/drivers/mongo/mongodb-blueprint.d.ts.map +1 -0
- package/esm/drivers/mongo/mongodb-blueprint.js +51 -0
- package/esm/drivers/mongo/mongodb-blueprint.js.map +1 -0
- package/esm/drivers/mongo/mongodb-driver.d.ts +188 -0
- package/esm/drivers/mongo/mongodb-driver.d.ts.map +1 -0
- package/esm/drivers/mongo/mongodb-driver.js +411 -0
- package/esm/drivers/mongo/mongodb-driver.js.map +1 -0
- package/esm/drivers/mongo/types.d.ts +43 -0
- package/esm/drivers/mongo/types.d.ts.map +1 -0
- package/esm/errors/missing-data-source.error.d.ts +22 -0
- package/esm/errors/missing-data-source.error.d.ts.map +1 -0
- package/esm/errors/missing-data-source.error.js +29 -0
- package/esm/errors/missing-data-source.error.js.map +1 -0
- package/esm/events/model-events.d.ts +231 -0
- package/esm/events/model-events.d.ts.map +1 -0
- package/esm/events/model-events.js +259 -0
- package/esm/events/model-events.js.map +1 -0
- package/esm/expressions/aggregate-expressions.d.ts +215 -0
- package/esm/expressions/aggregate-expressions.d.ts.map +1 -0
- package/esm/expressions/aggregate-expressions.js +221 -0
- package/esm/expressions/aggregate-expressions.js.map +1 -0
- package/esm/expressions/index.d.ts +2 -0
- package/esm/expressions/index.d.ts.map +1 -0
- package/esm/index.d.ts +41 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +1 -40
- package/esm/index.js.map +1 -1
- package/esm/migration/column-builder.d.ts +167 -0
- package/esm/migration/column-builder.d.ts.map +1 -0
- package/esm/migration/column-builder.js +217 -0
- package/esm/migration/column-builder.js.map +1 -0
- package/esm/migration/foreign-key-builder.d.ts +110 -0
- package/esm/migration/foreign-key-builder.d.ts.map +1 -0
- package/esm/migration/foreign-key-builder.js +129 -0
- package/esm/migration/foreign-key-builder.js.map +1 -0
- package/esm/migration/index.d.ts +6 -0
- package/esm/migration/index.d.ts.map +1 -0
- package/esm/migration/migration-runner.d.ts +231 -0
- package/esm/migration/migration-runner.d.ts.map +1 -0
- package/esm/migration/migration-runner.js +443 -0
- package/esm/migration/migration-runner.js.map +1 -0
- package/esm/migration/migration.js +1346 -0
- package/esm/migration/migration.js.map +1 -0
- package/esm/migration/types.d.ts +132 -0
- package/esm/migration/types.d.ts.map +1 -0
- package/esm/model/model.d.ts +1267 -0
- package/esm/model/model.d.ts.map +1 -0
- package/esm/model/model.js +1463 -0
- package/esm/model/model.js.map +1 -0
- package/esm/model/register-model.d.ts +80 -0
- package/esm/model/register-model.d.ts.map +1 -0
- package/esm/model/register-model.js +91 -0
- package/esm/model/register-model.js.map +1 -0
- package/esm/remover/database-remover.d.ts +100 -0
- package/esm/remover/database-remover.d.ts.map +1 -0
- package/esm/remover/database-remover.js +209 -0
- package/esm/remover/database-remover.js.map +1 -0
- package/esm/restorer/database-restorer.d.ts +131 -0
- package/esm/restorer/database-restorer.d.ts.map +1 -0
- package/esm/restorer/database-restorer.js +425 -0
- package/esm/restorer/database-restorer.js.map +1 -0
- package/esm/sync/index.d.ts +12 -0
- package/esm/sync/index.d.ts.map +1 -0
- package/esm/sync/model-events.d.ts +62 -0
- package/esm/sync/model-events.d.ts.map +1 -0
- package/esm/sync/model-events.js +49 -0
- package/esm/sync/model-events.js.map +1 -0
- package/esm/sync/model-sync-operation.d.ts +163 -0
- package/esm/sync/model-sync-operation.d.ts.map +1 -0
- package/esm/sync/model-sync-operation.js +292 -0
- package/esm/sync/model-sync-operation.js.map +1 -0
- package/esm/sync/model-sync.d.ts +130 -0
- package/esm/sync/model-sync.d.ts.map +1 -0
- package/esm/sync/model-sync.js +178 -0
- package/esm/sync/model-sync.js.map +1 -0
- package/esm/sync/sync-context.d.ts +70 -0
- package/esm/sync/sync-context.d.ts.map +1 -0
- package/esm/sync/sync-context.js +101 -0
- package/esm/sync/sync-context.js.map +1 -0
- package/esm/sync/sync-manager.d.ts +213 -0
- package/esm/sync/sync-manager.d.ts.map +1 -0
- package/esm/sync/sync-manager.js +689 -0
- package/esm/sync/sync-manager.js.map +1 -0
- package/esm/sync/types.d.ts +289 -0
- package/esm/sync/types.d.ts.map +1 -0
- package/esm/types.d.ts +45 -0
- package/esm/types.d.ts.map +1 -0
- package/esm/utils/connect-to-database.d.ts +246 -0
- package/esm/utils/connect-to-database.d.ts.map +1 -0
- package/esm/utils/connect-to-database.js +92 -0
- package/esm/utils/connect-to-database.js.map +1 -0
- package/esm/utils/database-writer.utils.d.ts +15 -0
- package/esm/utils/database-writer.utils.d.ts.map +1 -0
- package/esm/utils/database-writer.utils.js +14 -0
- package/esm/utils/database-writer.utils.js.map +1 -0
- package/esm/utils/define-model.js +100 -0
- package/esm/utils/define-model.js.map +1 -0
- package/esm/utils/once-connected.d.ts +146 -0
- package/esm/utils/once-connected.d.ts.map +1 -0
- package/esm/utils/once-connected.js +252 -0
- package/esm/utils/once-connected.js.map +1 -0
- package/esm/validation/database-seal-plugins.d.ts +2 -0
- package/esm/validation/database-seal-plugins.d.ts.map +1 -0
- package/esm/validation/database-seal-plugins.js +4 -0
- package/esm/validation/database-seal-plugins.js.map +1 -0
- package/esm/validation/database-writer-validation-error.d.ts +97 -0
- package/esm/validation/database-writer-validation-error.d.ts.map +1 -0
- package/esm/validation/database-writer-validation-error.js +160 -0
- package/esm/validation/database-writer-validation-error.js.map +1 -0
- package/esm/validation/index.d.ts +3 -0
- package/esm/validation/index.d.ts.map +1 -0
- package/esm/validation/mutators/embed-mutator.d.ts +9 -0
- package/esm/validation/mutators/embed-mutator.d.ts.map +1 -0
- package/esm/validation/mutators/embed-mutator.js +33 -0
- package/esm/validation/mutators/embed-mutator.js.map +1 -0
- package/esm/validation/plugins/embed-validator-plugin.d.ts +24 -0
- package/esm/validation/plugins/embed-validator-plugin.d.ts.map +1 -0
- package/esm/validation/plugins/embed-validator-plugin.js +18 -0
- package/esm/validation/plugins/embed-validator-plugin.js.map +1 -0
- package/esm/validation/rules/database-model-rule.d.ts +7 -0
- package/esm/validation/rules/database-model-rule.d.ts.map +1 -0
- package/esm/validation/rules/database-model-rule.js +27 -0
- package/esm/validation/rules/database-model-rule.js.map +1 -0
- package/esm/validation/transformers/embed-model-transformer.d.ts +3 -0
- package/esm/validation/transformers/embed-model-transformer.d.ts.map +1 -0
- package/esm/validation/transformers/embed-model-transformer.js +18 -0
- package/esm/validation/transformers/embed-model-transformer.js.map +1 -0
- package/esm/validation/validators/embed-validator.d.ts +21 -0
- package/esm/validation/validators/embed-validator.d.ts.map +1 -0
- package/esm/validation/validators/embed-validator.js +42 -0
- package/esm/validation/validators/embed-validator.js.map +1 -0
- package/esm/writer/database-writer.d.ts +181 -0
- package/esm/writer/database-writer.d.ts.map +1 -0
- package/esm/writer/database-writer.js +402 -0
- package/esm/writer/database-writer.js.map +1 -0
- package/package.json +61 -52
|
@@ -0,0 +1,1346 @@
|
|
|
1
|
+
'use strict';var columnBuilder=require('./column-builder.js'),foreignKeyBuilder=require('./foreign-key-builder.js');/**
|
|
2
|
+
* Base class for all database migrations.
|
|
3
|
+
*
|
|
4
|
+
* Provides a fluent API for defining schema changes that work across
|
|
5
|
+
* both SQL and NoSQL databases. The migration driver handles translating
|
|
6
|
+
* operations to native database commands.
|
|
7
|
+
*
|
|
8
|
+
* Migrations are executed in order based on their `createdAt` timestamp,
|
|
9
|
+
* which is typically extracted from the filename (e.g., `2024-01-15_create-users`).
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* // Using Migration.for() to bind to a model
|
|
14
|
+
* export default class extends Migration.for(User) {
|
|
15
|
+
* public up(): void {
|
|
16
|
+
* this.string("email").unique();
|
|
17
|
+
* this.integer("age").nullable();
|
|
18
|
+
* this.geoIndex("location");
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* public down(): void {
|
|
22
|
+
* this.dropColumn("email");
|
|
23
|
+
* this.dropColumn("age");
|
|
24
|
+
* this.dropGeoIndex("location");
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* // Manual table migration (without model binding)
|
|
32
|
+
* export default class CreateUsersTable extends Migration {
|
|
33
|
+
* public readonly table = "users";
|
|
34
|
+
*
|
|
35
|
+
* public up(): void {
|
|
36
|
+
* this.createTable();
|
|
37
|
+
* this.id();
|
|
38
|
+
* this.string("name");
|
|
39
|
+
* this.string("email").unique();
|
|
40
|
+
* this.timestamps();
|
|
41
|
+
* }
|
|
42
|
+
*
|
|
43
|
+
* public down(): void {
|
|
44
|
+
* this.dropTable();
|
|
45
|
+
* }
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
class Migration {
|
|
50
|
+
/**
|
|
51
|
+
* Migration name that will be labeled with
|
|
52
|
+
* If record is enabled in migration, it will be stored as migration name
|
|
53
|
+
* in database
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* "2024-01-15_create-users";
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
static migrationName;
|
|
61
|
+
/**
|
|
62
|
+
* Table/collection name for this migration.
|
|
63
|
+
*
|
|
64
|
+
* Must be defined by each migration class (either directly or via `Migration.for()`).
|
|
65
|
+
*/
|
|
66
|
+
table;
|
|
67
|
+
/**
|
|
68
|
+
* Sort order
|
|
69
|
+
* If not provided, it will be ordered alphabetically
|
|
70
|
+
*/
|
|
71
|
+
static order;
|
|
72
|
+
/**
|
|
73
|
+
* Optional data source override.
|
|
74
|
+
*
|
|
75
|
+
* If specified, this migration will use a specific data source
|
|
76
|
+
* instead of the default one. Can be a string name or DataSource instance.
|
|
77
|
+
*/
|
|
78
|
+
dataSource;
|
|
79
|
+
/**
|
|
80
|
+
* Optional timestamp override.
|
|
81
|
+
*
|
|
82
|
+
* By default, the migration runner extracts this from the filename.
|
|
83
|
+
* Set explicitly to override the execution order.
|
|
84
|
+
*
|
|
85
|
+
* Format: ISO 8601 or any parseable date string.
|
|
86
|
+
*/
|
|
87
|
+
createdAt;
|
|
88
|
+
/**
|
|
89
|
+
* Whether to wrap migration in a transaction.
|
|
90
|
+
*
|
|
91
|
+
* Defaults to `true` for SQL databases that support DDL transactions.
|
|
92
|
+
* Set to `false` for operations that cannot be transactional.
|
|
93
|
+
*
|
|
94
|
+
* Note: MongoDB does not support transactions for most DDL operations.
|
|
95
|
+
*/
|
|
96
|
+
transactional;
|
|
97
|
+
/**
|
|
98
|
+
* Migration driver instance (injected by the runner).
|
|
99
|
+
*/
|
|
100
|
+
driver;
|
|
101
|
+
/**
|
|
102
|
+
* Queued operations to execute.
|
|
103
|
+
*/
|
|
104
|
+
pendingOperations = [];
|
|
105
|
+
/**
|
|
106
|
+
* Pending indexes from column builders.
|
|
107
|
+
*/
|
|
108
|
+
pendingIndexes = [];
|
|
109
|
+
// ============================================================================
|
|
110
|
+
// STATIC FACTORY
|
|
111
|
+
// ============================================================================
|
|
112
|
+
/**
|
|
113
|
+
* Create a migration class bound to a specific model.
|
|
114
|
+
*
|
|
115
|
+
* Automatically inherits the model's table name and data source,
|
|
116
|
+
* reducing boilerplate and ensuring consistency.
|
|
117
|
+
*
|
|
118
|
+
* @param model - Model class to bind
|
|
119
|
+
* @returns Abstract migration class bound to the model
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* export default class extends Migration.for(User) {
|
|
124
|
+
* public up(): void {
|
|
125
|
+
* this.string("avatar").nullable();
|
|
126
|
+
* }
|
|
127
|
+
*
|
|
128
|
+
* public down(): void {
|
|
129
|
+
* this.dropColumn("avatar");
|
|
130
|
+
* }
|
|
131
|
+
* }
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
static for(model) {
|
|
135
|
+
class BoundMigration extends Migration {
|
|
136
|
+
table = model.table;
|
|
137
|
+
dataSource = model.dataSource;
|
|
138
|
+
}
|
|
139
|
+
return BoundMigration;
|
|
140
|
+
}
|
|
141
|
+
// ============================================================================
|
|
142
|
+
// DRIVER INJECTION
|
|
143
|
+
// ============================================================================
|
|
144
|
+
/**
|
|
145
|
+
* Set the migration driver.
|
|
146
|
+
*
|
|
147
|
+
* Called by the migration runner before executing up/down.
|
|
148
|
+
*
|
|
149
|
+
* @param driver - Migration driver instance
|
|
150
|
+
* @internal
|
|
151
|
+
*/
|
|
152
|
+
setDriver(driver) {
|
|
153
|
+
this.driver = driver;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Get the migration driver.
|
|
157
|
+
*
|
|
158
|
+
* @returns The migration driver instance
|
|
159
|
+
*/
|
|
160
|
+
getDriver() {
|
|
161
|
+
return this.driver;
|
|
162
|
+
}
|
|
163
|
+
// ============================================================================
|
|
164
|
+
// EXECUTE OPERATIONS
|
|
165
|
+
// ============================================================================
|
|
166
|
+
/**
|
|
167
|
+
* Execute all pending operations.
|
|
168
|
+
*
|
|
169
|
+
* Called by the migration runner after up() or down() completes.
|
|
170
|
+
* Executes operations in the order they were defined.
|
|
171
|
+
*
|
|
172
|
+
* @internal
|
|
173
|
+
*/
|
|
174
|
+
async execute() {
|
|
175
|
+
// Execute column/table operations
|
|
176
|
+
for (const op of this.pendingOperations) {
|
|
177
|
+
await this.executeOperation(op);
|
|
178
|
+
}
|
|
179
|
+
// Execute pending indexes from column builders
|
|
180
|
+
for (const index of this.pendingIndexes) {
|
|
181
|
+
if (index.unique) {
|
|
182
|
+
await this.driver.createUniqueIndex(this.table, index.columns, index.name);
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
await this.driver.createIndex(this.table, index);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
// Clear pending operations after execution
|
|
189
|
+
this.pendingOperations.length = 0;
|
|
190
|
+
this.pendingIndexes.length = 0;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Execute a single pending operation.
|
|
194
|
+
*/
|
|
195
|
+
async executeOperation(op) {
|
|
196
|
+
switch (op.type) {
|
|
197
|
+
case "addColumn":
|
|
198
|
+
await this.driver.addColumn(this.table, op.payload);
|
|
199
|
+
break;
|
|
200
|
+
case "dropColumn":
|
|
201
|
+
await this.driver.dropColumn(this.table, op.payload);
|
|
202
|
+
break;
|
|
203
|
+
case "dropColumns":
|
|
204
|
+
await this.driver.dropColumns(this.table, op.payload);
|
|
205
|
+
break;
|
|
206
|
+
case "renameColumn": {
|
|
207
|
+
const { from, to } = op.payload;
|
|
208
|
+
await this.driver.renameColumn(this.table, from, to);
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
case "modifyColumn":
|
|
212
|
+
await this.driver.modifyColumn(this.table, op.payload);
|
|
213
|
+
break;
|
|
214
|
+
case "createIndex":
|
|
215
|
+
await this.driver.createIndex(this.table, op.payload);
|
|
216
|
+
break;
|
|
217
|
+
case "dropIndex":
|
|
218
|
+
await this.driver.dropIndex(this.table, op.payload);
|
|
219
|
+
break;
|
|
220
|
+
case "createUniqueIndex": {
|
|
221
|
+
const { columns, name } = op.payload;
|
|
222
|
+
await this.driver.createUniqueIndex(this.table, columns, name);
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
case "dropUniqueIndex":
|
|
226
|
+
await this.driver.dropUniqueIndex(this.table, op.payload);
|
|
227
|
+
break;
|
|
228
|
+
case "createFullTextIndex": {
|
|
229
|
+
const { columns, options } = op.payload;
|
|
230
|
+
await this.driver.createFullTextIndex(this.table, columns, options);
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
case "dropFullTextIndex":
|
|
234
|
+
await this.driver.dropFullTextIndex(this.table, op.payload);
|
|
235
|
+
break;
|
|
236
|
+
case "createGeoIndex": {
|
|
237
|
+
const { column, options } = op.payload;
|
|
238
|
+
await this.driver.createGeoIndex(this.table, column, options);
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
case "dropGeoIndex":
|
|
242
|
+
await this.driver.dropGeoIndex(this.table, op.payload);
|
|
243
|
+
break;
|
|
244
|
+
case "createVectorIndex": {
|
|
245
|
+
const { column, options } = op.payload;
|
|
246
|
+
await this.driver.createVectorIndex(this.table, column, options);
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
case "dropVectorIndex":
|
|
250
|
+
await this.driver.dropVectorIndex(this.table, op.payload);
|
|
251
|
+
break;
|
|
252
|
+
case "createTTLIndex": {
|
|
253
|
+
const { column, seconds } = op.payload;
|
|
254
|
+
await this.driver.createTTLIndex(this.table, column, seconds);
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
case "dropTTLIndex":
|
|
258
|
+
await this.driver.dropTTLIndex(this.table, op.payload);
|
|
259
|
+
break;
|
|
260
|
+
case "addForeignKey":
|
|
261
|
+
await this.driver.addForeignKey(this.table, op.payload);
|
|
262
|
+
break;
|
|
263
|
+
case "dropForeignKey":
|
|
264
|
+
await this.driver.dropForeignKey(this.table, op.payload);
|
|
265
|
+
break;
|
|
266
|
+
case "addPrimaryKey":
|
|
267
|
+
await this.driver.addPrimaryKey(this.table, op.payload);
|
|
268
|
+
break;
|
|
269
|
+
case "dropPrimaryKey":
|
|
270
|
+
await this.driver.dropPrimaryKey(this.table);
|
|
271
|
+
break;
|
|
272
|
+
case "createTable":
|
|
273
|
+
await this.driver.createTable(this.table);
|
|
274
|
+
break;
|
|
275
|
+
case "createTableIfNotExists":
|
|
276
|
+
await this.driver.createTableIfNotExists(this.table);
|
|
277
|
+
break;
|
|
278
|
+
case "dropTable":
|
|
279
|
+
await this.driver.dropTable(this.table);
|
|
280
|
+
break;
|
|
281
|
+
case "dropTableIfExists":
|
|
282
|
+
await this.driver.dropTableIfExists(this.table);
|
|
283
|
+
break;
|
|
284
|
+
case "renameTable":
|
|
285
|
+
await this.driver.renameTable(this.table, op.payload);
|
|
286
|
+
break;
|
|
287
|
+
case "setSchemaValidation":
|
|
288
|
+
await this.driver.setSchemaValidation(this.table, op.payload);
|
|
289
|
+
break;
|
|
290
|
+
case "removeSchemaValidation":
|
|
291
|
+
await this.driver.removeSchemaValidation(this.table);
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
// ============================================================================
|
|
296
|
+
// INTERNAL HELPERS
|
|
297
|
+
// ============================================================================
|
|
298
|
+
/**
|
|
299
|
+
* Add a pending index definition.
|
|
300
|
+
*
|
|
301
|
+
* Called by ColumnBuilder when .unique() or .index() is chained.
|
|
302
|
+
*
|
|
303
|
+
* @param index - Index definition
|
|
304
|
+
* @internal
|
|
305
|
+
*/
|
|
306
|
+
addPendingIndex(index) {
|
|
307
|
+
this.pendingIndexes.push(index);
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Add a foreign key operation.
|
|
311
|
+
*
|
|
312
|
+
* Called by ForeignKeyBuilder when .add() is called.
|
|
313
|
+
*
|
|
314
|
+
* @param fk - Foreign key definition
|
|
315
|
+
* @internal
|
|
316
|
+
*/
|
|
317
|
+
addForeignKeyOperation(fk) {
|
|
318
|
+
this.pendingOperations.push({
|
|
319
|
+
type: "addForeignKey",
|
|
320
|
+
payload: fk,
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
// ============================================================================
|
|
324
|
+
// TABLE OPERATIONS
|
|
325
|
+
// ============================================================================
|
|
326
|
+
/**
|
|
327
|
+
* Create the table/collection.
|
|
328
|
+
*
|
|
329
|
+
* For SQL, this creates an empty table.
|
|
330
|
+
* For MongoDB, this creates the collection.
|
|
331
|
+
*
|
|
332
|
+
* @returns This migration for chaining
|
|
333
|
+
*/
|
|
334
|
+
createTable() {
|
|
335
|
+
this.pendingOperations.push({ type: "createTable", payload: null });
|
|
336
|
+
return this;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Create table if not exists
|
|
340
|
+
*/
|
|
341
|
+
createTableIfNotExists() {
|
|
342
|
+
this.pendingOperations.push({ type: "createTableIfNotExists", payload: null });
|
|
343
|
+
return this;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Drop the table/collection.
|
|
347
|
+
*
|
|
348
|
+
* @returns This migration for chaining
|
|
349
|
+
*/
|
|
350
|
+
dropTable() {
|
|
351
|
+
this.pendingOperations.push({ type: "dropTable", payload: null });
|
|
352
|
+
return this;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Drop the table/collection if it exists.
|
|
356
|
+
*
|
|
357
|
+
* No error is thrown if the table doesn't exist.
|
|
358
|
+
*
|
|
359
|
+
* @returns This migration for chaining
|
|
360
|
+
*/
|
|
361
|
+
dropTableIfExists() {
|
|
362
|
+
this.pendingOperations.push({ type: "dropTableIfExists", payload: null });
|
|
363
|
+
return this;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Rename the table/collection.
|
|
367
|
+
*
|
|
368
|
+
* @param newName - New table name
|
|
369
|
+
* @returns This migration for chaining
|
|
370
|
+
*/
|
|
371
|
+
renameTableTo(newName) {
|
|
372
|
+
this.pendingOperations.push({ type: "renameTable", payload: newName });
|
|
373
|
+
return this;
|
|
374
|
+
}
|
|
375
|
+
// ============================================================================
|
|
376
|
+
// COLUMN TYPES - STRING
|
|
377
|
+
// ============================================================================
|
|
378
|
+
/**
|
|
379
|
+
* Add a string/varchar column.
|
|
380
|
+
*
|
|
381
|
+
* @param column - Column name
|
|
382
|
+
* @param length - Max length (default: 255)
|
|
383
|
+
* @returns Column builder for chaining modifiers
|
|
384
|
+
*
|
|
385
|
+
* @example
|
|
386
|
+
* ```typescript
|
|
387
|
+
* this.string("name"); // VARCHAR(255)
|
|
388
|
+
* this.string("code", 10); // VARCHAR(10)
|
|
389
|
+
* ```
|
|
390
|
+
*/
|
|
391
|
+
string(column, length = 255) {
|
|
392
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "string", { length });
|
|
393
|
+
this.pendingOperations.push({
|
|
394
|
+
type: "addColumn",
|
|
395
|
+
payload: builder.getDefinition(),
|
|
396
|
+
});
|
|
397
|
+
return builder;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Add a fixed-length char column.
|
|
401
|
+
*
|
|
402
|
+
* @param column - Column name
|
|
403
|
+
* @param length - Exact length
|
|
404
|
+
* @returns Column builder for chaining modifiers
|
|
405
|
+
*/
|
|
406
|
+
char(column, length) {
|
|
407
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "char", { length });
|
|
408
|
+
this.pendingOperations.push({
|
|
409
|
+
type: "addColumn",
|
|
410
|
+
payload: builder.getDefinition(),
|
|
411
|
+
});
|
|
412
|
+
return builder;
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Add a text column (unlimited length).
|
|
416
|
+
*
|
|
417
|
+
* @param column - Column name
|
|
418
|
+
* @returns Column builder for chaining modifiers
|
|
419
|
+
*/
|
|
420
|
+
text(column) {
|
|
421
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "text");
|
|
422
|
+
this.pendingOperations.push({
|
|
423
|
+
type: "addColumn",
|
|
424
|
+
payload: builder.getDefinition(),
|
|
425
|
+
});
|
|
426
|
+
return builder;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Add a medium text column.
|
|
430
|
+
*
|
|
431
|
+
* @param column - Column name
|
|
432
|
+
* @returns Column builder for chaining modifiers
|
|
433
|
+
*/
|
|
434
|
+
mediumText(column) {
|
|
435
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "mediumText");
|
|
436
|
+
this.pendingOperations.push({
|
|
437
|
+
type: "addColumn",
|
|
438
|
+
payload: builder.getDefinition(),
|
|
439
|
+
});
|
|
440
|
+
return builder;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Add a long text column.
|
|
444
|
+
*
|
|
445
|
+
* @param column - Column name
|
|
446
|
+
* @returns Column builder for chaining modifiers
|
|
447
|
+
*/
|
|
448
|
+
longText(column) {
|
|
449
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "longText");
|
|
450
|
+
this.pendingOperations.push({
|
|
451
|
+
type: "addColumn",
|
|
452
|
+
payload: builder.getDefinition(),
|
|
453
|
+
});
|
|
454
|
+
return builder;
|
|
455
|
+
}
|
|
456
|
+
// ============================================================================
|
|
457
|
+
// COLUMN TYPES - NUMERIC
|
|
458
|
+
// ============================================================================
|
|
459
|
+
/**
|
|
460
|
+
* Add an integer column.
|
|
461
|
+
*
|
|
462
|
+
* @param column - Column name
|
|
463
|
+
* @returns Column builder for chaining modifiers
|
|
464
|
+
*/
|
|
465
|
+
integer(column) {
|
|
466
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "integer");
|
|
467
|
+
this.pendingOperations.push({
|
|
468
|
+
type: "addColumn",
|
|
469
|
+
payload: builder.getDefinition(),
|
|
470
|
+
});
|
|
471
|
+
return builder;
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Alias for integer().
|
|
475
|
+
*/
|
|
476
|
+
int(column) {
|
|
477
|
+
return this.integer(column);
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Add a small integer column.
|
|
481
|
+
*
|
|
482
|
+
* @param column - Column name
|
|
483
|
+
* @returns Column builder for chaining modifiers
|
|
484
|
+
*/
|
|
485
|
+
smallInteger(column) {
|
|
486
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "smallInteger");
|
|
487
|
+
this.pendingOperations.push({
|
|
488
|
+
type: "addColumn",
|
|
489
|
+
payload: builder.getDefinition(),
|
|
490
|
+
});
|
|
491
|
+
return builder;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Alias for smallInteger().
|
|
495
|
+
*/
|
|
496
|
+
smallInt(column) {
|
|
497
|
+
return this.smallInteger(column);
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Add a tiny integer column.
|
|
501
|
+
*
|
|
502
|
+
* @param column - Column name
|
|
503
|
+
* @returns Column builder for chaining modifiers
|
|
504
|
+
*/
|
|
505
|
+
tinyInteger(column) {
|
|
506
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "tinyInteger");
|
|
507
|
+
this.pendingOperations.push({
|
|
508
|
+
type: "addColumn",
|
|
509
|
+
payload: builder.getDefinition(),
|
|
510
|
+
});
|
|
511
|
+
return builder;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Alias for tinyInteger().
|
|
515
|
+
*/
|
|
516
|
+
tinyInt(column) {
|
|
517
|
+
return this.tinyInteger(column);
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Add a big integer column.
|
|
521
|
+
*
|
|
522
|
+
* @param column - Column name
|
|
523
|
+
* @returns Column builder for chaining modifiers
|
|
524
|
+
*/
|
|
525
|
+
bigInteger(column) {
|
|
526
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "bigInteger");
|
|
527
|
+
this.pendingOperations.push({
|
|
528
|
+
type: "addColumn",
|
|
529
|
+
payload: builder.getDefinition(),
|
|
530
|
+
});
|
|
531
|
+
return builder;
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Alias for bigInteger().
|
|
535
|
+
*/
|
|
536
|
+
bigInt(column) {
|
|
537
|
+
return this.bigInteger(column);
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Add a float column.
|
|
541
|
+
*
|
|
542
|
+
* @param column - Column name
|
|
543
|
+
* @returns Column builder for chaining modifiers
|
|
544
|
+
*/
|
|
545
|
+
float(column) {
|
|
546
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "float");
|
|
547
|
+
this.pendingOperations.push({
|
|
548
|
+
type: "addColumn",
|
|
549
|
+
payload: builder.getDefinition(),
|
|
550
|
+
});
|
|
551
|
+
return builder;
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Add a double precision column.
|
|
555
|
+
*
|
|
556
|
+
* @param column - Column name
|
|
557
|
+
* @returns Column builder for chaining modifiers
|
|
558
|
+
*/
|
|
559
|
+
double(column) {
|
|
560
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "double");
|
|
561
|
+
this.pendingOperations.push({
|
|
562
|
+
type: "addColumn",
|
|
563
|
+
payload: builder.getDefinition(),
|
|
564
|
+
});
|
|
565
|
+
return builder;
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Add a decimal column with precision and scale.
|
|
569
|
+
*
|
|
570
|
+
* @param column - Column name
|
|
571
|
+
* @param precision - Total digits (default: 8)
|
|
572
|
+
* @param scale - Decimal places (default: 2)
|
|
573
|
+
* @returns Column builder for chaining modifiers
|
|
574
|
+
*
|
|
575
|
+
* @example
|
|
576
|
+
* ```typescript
|
|
577
|
+
* this.decimal("price", 10, 2); // DECIMAL(10,2) - up to 99999999.99
|
|
578
|
+
* ```
|
|
579
|
+
*/
|
|
580
|
+
decimal(column, precision = 8, scale = 2) {
|
|
581
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "decimal", {
|
|
582
|
+
precision,
|
|
583
|
+
scale,
|
|
584
|
+
});
|
|
585
|
+
this.pendingOperations.push({
|
|
586
|
+
type: "addColumn",
|
|
587
|
+
payload: builder.getDefinition(),
|
|
588
|
+
});
|
|
589
|
+
return builder;
|
|
590
|
+
}
|
|
591
|
+
// ============================================================================
|
|
592
|
+
// COLUMN TYPES - BOOLEAN
|
|
593
|
+
// ============================================================================
|
|
594
|
+
/**
|
|
595
|
+
* Add a boolean column.
|
|
596
|
+
*
|
|
597
|
+
* @param column - Column name
|
|
598
|
+
* @returns Column builder for chaining modifiers
|
|
599
|
+
*/
|
|
600
|
+
boolean(column) {
|
|
601
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "boolean");
|
|
602
|
+
this.pendingOperations.push({
|
|
603
|
+
type: "addColumn",
|
|
604
|
+
payload: builder.getDefinition(),
|
|
605
|
+
});
|
|
606
|
+
return builder;
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* Alias for boolean().
|
|
610
|
+
*/
|
|
611
|
+
bool(column) {
|
|
612
|
+
return this.boolean(column);
|
|
613
|
+
}
|
|
614
|
+
// ============================================================================
|
|
615
|
+
// COLUMN TYPES - DATE/TIME
|
|
616
|
+
// ============================================================================
|
|
617
|
+
/**
|
|
618
|
+
* Add a date column (date only, no time).
|
|
619
|
+
*
|
|
620
|
+
* @param column - Column name
|
|
621
|
+
* @returns Column builder for chaining modifiers
|
|
622
|
+
*/
|
|
623
|
+
date(column) {
|
|
624
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "date");
|
|
625
|
+
this.pendingOperations.push({
|
|
626
|
+
type: "addColumn",
|
|
627
|
+
payload: builder.getDefinition(),
|
|
628
|
+
});
|
|
629
|
+
return builder;
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Add a datetime column (date and time).
|
|
633
|
+
*
|
|
634
|
+
* @param column - Column name
|
|
635
|
+
* @returns Column builder for chaining modifiers
|
|
636
|
+
*/
|
|
637
|
+
dateTime(column) {
|
|
638
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "dateTime");
|
|
639
|
+
this.pendingOperations.push({
|
|
640
|
+
type: "addColumn",
|
|
641
|
+
payload: builder.getDefinition(),
|
|
642
|
+
});
|
|
643
|
+
return builder;
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* Add a timestamp column.
|
|
647
|
+
*
|
|
648
|
+
* @param column - Column name
|
|
649
|
+
* @returns Column builder for chaining modifiers
|
|
650
|
+
*/
|
|
651
|
+
timestamp(column) {
|
|
652
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "timestamp");
|
|
653
|
+
this.pendingOperations.push({
|
|
654
|
+
type: "addColumn",
|
|
655
|
+
payload: builder.getDefinition(),
|
|
656
|
+
});
|
|
657
|
+
return builder;
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* Add a time column (time only, no date).
|
|
661
|
+
*
|
|
662
|
+
* @param column - Column name
|
|
663
|
+
* @returns Column builder for chaining modifiers
|
|
664
|
+
*/
|
|
665
|
+
time(column) {
|
|
666
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "time");
|
|
667
|
+
this.pendingOperations.push({
|
|
668
|
+
type: "addColumn",
|
|
669
|
+
payload: builder.getDefinition(),
|
|
670
|
+
});
|
|
671
|
+
return builder;
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* Add a year column.
|
|
675
|
+
*
|
|
676
|
+
* @param column - Column name
|
|
677
|
+
* @returns Column builder for chaining modifiers
|
|
678
|
+
*/
|
|
679
|
+
year(column) {
|
|
680
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "year");
|
|
681
|
+
this.pendingOperations.push({
|
|
682
|
+
type: "addColumn",
|
|
683
|
+
payload: builder.getDefinition(),
|
|
684
|
+
});
|
|
685
|
+
return builder;
|
|
686
|
+
}
|
|
687
|
+
// ============================================================================
|
|
688
|
+
// COLUMN TYPES - JSON & BINARY
|
|
689
|
+
// ============================================================================
|
|
690
|
+
/**
|
|
691
|
+
* Add a JSON column.
|
|
692
|
+
*
|
|
693
|
+
* @param column - Column name
|
|
694
|
+
* @returns Column builder for chaining modifiers
|
|
695
|
+
*/
|
|
696
|
+
json(column) {
|
|
697
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "json");
|
|
698
|
+
this.pendingOperations.push({
|
|
699
|
+
type: "addColumn",
|
|
700
|
+
payload: builder.getDefinition(),
|
|
701
|
+
});
|
|
702
|
+
return builder;
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Alias for json().
|
|
706
|
+
*/
|
|
707
|
+
object(column) {
|
|
708
|
+
return this.json(column);
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* Add a binary/blob column.
|
|
712
|
+
*
|
|
713
|
+
* @param column - Column name
|
|
714
|
+
* @returns Column builder for chaining modifiers
|
|
715
|
+
*/
|
|
716
|
+
binary(column) {
|
|
717
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "binary");
|
|
718
|
+
this.pendingOperations.push({
|
|
719
|
+
type: "addColumn",
|
|
720
|
+
payload: builder.getDefinition(),
|
|
721
|
+
});
|
|
722
|
+
return builder;
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* Alias for binary().
|
|
726
|
+
*/
|
|
727
|
+
blob(column) {
|
|
728
|
+
return this.binary(column);
|
|
729
|
+
}
|
|
730
|
+
// ============================================================================
|
|
731
|
+
// COLUMN TYPES - IDENTIFIERS
|
|
732
|
+
// ============================================================================
|
|
733
|
+
/**
|
|
734
|
+
* Add a UUID column.
|
|
735
|
+
*
|
|
736
|
+
* @param column - Column name
|
|
737
|
+
* @returns Column builder for chaining modifiers
|
|
738
|
+
*/
|
|
739
|
+
uuid(column) {
|
|
740
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "uuid");
|
|
741
|
+
this.pendingOperations.push({
|
|
742
|
+
type: "addColumn",
|
|
743
|
+
payload: builder.getDefinition(),
|
|
744
|
+
});
|
|
745
|
+
return builder;
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Add a ULID column.
|
|
749
|
+
*
|
|
750
|
+
* @param column - Column name
|
|
751
|
+
* @returns Column builder for chaining modifiers
|
|
752
|
+
*/
|
|
753
|
+
ulid(column) {
|
|
754
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "ulid");
|
|
755
|
+
this.pendingOperations.push({
|
|
756
|
+
type: "addColumn",
|
|
757
|
+
payload: builder.getDefinition(),
|
|
758
|
+
});
|
|
759
|
+
return builder;
|
|
760
|
+
}
|
|
761
|
+
// ============================================================================
|
|
762
|
+
// COLUMN TYPES - NETWORK
|
|
763
|
+
// ============================================================================
|
|
764
|
+
/**
|
|
765
|
+
* Add an IP address column.
|
|
766
|
+
*
|
|
767
|
+
* @param column - Column name
|
|
768
|
+
* @returns Column builder for chaining modifiers
|
|
769
|
+
*/
|
|
770
|
+
ipAddress(column) {
|
|
771
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "ipAddress");
|
|
772
|
+
this.pendingOperations.push({
|
|
773
|
+
type: "addColumn",
|
|
774
|
+
payload: builder.getDefinition(),
|
|
775
|
+
});
|
|
776
|
+
return builder;
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* Add a MAC address column.
|
|
780
|
+
*
|
|
781
|
+
* @param column - Column name
|
|
782
|
+
* @returns Column builder for chaining modifiers
|
|
783
|
+
*/
|
|
784
|
+
macAddress(column) {
|
|
785
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "macAddress");
|
|
786
|
+
this.pendingOperations.push({
|
|
787
|
+
type: "addColumn",
|
|
788
|
+
payload: builder.getDefinition(),
|
|
789
|
+
});
|
|
790
|
+
return builder;
|
|
791
|
+
}
|
|
792
|
+
// ============================================================================
|
|
793
|
+
// COLUMN TYPES - GEO & SPATIAL
|
|
794
|
+
// ============================================================================
|
|
795
|
+
/**
|
|
796
|
+
* Add a geo point column.
|
|
797
|
+
*
|
|
798
|
+
* @param column - Column name
|
|
799
|
+
* @returns Column builder for chaining modifiers
|
|
800
|
+
*/
|
|
801
|
+
point(column) {
|
|
802
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "point");
|
|
803
|
+
this.pendingOperations.push({
|
|
804
|
+
type: "addColumn",
|
|
805
|
+
payload: builder.getDefinition(),
|
|
806
|
+
});
|
|
807
|
+
return builder;
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* Add a polygon column.
|
|
811
|
+
*
|
|
812
|
+
* @param column - Column name
|
|
813
|
+
* @returns Column builder for chaining modifiers
|
|
814
|
+
*/
|
|
815
|
+
polygon(column) {
|
|
816
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "polygon");
|
|
817
|
+
this.pendingOperations.push({
|
|
818
|
+
type: "addColumn",
|
|
819
|
+
payload: builder.getDefinition(),
|
|
820
|
+
});
|
|
821
|
+
return builder;
|
|
822
|
+
}
|
|
823
|
+
/**
|
|
824
|
+
* Add a line string column.
|
|
825
|
+
*
|
|
826
|
+
* @param column - Column name
|
|
827
|
+
* @returns Column builder for chaining modifiers
|
|
828
|
+
*/
|
|
829
|
+
lineString(column) {
|
|
830
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "lineString");
|
|
831
|
+
this.pendingOperations.push({
|
|
832
|
+
type: "addColumn",
|
|
833
|
+
payload: builder.getDefinition(),
|
|
834
|
+
});
|
|
835
|
+
return builder;
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Add a generic geometry column.
|
|
839
|
+
*
|
|
840
|
+
* @param column - Column name
|
|
841
|
+
* @returns Column builder for chaining modifiers
|
|
842
|
+
*/
|
|
843
|
+
geometry(column) {
|
|
844
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "geometry");
|
|
845
|
+
this.pendingOperations.push({
|
|
846
|
+
type: "addColumn",
|
|
847
|
+
payload: builder.getDefinition(),
|
|
848
|
+
});
|
|
849
|
+
return builder;
|
|
850
|
+
}
|
|
851
|
+
// ============================================================================
|
|
852
|
+
// COLUMN TYPES - AI/ML
|
|
853
|
+
// ============================================================================
|
|
854
|
+
/**
|
|
855
|
+
* Add a vector column for AI embeddings.
|
|
856
|
+
*
|
|
857
|
+
* Used for storing and searching ML embeddings (e.g., OpenAI, Cohere).
|
|
858
|
+
*
|
|
859
|
+
* @param column - Column name
|
|
860
|
+
* @param dimensions - Vector dimensions (e.g., 1536 for OpenAI ada-002)
|
|
861
|
+
* @returns Column builder for chaining modifiers
|
|
862
|
+
*
|
|
863
|
+
* @example
|
|
864
|
+
* ```typescript
|
|
865
|
+
* this.vector("embedding", 1536); // OpenAI ada-002
|
|
866
|
+
* this.vector("embedding", 384); // Sentence Transformers
|
|
867
|
+
* ```
|
|
868
|
+
*/
|
|
869
|
+
vector(column, dimensions) {
|
|
870
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "vector", { dimensions });
|
|
871
|
+
this.pendingOperations.push({
|
|
872
|
+
type: "addColumn",
|
|
873
|
+
payload: builder.getDefinition(),
|
|
874
|
+
});
|
|
875
|
+
return builder;
|
|
876
|
+
}
|
|
877
|
+
// ============================================================================
|
|
878
|
+
// COLUMN TYPES - ENUM & SET
|
|
879
|
+
// ============================================================================
|
|
880
|
+
/**
|
|
881
|
+
* Add an enum column with allowed values.
|
|
882
|
+
*
|
|
883
|
+
* @param column - Column name
|
|
884
|
+
* @param values - Allowed enum values
|
|
885
|
+
* @returns Column builder for chaining modifiers
|
|
886
|
+
*
|
|
887
|
+
* @example
|
|
888
|
+
* ```typescript
|
|
889
|
+
* this.enum("status", ["pending", "active", "archived"]);
|
|
890
|
+
* ```
|
|
891
|
+
*/
|
|
892
|
+
enum(column, values) {
|
|
893
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "enum", { values });
|
|
894
|
+
this.pendingOperations.push({
|
|
895
|
+
type: "addColumn",
|
|
896
|
+
payload: builder.getDefinition(),
|
|
897
|
+
});
|
|
898
|
+
return builder;
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* Add a set column (multiple values from a set).
|
|
902
|
+
*
|
|
903
|
+
* @param column - Column name
|
|
904
|
+
* @param values - Allowed set values
|
|
905
|
+
* @returns Column builder for chaining modifiers
|
|
906
|
+
*/
|
|
907
|
+
set(column, values) {
|
|
908
|
+
const builder = new columnBuilder.ColumnBuilder(this, column, "set", { values });
|
|
909
|
+
this.pendingOperations.push({
|
|
910
|
+
type: "addColumn",
|
|
911
|
+
payload: builder.getDefinition(),
|
|
912
|
+
});
|
|
913
|
+
return builder;
|
|
914
|
+
}
|
|
915
|
+
// ============================================================================
|
|
916
|
+
// SHORTCUTS
|
|
917
|
+
// ============================================================================
|
|
918
|
+
/**
|
|
919
|
+
* Add an auto-increment primary key column.
|
|
920
|
+
*
|
|
921
|
+
* Creates an unsigned integer with primary key and auto-increment.
|
|
922
|
+
*
|
|
923
|
+
* @param name - Column name (default: "id")
|
|
924
|
+
* @returns Column builder for chaining modifiers
|
|
925
|
+
*
|
|
926
|
+
* @example
|
|
927
|
+
* ```typescript
|
|
928
|
+
* this.id(); // Creates "id" column
|
|
929
|
+
* this.id("userId"); // Creates "userId" column
|
|
930
|
+
* ```
|
|
931
|
+
*/
|
|
932
|
+
id(name = "id") {
|
|
933
|
+
return this.integer(name).primary().autoIncrement().unsigned();
|
|
934
|
+
}
|
|
935
|
+
/**
|
|
936
|
+
* Add a big integer auto-increment primary key column.
|
|
937
|
+
*
|
|
938
|
+
* @param name - Column name (default: "id")
|
|
939
|
+
* @returns Column builder for chaining modifiers
|
|
940
|
+
*/
|
|
941
|
+
bigId(name = "id") {
|
|
942
|
+
return this.bigInteger(name).primary().autoIncrement().unsigned();
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* Add a UUID primary key column.
|
|
946
|
+
*
|
|
947
|
+
* @param name - Column name (default: "id")
|
|
948
|
+
* @returns Column builder for chaining modifiers
|
|
949
|
+
*/
|
|
950
|
+
uuidId(name = "id") {
|
|
951
|
+
return this.uuid(name).primary();
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* Add createdAt and updatedAt timestamp columns.
|
|
955
|
+
*
|
|
956
|
+
* @returns This migration for chaining
|
|
957
|
+
*
|
|
958
|
+
* @example
|
|
959
|
+
* ```typescript
|
|
960
|
+
* this.timestamps(); // Creates createdAt and updatedAt
|
|
961
|
+
* ```
|
|
962
|
+
*/
|
|
963
|
+
timestamps() {
|
|
964
|
+
this.dateTime("createdAt");
|
|
965
|
+
this.dateTime("updatedAt");
|
|
966
|
+
return this;
|
|
967
|
+
}
|
|
968
|
+
/**
|
|
969
|
+
* Add a deletedAt column for soft deletes.
|
|
970
|
+
*
|
|
971
|
+
* @param column - Column name (default: "deletedAt")
|
|
972
|
+
* @returns Column builder for chaining modifiers
|
|
973
|
+
*/
|
|
974
|
+
softDeletes(column = "deletedAt") {
|
|
975
|
+
return this.dateTime(column).nullable();
|
|
976
|
+
}
|
|
977
|
+
// ============================================================================
|
|
978
|
+
// DROP COLUMN OPERATIONS
|
|
979
|
+
// ============================================================================
|
|
980
|
+
/**
|
|
981
|
+
* Drop a column.
|
|
982
|
+
*
|
|
983
|
+
* @param column - Column name to drop
|
|
984
|
+
* @returns This migration for chaining
|
|
985
|
+
*/
|
|
986
|
+
dropColumn(column) {
|
|
987
|
+
this.pendingOperations.push({ type: "dropColumn", payload: column });
|
|
988
|
+
return this;
|
|
989
|
+
}
|
|
990
|
+
/**
|
|
991
|
+
* Drop multiple columns.
|
|
992
|
+
*
|
|
993
|
+
* @param columns - Column names to drop
|
|
994
|
+
* @returns This migration for chaining
|
|
995
|
+
*/
|
|
996
|
+
dropColumns(...columns) {
|
|
997
|
+
this.pendingOperations.push({ type: "dropColumns", payload: columns });
|
|
998
|
+
return this;
|
|
999
|
+
}
|
|
1000
|
+
/**
|
|
1001
|
+
* Rename a column.
|
|
1002
|
+
*
|
|
1003
|
+
* @param from - Current column name
|
|
1004
|
+
* @param to - New column name
|
|
1005
|
+
* @returns This migration for chaining
|
|
1006
|
+
*/
|
|
1007
|
+
renameColumn(from, to) {
|
|
1008
|
+
this.pendingOperations.push({
|
|
1009
|
+
type: "renameColumn",
|
|
1010
|
+
payload: { from, to },
|
|
1011
|
+
});
|
|
1012
|
+
return this;
|
|
1013
|
+
}
|
|
1014
|
+
// ============================================================================
|
|
1015
|
+
// INDEX OPERATIONS
|
|
1016
|
+
// ============================================================================
|
|
1017
|
+
/**
|
|
1018
|
+
* Create an index on one or more columns.
|
|
1019
|
+
*
|
|
1020
|
+
* @param columns - Column(s) to index
|
|
1021
|
+
* @param name - Optional index name
|
|
1022
|
+
* @returns This migration for chaining
|
|
1023
|
+
*
|
|
1024
|
+
* @example
|
|
1025
|
+
* ```typescript
|
|
1026
|
+
* this.index("email");
|
|
1027
|
+
* this.index(["firstName", "lastName"], "name_idx");
|
|
1028
|
+
* ```
|
|
1029
|
+
*/
|
|
1030
|
+
index(columns, name) {
|
|
1031
|
+
const cols = Array.isArray(columns) ? columns : [columns];
|
|
1032
|
+
this.pendingOperations.push({
|
|
1033
|
+
type: "createIndex",
|
|
1034
|
+
payload: { columns: cols, name },
|
|
1035
|
+
});
|
|
1036
|
+
return this;
|
|
1037
|
+
}
|
|
1038
|
+
/**
|
|
1039
|
+
* Drop an index by name or columns.
|
|
1040
|
+
*
|
|
1041
|
+
* @param nameOrColumns - Index name (string) or columns array
|
|
1042
|
+
* @returns This migration for chaining
|
|
1043
|
+
*
|
|
1044
|
+
* @example
|
|
1045
|
+
* ```typescript
|
|
1046
|
+
* this.dropIndex("email_idx"); // Drop by name
|
|
1047
|
+
* this.dropIndex(["firstName", "lastName"]); // Drop by columns
|
|
1048
|
+
* ```
|
|
1049
|
+
*/
|
|
1050
|
+
dropIndex(nameOrColumns) {
|
|
1051
|
+
this.pendingOperations.push({
|
|
1052
|
+
type: "dropIndex",
|
|
1053
|
+
payload: nameOrColumns,
|
|
1054
|
+
});
|
|
1055
|
+
return this;
|
|
1056
|
+
}
|
|
1057
|
+
/**
|
|
1058
|
+
* Create a unique constraint/index.
|
|
1059
|
+
*
|
|
1060
|
+
* @param columns - Column(s) to make unique
|
|
1061
|
+
* @param name - Optional constraint name
|
|
1062
|
+
* @returns This migration for chaining
|
|
1063
|
+
*/
|
|
1064
|
+
unique(columns, name) {
|
|
1065
|
+
const cols = Array.isArray(columns) ? columns : [columns];
|
|
1066
|
+
this.pendingOperations.push({
|
|
1067
|
+
type: "createUniqueIndex",
|
|
1068
|
+
payload: { columns: cols, name },
|
|
1069
|
+
});
|
|
1070
|
+
return this;
|
|
1071
|
+
}
|
|
1072
|
+
/**
|
|
1073
|
+
* Drop a unique constraint/index.
|
|
1074
|
+
*
|
|
1075
|
+
* @param columns - Columns in the unique constraint
|
|
1076
|
+
* @returns This migration for chaining
|
|
1077
|
+
*/
|
|
1078
|
+
dropUnique(columns) {
|
|
1079
|
+
const cols = Array.isArray(columns) ? columns : [columns];
|
|
1080
|
+
this.pendingOperations.push({ type: "dropUniqueIndex", payload: cols });
|
|
1081
|
+
return this;
|
|
1082
|
+
}
|
|
1083
|
+
// ============================================================================
|
|
1084
|
+
// FULL-TEXT INDEX
|
|
1085
|
+
// ============================================================================
|
|
1086
|
+
/**
|
|
1087
|
+
* Create a full-text search index.
|
|
1088
|
+
*
|
|
1089
|
+
* @param columns - Column(s) to index
|
|
1090
|
+
* @param options - Full-text options
|
|
1091
|
+
* @returns This migration for chaining
|
|
1092
|
+
*/
|
|
1093
|
+
fullText(columns, options) {
|
|
1094
|
+
const cols = Array.isArray(columns) ? columns : [columns];
|
|
1095
|
+
this.pendingOperations.push({
|
|
1096
|
+
type: "createFullTextIndex",
|
|
1097
|
+
payload: { columns: cols, options },
|
|
1098
|
+
});
|
|
1099
|
+
return this;
|
|
1100
|
+
}
|
|
1101
|
+
/**
|
|
1102
|
+
* Drop a full-text search index.
|
|
1103
|
+
*
|
|
1104
|
+
* @param name - Index name
|
|
1105
|
+
* @returns This migration for chaining
|
|
1106
|
+
*/
|
|
1107
|
+
dropFullText(name) {
|
|
1108
|
+
this.pendingOperations.push({ type: "dropFullTextIndex", payload: name });
|
|
1109
|
+
return this;
|
|
1110
|
+
}
|
|
1111
|
+
// ============================================================================
|
|
1112
|
+
// GEO INDEX
|
|
1113
|
+
// ============================================================================
|
|
1114
|
+
/**
|
|
1115
|
+
* Create a geo-spatial index.
|
|
1116
|
+
*
|
|
1117
|
+
* @param column - Geo column
|
|
1118
|
+
* @param options - Geo index options
|
|
1119
|
+
* @returns This migration for chaining
|
|
1120
|
+
*
|
|
1121
|
+
* @example
|
|
1122
|
+
* ```typescript
|
|
1123
|
+
* this.geoIndex("location"); // 2dsphere index
|
|
1124
|
+
* this.geoIndex("coordinates", { type: "2d" }); // 2d index
|
|
1125
|
+
* ```
|
|
1126
|
+
*/
|
|
1127
|
+
geoIndex(column, options) {
|
|
1128
|
+
this.pendingOperations.push({
|
|
1129
|
+
type: "createGeoIndex",
|
|
1130
|
+
payload: { column, options },
|
|
1131
|
+
});
|
|
1132
|
+
return this;
|
|
1133
|
+
}
|
|
1134
|
+
/**
|
|
1135
|
+
* Drop a geo-spatial index.
|
|
1136
|
+
*
|
|
1137
|
+
* @param column - Geo column
|
|
1138
|
+
* @returns This migration for chaining
|
|
1139
|
+
*/
|
|
1140
|
+
dropGeoIndex(column) {
|
|
1141
|
+
this.pendingOperations.push({ type: "dropGeoIndex", payload: column });
|
|
1142
|
+
return this;
|
|
1143
|
+
}
|
|
1144
|
+
// ============================================================================
|
|
1145
|
+
// VECTOR INDEX
|
|
1146
|
+
// ============================================================================
|
|
1147
|
+
/**
|
|
1148
|
+
* Create a vector search index for AI embeddings.
|
|
1149
|
+
*
|
|
1150
|
+
* @param column - Vector column
|
|
1151
|
+
* @param options - Vector index options
|
|
1152
|
+
* @returns This migration for chaining
|
|
1153
|
+
*
|
|
1154
|
+
* @example
|
|
1155
|
+
* ```typescript
|
|
1156
|
+
* this.vectorIndex("embedding", {
|
|
1157
|
+
* dimensions: 1536,
|
|
1158
|
+
* similarity: "cosine",
|
|
1159
|
+
* });
|
|
1160
|
+
* ```
|
|
1161
|
+
*/
|
|
1162
|
+
vectorIndex(column, options) {
|
|
1163
|
+
this.pendingOperations.push({
|
|
1164
|
+
type: "createVectorIndex",
|
|
1165
|
+
payload: { column, options },
|
|
1166
|
+
});
|
|
1167
|
+
return this;
|
|
1168
|
+
}
|
|
1169
|
+
/**
|
|
1170
|
+
* Drop a vector search index.
|
|
1171
|
+
*
|
|
1172
|
+
* @param column - Vector column
|
|
1173
|
+
* @returns This migration for chaining
|
|
1174
|
+
*/
|
|
1175
|
+
dropVectorIndex(column) {
|
|
1176
|
+
this.pendingOperations.push({ type: "dropVectorIndex", payload: column });
|
|
1177
|
+
return this;
|
|
1178
|
+
}
|
|
1179
|
+
// ============================================================================
|
|
1180
|
+
// TTL INDEX
|
|
1181
|
+
// ============================================================================
|
|
1182
|
+
/**
|
|
1183
|
+
* Create a TTL (time-to-live) index for automatic document expiration.
|
|
1184
|
+
*
|
|
1185
|
+
* Primarily for MongoDB. Documents are automatically deleted after the
|
|
1186
|
+
* specified time has passed since the date in the column.
|
|
1187
|
+
*
|
|
1188
|
+
* @param column - Date column to check for expiration
|
|
1189
|
+
* @param expireAfterSeconds - Seconds after which documents expire
|
|
1190
|
+
* @returns This migration for chaining
|
|
1191
|
+
*
|
|
1192
|
+
* @example
|
|
1193
|
+
* ```typescript
|
|
1194
|
+
* // Delete sessions 24 hours after createdAt
|
|
1195
|
+
* this.ttlIndex("createdAt", 86400);
|
|
1196
|
+
* ```
|
|
1197
|
+
*/
|
|
1198
|
+
ttlIndex(column, expireAfterSeconds) {
|
|
1199
|
+
this.pendingOperations.push({
|
|
1200
|
+
type: "createTTLIndex",
|
|
1201
|
+
payload: { column, seconds: expireAfterSeconds },
|
|
1202
|
+
});
|
|
1203
|
+
return this;
|
|
1204
|
+
}
|
|
1205
|
+
/**
|
|
1206
|
+
* Drop a TTL index.
|
|
1207
|
+
*
|
|
1208
|
+
* @param column - Column with TTL
|
|
1209
|
+
* @returns This migration for chaining
|
|
1210
|
+
*/
|
|
1211
|
+
dropTTLIndex(column) {
|
|
1212
|
+
this.pendingOperations.push({ type: "dropTTLIndex", payload: column });
|
|
1213
|
+
return this;
|
|
1214
|
+
}
|
|
1215
|
+
// ============================================================================
|
|
1216
|
+
// PRIMARY KEY
|
|
1217
|
+
// ============================================================================
|
|
1218
|
+
/**
|
|
1219
|
+
* Add a composite primary key.
|
|
1220
|
+
*
|
|
1221
|
+
* @param columns - Columns to include in the primary key
|
|
1222
|
+
* @returns This migration for chaining
|
|
1223
|
+
*/
|
|
1224
|
+
primaryKey(columns) {
|
|
1225
|
+
this.pendingOperations.push({ type: "addPrimaryKey", payload: columns });
|
|
1226
|
+
return this;
|
|
1227
|
+
}
|
|
1228
|
+
/**
|
|
1229
|
+
* Drop the primary key constraint.
|
|
1230
|
+
*
|
|
1231
|
+
* @returns This migration for chaining
|
|
1232
|
+
*/
|
|
1233
|
+
dropPrimaryKey() {
|
|
1234
|
+
this.pendingOperations.push({ type: "dropPrimaryKey", payload: null });
|
|
1235
|
+
return this;
|
|
1236
|
+
}
|
|
1237
|
+
// ============================================================================
|
|
1238
|
+
// FOREIGN KEYS (SQL)
|
|
1239
|
+
// ============================================================================
|
|
1240
|
+
/**
|
|
1241
|
+
* Start building a foreign key constraint.
|
|
1242
|
+
*
|
|
1243
|
+
* SQL-only feature; NoSQL drivers ignore foreign keys.
|
|
1244
|
+
*
|
|
1245
|
+
* @param column - Local column that references another table
|
|
1246
|
+
* @returns Foreign key builder for chaining
|
|
1247
|
+
*
|
|
1248
|
+
* @example
|
|
1249
|
+
* ```typescript
|
|
1250
|
+
* this.foreign("user_id")
|
|
1251
|
+
* .references("users", "id")
|
|
1252
|
+
* .onDelete("cascade")
|
|
1253
|
+
* .add();
|
|
1254
|
+
* ```
|
|
1255
|
+
*/
|
|
1256
|
+
foreign(column) {
|
|
1257
|
+
return new foreignKeyBuilder.ForeignKeyBuilder(this, column);
|
|
1258
|
+
}
|
|
1259
|
+
/**
|
|
1260
|
+
* Drop a foreign key constraint by name.
|
|
1261
|
+
*
|
|
1262
|
+
* @param name - Constraint name
|
|
1263
|
+
* @returns This migration for chaining
|
|
1264
|
+
*/
|
|
1265
|
+
dropForeign(name) {
|
|
1266
|
+
this.pendingOperations.push({ type: "dropForeignKey", payload: name });
|
|
1267
|
+
return this;
|
|
1268
|
+
}
|
|
1269
|
+
// ============================================================================
|
|
1270
|
+
// SCHEMA VALIDATION (NoSQL)
|
|
1271
|
+
// ============================================================================
|
|
1272
|
+
/**
|
|
1273
|
+
* Set JSON schema validation rules on the collection.
|
|
1274
|
+
*
|
|
1275
|
+
* MongoDB-only feature. SQL databases ignore this.
|
|
1276
|
+
*
|
|
1277
|
+
* @param schema - JSON Schema object
|
|
1278
|
+
* @returns This migration for chaining
|
|
1279
|
+
*
|
|
1280
|
+
* @example
|
|
1281
|
+
* ```typescript
|
|
1282
|
+
* this.schemaValidation({
|
|
1283
|
+
* bsonType: "object",
|
|
1284
|
+
* required: ["name", "email"],
|
|
1285
|
+
* properties: {
|
|
1286
|
+
* name: { bsonType: "string" },
|
|
1287
|
+
* email: { bsonType: "string" },
|
|
1288
|
+
* },
|
|
1289
|
+
* });
|
|
1290
|
+
* ```
|
|
1291
|
+
*/
|
|
1292
|
+
schemaValidation(schema) {
|
|
1293
|
+
this.pendingOperations.push({
|
|
1294
|
+
type: "setSchemaValidation",
|
|
1295
|
+
payload: schema,
|
|
1296
|
+
});
|
|
1297
|
+
return this;
|
|
1298
|
+
}
|
|
1299
|
+
/**
|
|
1300
|
+
* Remove schema validation rules from the collection.
|
|
1301
|
+
*
|
|
1302
|
+
* @returns This migration for chaining
|
|
1303
|
+
*/
|
|
1304
|
+
dropSchemaValidation() {
|
|
1305
|
+
this.pendingOperations.push({
|
|
1306
|
+
type: "removeSchemaValidation",
|
|
1307
|
+
payload: null,
|
|
1308
|
+
});
|
|
1309
|
+
return this;
|
|
1310
|
+
}
|
|
1311
|
+
// ============================================================================
|
|
1312
|
+
// RAW ACCESS
|
|
1313
|
+
// ============================================================================
|
|
1314
|
+
/**
|
|
1315
|
+
* Execute raw operations with direct driver access.
|
|
1316
|
+
*
|
|
1317
|
+
* Use this for database-specific operations not covered by the API.
|
|
1318
|
+
*
|
|
1319
|
+
* @param callback - Callback receiving the native connection
|
|
1320
|
+
* @returns Result from callback
|
|
1321
|
+
*
|
|
1322
|
+
* @example
|
|
1323
|
+
* ```typescript
|
|
1324
|
+
* await this.raw(async (db) => {
|
|
1325
|
+
* await db.collection("users").updateMany({}, { $set: { active: true } });
|
|
1326
|
+
* });
|
|
1327
|
+
* ```
|
|
1328
|
+
*/
|
|
1329
|
+
async raw(callback) {
|
|
1330
|
+
return this.driver.raw(callback);
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
function migrate(model, options) {
|
|
1334
|
+
return class AnonymousMigration extends Migration {
|
|
1335
|
+
static migrationName = options?.name;
|
|
1336
|
+
static createdAt = options?.createdAt;
|
|
1337
|
+
table = model.table;
|
|
1338
|
+
static transactional = options?.transactional;
|
|
1339
|
+
async up() {
|
|
1340
|
+
options?.up?.call(this);
|
|
1341
|
+
}
|
|
1342
|
+
async down() {
|
|
1343
|
+
options?.down?.call(this);
|
|
1344
|
+
}
|
|
1345
|
+
};
|
|
1346
|
+
}exports.Migration=Migration;exports.migrate=migrate;//# sourceMappingURL=migration.js.map
|