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