@powersync/web 0.0.0-dev-20260306114652 → 0.0.0-dev-20260309101613

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.
@@ -15587,17 +15587,12 @@ class TriggerManagerImpl {
15587
15587
  }
15588
15588
  });
15589
15589
  }
15590
- /**
15591
- * Creates a diff trigger destination table on the database with the given configuration.
15592
- * By default this is invoked internally when creating a diff trigger, but can
15593
- * be used manually if `manageDestinationExternally` is set to true.
15594
- */
15595
15590
  async createDiffDestinationTable(tableName, options) {
15596
- const tableTriggerTypeClause = !options?.useStorage ? 'TEMP' : '';
15597
- const onlyIfNotExists = options?.onlyIfNotExists ? 'IF NOT EXISTS' : '';
15598
- const ctx = options?.lockContext ?? this.db.database;
15599
- await ctx.execute(/* sql */ `
15600
- CREATE ${tableTriggerTypeClause} TABLE ${onlyIfNotExists} ${tableName} (
15591
+ const { temporary = true, onlyIfNotExists = false } = options ?? {};
15592
+ const tableTriggerTypeClause = temporary ? 'TEMP' : '';
15593
+ const onlyIfNotExistsClause = onlyIfNotExists ? 'IF NOT EXISTS' : '';
15594
+ await this.db.execute(/* sql */ `
15595
+ CREATE ${tableTriggerTypeClause} TABLE ${onlyIfNotExistsClause} ${tableName} (
15601
15596
  operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
15602
15597
  id TEXT,
15603
15598
  operation TEXT,
@@ -15636,7 +15631,7 @@ class TriggerManagerImpl {
15636
15631
  const internalSource = sourceDefinition.internalName;
15637
15632
  const triggerIds = [];
15638
15633
  const id = await this.getUUID();
15639
- const releaseStorageClaim = useStorage ? await this.options.claimManager.obtainClaim(id) : null;
15634
+ const releaseStorageClaim = useStorage && !manageDestinationExternally ? await this.options.claimManager.obtainClaim(id) : null;
15640
15635
  /**
15641
15636
  * We default to replicating all columns if no columns array is provided.
15642
15637
  */
@@ -15678,11 +15673,16 @@ class TriggerManagerImpl {
15678
15673
  // Allow user code to execute in this lock context before the trigger is created.
15679
15674
  await hooks?.beforeCreate?.(tx);
15680
15675
  if (!manageDestinationExternally) {
15681
- await this.createDiffDestinationTable(destination, {
15682
- lockContext: tx,
15683
- useStorage,
15684
- onlyIfNotExists: false
15685
- });
15676
+ await tx.execute(/* sql */ `
15677
+ CREATE ${tableTriggerTypeClause} TABLE ${destination} (
15678
+ operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
15679
+ id TEXT,
15680
+ operation TEXT,
15681
+ timestamp TEXT,
15682
+ value TEXT,
15683
+ previous_value TEXT
15684
+ )
15685
+ `);
15686
15686
  }
15687
15687
  if (operations.includes(DiffTriggerOperation.INSERT)) {
15688
15688
  const insertTriggerId = this.generateTriggerName(DiffTriggerOperation.INSERT, destination, id, manageDestinationExternally);