@warlock.js/cascade 4.0.141 → 4.0.142
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.js +1 -1
- package/cjs/migration/column-builder.d.ts +14 -4
- package/cjs/migration/column-builder.d.ts.map +1 -1
- package/cjs/migration/column-builder.js +14 -5
- package/cjs/migration/column-builder.js.map +1 -1
- package/cjs/migration/column-helpers.d.ts +269 -0
- package/cjs/migration/column-helpers.d.ts.map +1 -0
- package/cjs/migration/column-helpers.js +384 -0
- package/cjs/migration/column-helpers.js.map +1 -0
- package/cjs/migration/index.d.ts +1 -0
- package/cjs/migration/index.d.ts.map +1 -1
- package/cjs/migration/migration.d.ts +302 -1
- package/cjs/migration/migration.d.ts.map +1 -1
- package/cjs/migration/migration.js +302 -1
- package/cjs/migration/migration.js.map +1 -1
- package/cjs/types.d.ts +23 -0
- package/cjs/types.d.ts.map +1 -1
- package/cjs/writer/database-writer.js +4 -4
- package/cjs/writer/database-writer.js.map +1 -1
- package/esm/index.js +1 -1
- package/esm/migration/column-builder.d.ts +14 -4
- package/esm/migration/column-builder.d.ts.map +1 -1
- package/esm/migration/column-builder.js +14 -5
- package/esm/migration/column-builder.js.map +1 -1
- package/esm/migration/column-helpers.d.ts +269 -0
- package/esm/migration/column-helpers.d.ts.map +1 -0
- package/esm/migration/column-helpers.js +384 -0
- package/esm/migration/column-helpers.js.map +1 -0
- package/esm/migration/index.d.ts +1 -0
- package/esm/migration/index.d.ts.map +1 -1
- package/esm/migration/migration.d.ts +302 -1
- package/esm/migration/migration.d.ts.map +1 -1
- package/esm/migration/migration.js +302 -1
- package/esm/migration/migration.js.map +1 -1
- package/esm/types.d.ts +23 -0
- package/esm/types.d.ts.map +1 -1
- package/esm/writer/database-writer.js +4 -4
- package/esm/writer/database-writer.js.map +1 -1
- package/package.json +4 -4
package/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var databaseDataSourceContext=require('./context/database-data-source-context.js'),databaseTransactionContext=require('./context/database-transaction-context.js'),dataSource=require('./data-source/data-source.js'),dataSourceRegistry=require('./data-source/data-source-registry.js'),missingDataSource_error=require('./errors/missing-data-source.error.js'),transactionRollback_error=require('./errors/transaction-rollback.error.js'),databaseDirtyTracker=require('./database-dirty-tracker.js'),modelEvents=require('./events/model-events.js'),model=require('./model/model.js'),registerModel=require('./model/register-model.js'),databaseRemover=require('./remover/database-remover.js'),databaseRestorer=require('./restorer/database-restorer.js'),databaseWriterValidationError=require('./validation/database-writer-validation-error.js');require('./validation/database-seal-plugins.js');var databaseWriter=require('./writer/database-writer.js'),helpers=require('./relations/helpers.js'),relationLoader=require('./relations/relation-loader.js'),relationHydrator=require('./relations/relation-hydrator.js'),pivotOperations=require('./relations/pivot-operations.js'),aggregateExpressions=require('./expressions/aggregate-expressions.js'),mongodbDriver=require('./drivers/mongodb/mongodb-driver.js'),mongodbIdGenerator=require('./drivers/mongodb/mongodb-id-generator.js'),mongodbQueryBuilder=require('./drivers/mongodb/mongodb-query-builder.js'),mongodbSyncAdapter=require('./drivers/mongodb/mongodb-sync-adapter.js'),modelSync=require('./sync/model-sync.js'),modelSyncOperation=require('./sync/model-sync-operation.js'),syncContext=require('./sync/sync-context.js'),syncManager=require('./sync/sync-manager.js'),connectToDatabase=require('./utils/connect-to-database.js'),databaseWriter_utils=require('./utils/database-writer.utils.js'),defineModel=require('./utils/define-model.js'),onceConnected=require('./utils/once-connected.js'),columnBuilder=require('./migration/column-builder.js'),foreignKeyBuilder=require('./migration/foreign-key-builder.js'),migration=require('./migration/migration.js'),migrationRunner=require('./migration/migration-runner.js'),mongodbMigrationDriver=require('./drivers/mongodb/mongodb-migration-driver.js'),postgresBlueprint=require('./drivers/postgres/postgres-blueprint.js'),postgresDialect=require('./drivers/postgres/postgres-dialect.js'),postgresDriver=require('./drivers/postgres/postgres-driver.js'),postgresMigrationDriver=require('./drivers/postgres/postgres-migration-driver.js'),postgresQueryBuilder=require('./drivers/postgres/postgres-query-builder.js'),postgresQueryParser=require('./drivers/postgres/postgres-query-parser.js'),postgresSyncAdapter=require('./drivers/postgres/postgres-sync-adapter.js');exports.databaseDataSourceContext=databaseDataSourceContext.databaseDataSourceContext;exports.databaseTransactionContext=databaseTransactionContext.databaseTransactionContext;exports.DataSource=dataSource.DataSource;exports.dataSourceRegistry=dataSourceRegistry.dataSourceRegistry;exports.MissingDataSourceError=missingDataSource_error.MissingDataSourceError;exports.TransactionRollbackError=transactionRollback_error.TransactionRollbackError;exports.DatabaseDirtyTracker=databaseDirtyTracker.DatabaseDirtyTracker;exports.ModelEvents=modelEvents.ModelEvents;exports.globalModelEvents=modelEvents.globalModelEvents;exports.Model=model.Model;exports.RegisterModel=registerModel.RegisterModel;exports.cleanupModelsRegistery=registerModel.cleanupModelsRegistery;exports.getAllModelsFromRegistry=registerModel.getAllModelsFromRegistry;exports.getModelFromRegistry=registerModel.getModelFromRegistry;exports.registerModelInRegistry=registerModel.registerModelInRegistry;exports.removeModelFromRegistery=registerModel.removeModelFromRegistery;exports.resolveModelClass=registerModel.resolveModelClass;exports.DatabaseRemover=databaseRemover.DatabaseRemover;exports.DatabaseRestorer=databaseRestorer.DatabaseRestorer;exports.DatabaseWriterValidationError=databaseWriterValidationError.DatabaseWriterValidationError;exports.DatabaseWriter=databaseWriter.DatabaseWriter;exports.belongsTo=helpers.belongsTo;exports.belongsToMany=helpers.belongsToMany;exports.hasMany=helpers.hasMany;exports.hasOne=helpers.hasOne;exports.RelationLoader=relationLoader.RelationLoader;exports.RelationHydrator=relationHydrator.RelationHydrator;exports.PivotOperations=pivotOperations.PivotOperations;exports.createPivotOperations=pivotOperations.createPivotOperations;exports.$agg=aggregateExpressions.$agg;exports.isAggregateExpression=aggregateExpressions.isAggregateExpression;exports.MongoDbDriver=mongodbDriver.MongoDbDriver;exports.isMongoDBDriverLoaded=mongodbDriver.isMongoDBDriverLoaded;exports.MongoIdGenerator=mongodbIdGenerator.MongoIdGenerator;exports.MongoQueryBuilder=mongodbQueryBuilder.MongoQueryBuilder;exports.MongoSyncAdapter=mongodbSyncAdapter.MongoSyncAdapter;exports.modelSync=modelSync.modelSync;exports.ModelSyncOperation=modelSyncOperation.ModelSyncOperation;exports.DEFAULT_MAX_SYNC_DEPTH=syncContext.DEFAULT_MAX_SYNC_DEPTH;exports.SyncContextManager=syncContext.SyncContextManager;exports.SyncManager=syncManager.SyncManager;exports.connectToDatabase=connectToDatabase.connectToDatabase;exports.getDatabaseDriver=connectToDatabase.getDatabaseDriver;exports.transaction=connectToDatabase.transaction;exports.useModelTransformer=databaseWriter_utils.useModelTransformer;exports.defineModel=defineModel.defineModel;exports.onceConnected=onceConnected.onceConnected;exports.onceDisconnected=onceConnected.onceDisconnected;exports.ColumnBuilder=columnBuilder.ColumnBuilder;exports.ForeignKeyBuilder=foreignKeyBuilder.ForeignKeyBuilder;exports.Migration=migration.Migration;exports.migrate=migration.migrate;exports.MigrationRunner=migrationRunner.MigrationRunner;exports.migrationRunner=migrationRunner.migrationRunner;exports.MongoMigrationDriver=mongodbMigrationDriver.MongoMigrationDriver;exports.PostgresBlueprint=postgresBlueprint.PostgresBlueprint;exports.PostgresDialect=postgresDialect.PostgresDialect;exports.PostgresDriver=postgresDriver.PostgresDriver;exports.PostgresMigrationDriver=postgresMigrationDriver.PostgresMigrationDriver;exports.PostgresQueryBuilder=postgresQueryBuilder.PostgresQueryBuilder;exports.PostgresQueryParser=postgresQueryParser.PostgresQueryParser;exports.PostgresSyncAdapter=postgresSyncAdapter.PostgresSyncAdapter;//# sourceMappingURL=index.js.map
|
|
1
|
+
'use strict';var databaseDataSourceContext=require('./context/database-data-source-context.js'),databaseTransactionContext=require('./context/database-transaction-context.js'),dataSource=require('./data-source/data-source.js'),dataSourceRegistry=require('./data-source/data-source-registry.js'),missingDataSource_error=require('./errors/missing-data-source.error.js'),transactionRollback_error=require('./errors/transaction-rollback.error.js'),databaseDirtyTracker=require('./database-dirty-tracker.js'),modelEvents=require('./events/model-events.js'),model=require('./model/model.js'),registerModel=require('./model/register-model.js'),databaseRemover=require('./remover/database-remover.js'),databaseRestorer=require('./restorer/database-restorer.js'),databaseWriterValidationError=require('./validation/database-writer-validation-error.js');require('./validation/database-seal-plugins.js');var databaseWriter=require('./writer/database-writer.js'),helpers=require('./relations/helpers.js'),relationLoader=require('./relations/relation-loader.js'),relationHydrator=require('./relations/relation-hydrator.js'),pivotOperations=require('./relations/pivot-operations.js'),aggregateExpressions=require('./expressions/aggregate-expressions.js'),mongodbDriver=require('./drivers/mongodb/mongodb-driver.js'),mongodbIdGenerator=require('./drivers/mongodb/mongodb-id-generator.js'),mongodbQueryBuilder=require('./drivers/mongodb/mongodb-query-builder.js'),mongodbSyncAdapter=require('./drivers/mongodb/mongodb-sync-adapter.js'),modelSync=require('./sync/model-sync.js'),modelSyncOperation=require('./sync/model-sync-operation.js'),syncContext=require('./sync/sync-context.js'),syncManager=require('./sync/sync-manager.js'),connectToDatabase=require('./utils/connect-to-database.js'),databaseWriter_utils=require('./utils/database-writer.utils.js'),defineModel=require('./utils/define-model.js'),onceConnected=require('./utils/once-connected.js'),columnBuilder=require('./migration/column-builder.js'),foreignKeyBuilder=require('./migration/foreign-key-builder.js'),columnHelpers=require('./migration/column-helpers.js'),migration=require('./migration/migration.js'),migrationRunner=require('./migration/migration-runner.js'),mongodbMigrationDriver=require('./drivers/mongodb/mongodb-migration-driver.js'),postgresBlueprint=require('./drivers/postgres/postgres-blueprint.js'),postgresDialect=require('./drivers/postgres/postgres-dialect.js'),postgresDriver=require('./drivers/postgres/postgres-driver.js'),postgresMigrationDriver=require('./drivers/postgres/postgres-migration-driver.js'),postgresQueryBuilder=require('./drivers/postgres/postgres-query-builder.js'),postgresQueryParser=require('./drivers/postgres/postgres-query-parser.js'),postgresSyncAdapter=require('./drivers/postgres/postgres-sync-adapter.js');exports.databaseDataSourceContext=databaseDataSourceContext.databaseDataSourceContext;exports.databaseTransactionContext=databaseTransactionContext.databaseTransactionContext;exports.DataSource=dataSource.DataSource;exports.dataSourceRegistry=dataSourceRegistry.dataSourceRegistry;exports.MissingDataSourceError=missingDataSource_error.MissingDataSourceError;exports.TransactionRollbackError=transactionRollback_error.TransactionRollbackError;exports.DatabaseDirtyTracker=databaseDirtyTracker.DatabaseDirtyTracker;exports.ModelEvents=modelEvents.ModelEvents;exports.globalModelEvents=modelEvents.globalModelEvents;exports.Model=model.Model;exports.RegisterModel=registerModel.RegisterModel;exports.cleanupModelsRegistery=registerModel.cleanupModelsRegistery;exports.getAllModelsFromRegistry=registerModel.getAllModelsFromRegistry;exports.getModelFromRegistry=registerModel.getModelFromRegistry;exports.registerModelInRegistry=registerModel.registerModelInRegistry;exports.removeModelFromRegistery=registerModel.removeModelFromRegistery;exports.resolveModelClass=registerModel.resolveModelClass;exports.DatabaseRemover=databaseRemover.DatabaseRemover;exports.DatabaseRestorer=databaseRestorer.DatabaseRestorer;exports.DatabaseWriterValidationError=databaseWriterValidationError.DatabaseWriterValidationError;exports.DatabaseWriter=databaseWriter.DatabaseWriter;exports.belongsTo=helpers.belongsTo;exports.belongsToMany=helpers.belongsToMany;exports.hasMany=helpers.hasMany;exports.hasOne=helpers.hasOne;exports.RelationLoader=relationLoader.RelationLoader;exports.RelationHydrator=relationHydrator.RelationHydrator;exports.PivotOperations=pivotOperations.PivotOperations;exports.createPivotOperations=pivotOperations.createPivotOperations;exports.$agg=aggregateExpressions.$agg;exports.isAggregateExpression=aggregateExpressions.isAggregateExpression;exports.MongoDbDriver=mongodbDriver.MongoDbDriver;exports.isMongoDBDriverLoaded=mongodbDriver.isMongoDBDriverLoaded;exports.MongoIdGenerator=mongodbIdGenerator.MongoIdGenerator;exports.MongoQueryBuilder=mongodbQueryBuilder.MongoQueryBuilder;exports.MongoSyncAdapter=mongodbSyncAdapter.MongoSyncAdapter;exports.modelSync=modelSync.modelSync;exports.ModelSyncOperation=modelSyncOperation.ModelSyncOperation;exports.DEFAULT_MAX_SYNC_DEPTH=syncContext.DEFAULT_MAX_SYNC_DEPTH;exports.SyncContextManager=syncContext.SyncContextManager;exports.SyncManager=syncManager.SyncManager;exports.connectToDatabase=connectToDatabase.connectToDatabase;exports.getDatabaseDriver=connectToDatabase.getDatabaseDriver;exports.transaction=connectToDatabase.transaction;exports.useModelTransformer=databaseWriter_utils.useModelTransformer;exports.defineModel=defineModel.defineModel;exports.onceConnected=onceConnected.onceConnected;exports.onceDisconnected=onceConnected.onceDisconnected;exports.ColumnBuilder=columnBuilder.ColumnBuilder;exports.ForeignKeyBuilder=foreignKeyBuilder.ForeignKeyBuilder;exports.DetachedColumnBuilder=columnHelpers.DetachedColumnBuilder;exports.arrayBigInt=columnHelpers.arrayBigInt;exports.arrayBoolean=columnHelpers.arrayBoolean;exports.arrayDate=columnHelpers.arrayDate;exports.arrayDecimal=columnHelpers.arrayDecimal;exports.arrayFloat=columnHelpers.arrayFloat;exports.arrayInt=columnHelpers.arrayInt;exports.arrayText=columnHelpers.arrayText;exports.arrayTimestamp=columnHelpers.arrayTimestamp;exports.arrayUuid=columnHelpers.arrayUuid;exports.bigInt=columnHelpers.bigInt;exports.bigInteger=columnHelpers.bigInteger;exports.binary=columnHelpers.binary;exports.blobCol=columnHelpers.blobCol;exports.bool=columnHelpers.boolCol;exports.boolCol=columnHelpers.boolCol;exports.char=columnHelpers.char;exports.date=columnHelpers.date;exports.dateTime=columnHelpers.dateTime;exports.decimal=columnHelpers.decimal;exports.double=columnHelpers.double;exports.enumCol=columnHelpers.enumCol;exports.float=columnHelpers.float;exports.geometry=columnHelpers.geometry;exports.int=columnHelpers.int;exports.integer=columnHelpers.integer;exports.ipAddress=columnHelpers.ipAddress;exports.json=columnHelpers.json;exports.lineString=columnHelpers.lineString;exports.longText=columnHelpers.longText;exports.macAddress=columnHelpers.macAddress;exports.mediumText=columnHelpers.mediumText;exports.objectCol=columnHelpers.objectCol;exports.point=columnHelpers.point;exports.polygon=columnHelpers.polygon;exports.setCol=columnHelpers.setCol;exports.smallInt=columnHelpers.smallInt;exports.smallInteger=columnHelpers.smallInteger;exports.string=columnHelpers.string;exports.text=columnHelpers.text;exports.time=columnHelpers.time;exports.timestamp=columnHelpers.timestamp;exports.tinyInt=columnHelpers.tinyInt;exports.tinyInteger=columnHelpers.tinyInteger;exports.ulid=columnHelpers.ulid;exports.uuid=columnHelpers.uuid;exports.vector=columnHelpers.vector;exports.year=columnHelpers.year;exports.Migration=migration.Migration;exports.migrate=migration.migrate;exports.MigrationRunner=migrationRunner.MigrationRunner;exports.migrationRunner=migrationRunner.migrationRunner;exports.MongoMigrationDriver=mongodbMigrationDriver.MongoMigrationDriver;exports.PostgresBlueprint=postgresBlueprint.PostgresBlueprint;exports.PostgresDialect=postgresDialect.PostgresDialect;exports.PostgresDriver=postgresDriver.PostgresDriver;exports.PostgresMigrationDriver=postgresMigrationDriver.PostgresMigrationDriver;exports.PostgresQueryBuilder=postgresQueryBuilder.PostgresQueryBuilder;exports.PostgresQueryParser=postgresQueryParser.PostgresQueryParser;exports.PostgresSyncAdapter=postgresSyncAdapter.PostgresSyncAdapter;//# sourceMappingURL=index.js.map
|
|
@@ -244,22 +244,32 @@ export declare class ColumnBuilder {
|
|
|
244
244
|
/**
|
|
245
245
|
* Declare a foreign key constraint on this column.
|
|
246
246
|
*
|
|
247
|
+
* Accepts either a raw table-name string or a Model class (anything with a
|
|
248
|
+
* static `table` property). Using a Model class is preferred — it is
|
|
249
|
+
* type-safe and automatically tracks table renames.
|
|
250
|
+
*
|
|
247
251
|
* Pushes an `addForeignKey` operation immediately using a mutable reference —
|
|
248
252
|
* subsequent `.on()`, `.onDelete()`, `.onUpdate()` calls mutate the same
|
|
249
253
|
* definition that is already queued, so no `.add()` terminator is needed.
|
|
250
254
|
*
|
|
251
255
|
* Referenced column defaults to `"id"` — use `.on()` to override.
|
|
252
256
|
*
|
|
253
|
-
* @param
|
|
257
|
+
* @param tableOrModel - Referenced table name OR a Model class with a static `table` property
|
|
254
258
|
* @returns This builder for chaining
|
|
255
259
|
*
|
|
256
260
|
* @example
|
|
257
261
|
* ```typescript
|
|
258
|
-
*
|
|
259
|
-
* this.
|
|
262
|
+
* // Preferred — model class reference (type-safe, rename-proof)
|
|
263
|
+
* this.uuid("organization_id").references(Organization).onDelete("cascade");
|
|
264
|
+
*
|
|
265
|
+
* // Also supported — raw table string
|
|
266
|
+
* this.uuid("organization_id").references("organizations").onDelete("cascade");
|
|
267
|
+
* this.uuid("organization_id").references(Organization.table).onDelete("cascade");
|
|
260
268
|
* ```
|
|
261
269
|
*/
|
|
262
|
-
references(
|
|
270
|
+
references(tableOrModel: string | {
|
|
271
|
+
table: string;
|
|
272
|
+
}): this;
|
|
263
273
|
/**
|
|
264
274
|
* Set the referenced column for the foreign key.
|
|
265
275
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column-builder.d.ts","sourceRoot":"","sources":["../../src/migration/column-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,UAAU,EACV,oBAAoB,EACrB,MAAM,wCAAwC,CAAC;AAEhD;;;GAGG;AACH,KAAK,aAAa,GAAG;IACnB,eAAe,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,EAAE,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IACtE,sBAAsB,CAAC,EAAE,EAAE,oBAAoB,GAAG,IAAI,CAAC;CACxD,CAAC;AAcF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,aAAa;IAmBtB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAlB5B,kDAAkD;IAClD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmB;IAE9C,uEAAuE;IACvE,OAAO,CAAC,YAAY,CAAC,CAA8B;IAEnD,0FAA0F;IAC1F,OAAO,CAAC,mBAAmB,CAAC,CAAS;IAErC;;;;;;;OAOG;gBAEgB,SAAS,EAAE,aAAa,EACzC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,EAChB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;;;;;;;;;;;OAWG;IACI,QAAQ,IAAI,IAAI;IASvB;;;;;;;;;;;;OAYG;IACI,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IASlC;;;;;;OAMG;IACI,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IAYrD;;;;;;;;;;;;OAYG;IACI,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAKtC;;;;;;;;;;;OAWG;IACI,KAAK,IAAI,IAAI;IASpB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACI,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAejE;;;;;;;;;;;;OAYG;IACI,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAO/B;;;;;;;;;;;;OAYG;IACI,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC,UAAU,CAAC,GAAG,IAAI;IAO/D;;;;;;;;;;;;OAYG;IACI,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC,UAAU,CAAC,GAAG,IAAI;IAO/D;;;;;;;;;;;OAWG;IACI,UAAU,IAAI,IAAI;IAYzB;;;;;;;;;;;;;;;;;;;OAmBG;IACI,MAAM,IAAI,OAAO;IA+BxB;;OAEG;IACI,MAAM,IAAI,OAAO;IAQxB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACI,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAK5C;;;;;;OAMG;IACI,MAAM,IAAI,IAAI;IAUrB;;;;;;OAMG;IACI,OAAO,IAAI,IAAI;IActB;;;;;;OAMG;IACI,aAAa,IAAI,gBAAgB;CAGzC"}
|
|
@@ -322,25 +322,34 @@ class ColumnBuilder {
|
|
|
322
322
|
/**
|
|
323
323
|
* Declare a foreign key constraint on this column.
|
|
324
324
|
*
|
|
325
|
+
* Accepts either a raw table-name string or a Model class (anything with a
|
|
326
|
+
* static `table` property). Using a Model class is preferred — it is
|
|
327
|
+
* type-safe and automatically tracks table renames.
|
|
328
|
+
*
|
|
325
329
|
* Pushes an `addForeignKey` operation immediately using a mutable reference —
|
|
326
330
|
* subsequent `.on()`, `.onDelete()`, `.onUpdate()` calls mutate the same
|
|
327
331
|
* definition that is already queued, so no `.add()` terminator is needed.
|
|
328
332
|
*
|
|
329
333
|
* Referenced column defaults to `"id"` — use `.on()` to override.
|
|
330
334
|
*
|
|
331
|
-
* @param
|
|
335
|
+
* @param tableOrModel - Referenced table name OR a Model class with a static `table` property
|
|
332
336
|
* @returns This builder for chaining
|
|
333
337
|
*
|
|
334
338
|
* @example
|
|
335
339
|
* ```typescript
|
|
336
|
-
*
|
|
337
|
-
* this.
|
|
340
|
+
* // Preferred — model class reference (type-safe, rename-proof)
|
|
341
|
+
* this.uuid("organization_id").references(Organization).onDelete("cascade");
|
|
342
|
+
*
|
|
343
|
+
* // Also supported — raw table string
|
|
344
|
+
* this.uuid("organization_id").references("organizations").onDelete("cascade");
|
|
345
|
+
* this.uuid("organization_id").references(Organization.table).onDelete("cascade");
|
|
338
346
|
* ```
|
|
339
347
|
*/
|
|
340
|
-
references(
|
|
348
|
+
references(tableOrModel) {
|
|
349
|
+
const tableName = typeof tableOrModel === "string" ? tableOrModel : tableOrModel.table;
|
|
341
350
|
this.fkDefinition = {
|
|
342
351
|
column: this.definition.name,
|
|
343
|
-
referencesTable:
|
|
352
|
+
referencesTable: tableName,
|
|
344
353
|
referencesColumn: "id",
|
|
345
354
|
onDelete: "restrict",
|
|
346
355
|
onUpdate: "restrict",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column-builder.js","sources":["../../src/migration/column-builder.ts"],"sourcesContent":[null],"names":[],"mappings":"aA2BA;;;;;;;;;;;;;;;;;;;;;AAqBG;MACU,aAAa,CAAA;AAmBL,IAAA,SAAA,CAAA;;AAjBF,IAAA,UAAU,CAAmB;;AAGtC,IAAA,YAA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YACV,IAAI,EAAE,IAAI,IAAI,CAAA,MAAA,EAAS,IAAI,CAAC,UAAU,CAAC,IAAI,CAAE,CAAA;SAC9C,CAAC;AACF,QAAA,OAAO,IAAI,CAAC;KACb;;;;AAMD;;;;;;;;;;;;AAYG;AACI,IAAA,KAAK,CAAC,UAAkB,EAAA;AAC7B,QAAA,IAAI,CAAC,UAAU,CAAC,KAAK,GAAG,UAAU,CAAC;AACnC,QAAA,OAAO,IAAI,CAAC;KACb;AAED;;;;;;;;;;;AAWG;IACI,KAAK,GAAA;AACV,QAAA,IAAI,CAAC,UAAU,CAAC,KAAK,GAAG,IAAI,CAAC;AAC7B,QAAA,OAAO,IAAI,CAAC;KACb;;;;AAMD
|
|
1
|
+
{"version":3,"file":"column-builder.js","sources":["../../src/migration/column-builder.ts"],"sourcesContent":[null],"names":[],"mappings":"aA2BA;;;;;;;;;;;;;;;;;;;;;AAqBG;MACU,aAAa,CAAA;AAmBL,IAAA,SAAA,CAAA;;AAjBF,IAAA,UAAU,CAAmB;;AAGtC,IAAA,YAAY,CAA+B;;AAG3C,IAAA,mBAAmB,CAAU;AAErC;;;;;;;AAOG;AACH,IAAA,WAAA,CACmB,SAAwB,EACzC,IAAY,EACZ,IAAgB,EAChB,UAEI,EAAE,EAAA;QALW,IAAS,CAAA,SAAA,GAAT,SAAS,CAAe;QAOzC,IAAI,CAAC,UAAU,GAAG;YAChB,IAAI;YACJ,IAAI;AACJ,YAAA,QAAQ,EAAE,KAAK;AACf,YAAA,GAAG,OAAO;SACX,CAAC;KACH;;;;AAMD;;;;;;;;;AASG;IACI,QAAQ,GAAA;AACb,QAAA,IAAI,CAAC,UAAU,CAAC,QAAQ,GAAG,IAAI,CAAC;AAChC,QAAA,OAAO,IAAI,CAAC;KACb;AAED;;;;;;AAMG;IACI,WAAW,GAAA;AAChB,QAAA,IAAI,CAAC,UAAU,CAAC,QAAQ,GAAG,KAAK,CAAC;AACjC,QAAA,OAAO,IAAI,CAAC;KACb;;;;AAMD;;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AAmB,EAAE;AAC5B,YAAA,IAAI,CAAC,UAAU,CAAC,SAAS,GAAG;gBAC1B,UAAU,EAAE,IAAI,CAAC,mBAAmB;AACpC,gBAAA,MAAM,EAAE,IAAI;aACb,CAAC;AACH,SAAA;AACD,QAAA,OAAO,IAAI,CAAC;KACb;AAED;;;;;;AAMG;IACI,OAAO,GAAA;QACZ,IAAI,IAAI,CAAC,mBAAmB,EAAE;AAC5B,YAAA,IAAI,CAAC,UAAU,CAAC,SAAS,GAAG;gBAC1B,UAAU,EAAE,IAAI,CAAC,mBAAmB;AACpC,gBAAA,MAAM,EAAE,KAAK;aACd,CAAC;AACH,SAAA;AACD,QAAA,OAAO,IAAI,CAAC;KACb;;;;AAMD;;;;;;AAMG;IACI,aAAa,GAAA;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;KACxB;AACF"}
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { ColumnBuilder } from "./column-builder";
|
|
2
|
+
/**
|
|
3
|
+
* A no-op migration sink used by standalone column helpers.
|
|
4
|
+
*
|
|
5
|
+
* When column helpers are used in `Migration.create()` / `Migration.alter()`,
|
|
6
|
+
* the builder is constructed without a real migration context. The actual
|
|
7
|
+
* operations are dequeued from the ColumnBuilder's definition and replayed
|
|
8
|
+
* onto the real migration instance at execution time.
|
|
9
|
+
*
|
|
10
|
+
* Index and FK operations queued on this sink are collected and transferred
|
|
11
|
+
* to the real migration by the factory methods.
|
|
12
|
+
*/
|
|
13
|
+
declare class DetachedMigrationSink {
|
|
14
|
+
/** Pending indexes registered via .unique() / .index() on a helper column. */
|
|
15
|
+
readonly pendingIndexes: {
|
|
16
|
+
columns: string[];
|
|
17
|
+
unique?: boolean;
|
|
18
|
+
}[];
|
|
19
|
+
/** Pending FK definitions registered via .references() on a helper column. */
|
|
20
|
+
readonly pendingForeignKeys: object[];
|
|
21
|
+
addPendingIndex(index: {
|
|
22
|
+
columns: string[];
|
|
23
|
+
unique?: boolean;
|
|
24
|
+
}): void;
|
|
25
|
+
addForeignKeyOperation(fk: object): void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A `ColumnBuilder` that carries its own detached sink so it can be
|
|
29
|
+
* constructed outside of a migration class and later merged in.
|
|
30
|
+
*/
|
|
31
|
+
export declare class DetachedColumnBuilder extends ColumnBuilder {
|
|
32
|
+
readonly sink: DetachedMigrationSink;
|
|
33
|
+
constructor(type: ConstructorParameters<typeof ColumnBuilder>[2], name: string, options?: ConstructorParameters<typeof ColumnBuilder>[3]);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Standalone column helper: string / varchar.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* import { Migration, string } from "@warlock.js/cascade";
|
|
41
|
+
*
|
|
42
|
+
* export default Migration.create(User, {
|
|
43
|
+
* username: string(50).unique(),
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function string(length?: number): DetachedColumnBuilder;
|
|
48
|
+
/**
|
|
49
|
+
* Standalone column helper: fixed-length CHAR.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* code: char(3) // CHAR(3)
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare function char(length: number): DetachedColumnBuilder;
|
|
57
|
+
/**
|
|
58
|
+
* Standalone column helper: TEXT (unlimited length).
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* import { Migration, text } from "@warlock.js/cascade";
|
|
63
|
+
*
|
|
64
|
+
* export default Migration.create(User, {
|
|
65
|
+
* bio: text().nullable(),
|
|
66
|
+
* });
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare function text(): DetachedColumnBuilder;
|
|
70
|
+
/**
|
|
71
|
+
* Standalone column helper: MEDIUMTEXT.
|
|
72
|
+
*/
|
|
73
|
+
export declare function mediumText(): DetachedColumnBuilder;
|
|
74
|
+
/**
|
|
75
|
+
* Standalone column helper: LONGTEXT.
|
|
76
|
+
*/
|
|
77
|
+
export declare function longText(): DetachedColumnBuilder;
|
|
78
|
+
/**
|
|
79
|
+
* Standalone column helper: INTEGER.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* age: integer().unsigned()
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare function integer(): DetachedColumnBuilder;
|
|
87
|
+
/** Alias for `integer()`. */
|
|
88
|
+
export declare const int: typeof integer;
|
|
89
|
+
/**
|
|
90
|
+
* Standalone column helper: SMALLINT.
|
|
91
|
+
*/
|
|
92
|
+
export declare function smallInteger(): DetachedColumnBuilder;
|
|
93
|
+
/** Alias for `smallInteger()`. */
|
|
94
|
+
export declare const smallInt: typeof smallInteger;
|
|
95
|
+
/**
|
|
96
|
+
* Standalone column helper: TINYINT.
|
|
97
|
+
*/
|
|
98
|
+
export declare function tinyInteger(): DetachedColumnBuilder;
|
|
99
|
+
/** Alias for `tinyInteger()`. */
|
|
100
|
+
export declare const tinyInt: typeof tinyInteger;
|
|
101
|
+
/**
|
|
102
|
+
* Standalone column helper: BIGINT.
|
|
103
|
+
*/
|
|
104
|
+
export declare function bigInteger(): DetachedColumnBuilder;
|
|
105
|
+
/** Alias for `bigInteger()`. */
|
|
106
|
+
export declare const bigInt: typeof bigInteger;
|
|
107
|
+
/**
|
|
108
|
+
* Standalone column helper: FLOAT.
|
|
109
|
+
*/
|
|
110
|
+
export declare function float(): DetachedColumnBuilder;
|
|
111
|
+
/**
|
|
112
|
+
* Standalone column helper: DOUBLE.
|
|
113
|
+
*/
|
|
114
|
+
export declare function double(): DetachedColumnBuilder;
|
|
115
|
+
/**
|
|
116
|
+
* Standalone column helper: DECIMAL.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* price: decimal(10, 2) // DECIMAL(10,2)
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
export declare function decimal(precision?: number, scale?: number): DetachedColumnBuilder;
|
|
124
|
+
/**
|
|
125
|
+
* Standalone column helper: BOOLEAN.
|
|
126
|
+
*
|
|
127
|
+
* Named `boolCol` to avoid collision with the TypeScript / JS `boolean` primitive.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* is_active: boolCol().default(true)
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export declare function boolCol(): DetachedColumnBuilder;
|
|
135
|
+
/** Alias for `boolCol()`. */
|
|
136
|
+
export { boolCol as bool };
|
|
137
|
+
/**
|
|
138
|
+
* Standalone column helper: DATE.
|
|
139
|
+
*/
|
|
140
|
+
export declare function date(): DetachedColumnBuilder;
|
|
141
|
+
/**
|
|
142
|
+
* Standalone column helper: DATETIME.
|
|
143
|
+
*/
|
|
144
|
+
export declare function dateTime(): DetachedColumnBuilder;
|
|
145
|
+
/**
|
|
146
|
+
* Standalone column helper: TIMESTAMP.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```typescript
|
|
150
|
+
* started_at: timestamp().default("NOW()")
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
export declare function timestamp(): DetachedColumnBuilder;
|
|
154
|
+
/**
|
|
155
|
+
* Standalone column helper: TIME.
|
|
156
|
+
*/
|
|
157
|
+
export declare function time(): DetachedColumnBuilder;
|
|
158
|
+
/**
|
|
159
|
+
* Standalone column helper: YEAR.
|
|
160
|
+
*/
|
|
161
|
+
export declare function year(): DetachedColumnBuilder;
|
|
162
|
+
/**
|
|
163
|
+
* Standalone column helper: JSON.
|
|
164
|
+
*
|
|
165
|
+
* Named `jsonCol` to avoid collision with the TS/JSON built-in names.
|
|
166
|
+
* Use `json()` is fine for most cases though — this alias exists for clarity.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```typescript
|
|
170
|
+
* metadata: json().nullable()
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
export declare function json(): DetachedColumnBuilder;
|
|
174
|
+
/**
|
|
175
|
+
* Alias for `json()`. Named `objectCol` to avoid collision with TS `object` type.
|
|
176
|
+
*/
|
|
177
|
+
export declare function objectCol(): DetachedColumnBuilder;
|
|
178
|
+
/**
|
|
179
|
+
* Standalone column helper: BINARY / BLOB.
|
|
180
|
+
*/
|
|
181
|
+
export declare function binary(): DetachedColumnBuilder;
|
|
182
|
+
/**
|
|
183
|
+
* Alias for `binary()`. Named `blobCol` to avoid collision with the Web `Blob` API.
|
|
184
|
+
*/
|
|
185
|
+
export declare function blobCol(): DetachedColumnBuilder;
|
|
186
|
+
/**
|
|
187
|
+
* Standalone column helper: UUID.
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```typescript
|
|
191
|
+
* import { Migration, uuid } from "@warlock.js/cascade";
|
|
192
|
+
*
|
|
193
|
+
* export default Migration.create(Chat, {
|
|
194
|
+
* organization_id: uuid().references(Organization).onDelete("cascade"),
|
|
195
|
+
* });
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
export declare function uuid(): DetachedColumnBuilder;
|
|
199
|
+
/**
|
|
200
|
+
* Standalone column helper: ULID.
|
|
201
|
+
*/
|
|
202
|
+
export declare function ulid(): DetachedColumnBuilder;
|
|
203
|
+
/**
|
|
204
|
+
* Standalone column helper: IP address.
|
|
205
|
+
*/
|
|
206
|
+
export declare function ipAddress(): DetachedColumnBuilder;
|
|
207
|
+
/**
|
|
208
|
+
* Standalone column helper: MAC address.
|
|
209
|
+
*/
|
|
210
|
+
export declare function macAddress(): DetachedColumnBuilder;
|
|
211
|
+
/**
|
|
212
|
+
* Standalone column helper: geo point.
|
|
213
|
+
*/
|
|
214
|
+
export declare function point(): DetachedColumnBuilder;
|
|
215
|
+
/**
|
|
216
|
+
* Standalone column helper: polygon.
|
|
217
|
+
*/
|
|
218
|
+
export declare function polygon(): DetachedColumnBuilder;
|
|
219
|
+
/**
|
|
220
|
+
* Standalone column helper: line string.
|
|
221
|
+
*/
|
|
222
|
+
export declare function lineString(): DetachedColumnBuilder;
|
|
223
|
+
/**
|
|
224
|
+
* Standalone column helper: generic geometry.
|
|
225
|
+
*/
|
|
226
|
+
export declare function geometry(): DetachedColumnBuilder;
|
|
227
|
+
/**
|
|
228
|
+
* Standalone column helper: vector (for AI embeddings).
|
|
229
|
+
*
|
|
230
|
+
* @param dimensions - Embedding size (e.g. 1536 for text-embedding-3-small)
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* ```typescript
|
|
234
|
+
* embedding: vector(1536)
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
export declare function vector(dimensions: number): DetachedColumnBuilder;
|
|
238
|
+
/**
|
|
239
|
+
* Standalone column helper: ENUM.
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```typescript
|
|
243
|
+
* status: enumCol(["active", "inactive", "pending"])
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
export declare function enumCol(values: string[]): DetachedColumnBuilder;
|
|
247
|
+
/**
|
|
248
|
+
* Standalone column helper: SET (multiple values).
|
|
249
|
+
*/
|
|
250
|
+
export declare function setCol(values: string[]): DetachedColumnBuilder;
|
|
251
|
+
/** Standalone helper: INTEGER[] */
|
|
252
|
+
export declare function arrayInt(): DetachedColumnBuilder;
|
|
253
|
+
/** Standalone helper: BIGINT[] */
|
|
254
|
+
export declare function arrayBigInt(): DetachedColumnBuilder;
|
|
255
|
+
/** Standalone helper: REAL[] */
|
|
256
|
+
export declare function arrayFloat(): DetachedColumnBuilder;
|
|
257
|
+
/** Standalone helper: DECIMAL[] */
|
|
258
|
+
export declare function arrayDecimal(precision?: number, scale?: number): DetachedColumnBuilder;
|
|
259
|
+
/** Standalone helper: BOOLEAN[] */
|
|
260
|
+
export declare function arrayBoolean(): DetachedColumnBuilder;
|
|
261
|
+
/** Standalone helper: TEXT[] */
|
|
262
|
+
export declare function arrayText(): DetachedColumnBuilder;
|
|
263
|
+
/** Standalone helper: DATE[] */
|
|
264
|
+
export declare function arrayDate(): DetachedColumnBuilder;
|
|
265
|
+
/** Standalone helper: TIMESTAMPTZ[] */
|
|
266
|
+
export declare function arrayTimestamp(): DetachedColumnBuilder;
|
|
267
|
+
/** Standalone helper: UUID[] */
|
|
268
|
+
export declare function arrayUuid(): DetachedColumnBuilder;
|
|
269
|
+
//# sourceMappingURL=column-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-helpers.d.ts","sourceRoot":"","sources":["../../src/migration/column-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD;;;;;;;;;;GAUG;AACH,cAAM,qBAAqB;IACzB,8EAA8E;IAC9E,SAAgB,cAAc,EAAE;QAAE,OAAO,EAAE,MAAM,EAAE,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,EAAE,CAAM;IAE/E,8EAA8E;IAC9E,SAAgB,kBAAkB,EAAE,MAAM,EAAE,CAAM;IAE3C,eAAe,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,EAAE,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;IAIrE,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;CAGhD;AAED;;;GAGG;AACH,qBAAa,qBAAsB,SAAQ,aAAa;IACtD,SAAgB,IAAI,EAAE,qBAAqB,CAAC;gBAG1C,IAAI,EAAE,qBAAqB,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,EACpD,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,qBAAqB,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAM;CAM/D;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAC,MAAM,SAAM,GAAG,qBAAqB,CAE1D;A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