@powersync/common 0.0.0-dev-20260305092446 → 0.0.0-dev-20260305124002

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.
@@ -9968,7 +9968,7 @@ class TriggerManagerImpl {
9968
9968
  }
9969
9969
  async createDiffTrigger(options) {
9970
9970
  await this.db.waitForReady();
9971
- const { source, destination, columns, when, hooks, persistDestination = false,
9971
+ const { source, destination, columns, when, hooks, manageDestinationExternally = false,
9972
9972
  // Fall back to the provided default if not given on this level
9973
9973
  useStorage = this.defaultConfig.useStorageByDefault } = options;
9974
9974
  const operations = Object.keys(when);
@@ -10023,11 +10023,11 @@ class TriggerManagerImpl {
10023
10023
  * we need to ensure we can cleanup the created resources.
10024
10024
  * We unfortunately cannot rely on transaction rollback.
10025
10025
  */
10026
- const cleanup = async (force) => {
10026
+ const cleanup = async () => {
10027
10027
  disposeWarningListener();
10028
10028
  return this.db.writeLock(async (tx) => {
10029
10029
  await this.removeTriggers(tx, triggerIds);
10030
- if (!persistDestination || force) {
10030
+ if (!manageDestinationExternally) {
10031
10031
  await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
10032
10032
  }
10033
10033
  await releaseStorageClaim?.();
@@ -10036,16 +10036,18 @@ class TriggerManagerImpl {
10036
10036
  const setup = async (tx) => {
10037
10037
  // Allow user code to execute in this lock context before the trigger is created.
10038
10038
  await hooks?.beforeCreate?.(tx);
10039
- await tx.execute(/* sql */ `
10040
- CREATE ${tableTriggerTypeClause} TABLE ${persistDestination ? 'IF NOT EXISTS ' : ''}${destination} (
10041
- operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
10042
- id TEXT,
10043
- operation TEXT,
10044
- timestamp TEXT,
10045
- value TEXT,
10046
- previous_value TEXT
10047
- )
10048
- `);
10039
+ if (!manageDestinationExternally) {
10040
+ await tx.execute(/* sql */ `
10041
+ CREATE ${tableTriggerTypeClause} TABLE ${destination} (
10042
+ operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
10043
+ id TEXT,
10044
+ operation TEXT,
10045
+ timestamp TEXT,
10046
+ value TEXT,
10047
+ previous_value TEXT
10048
+ )
10049
+ `);
10050
+ }
10049
10051
  if (operations.includes(exports.DiffTriggerOperation.INSERT)) {
10050
10052
  const insertTriggerId = this.generateTriggerName(exports.DiffTriggerOperation.INSERT, destination, id);
10051
10053
  triggerIds.push(insertTriggerId);