@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.
|
@@ -16971,17 +16971,12 @@ class TriggerManagerImpl {
|
|
|
16971
16971
|
}
|
|
16972
16972
|
});
|
|
16973
16973
|
}
|
|
16974
|
-
/**
|
|
16975
|
-
* Creates a diff trigger destination table on the database with the given configuration.
|
|
16976
|
-
* By default this is invoked internally when creating a diff trigger, but can
|
|
16977
|
-
* be used manually if `manageDestinationExternally` is set to true.
|
|
16978
|
-
*/
|
|
16979
16974
|
async createDiffDestinationTable(tableName, options) {
|
|
16980
|
-
const
|
|
16981
|
-
const
|
|
16982
|
-
const
|
|
16983
|
-
await
|
|
16984
|
-
CREATE ${tableTriggerTypeClause} TABLE ${
|
|
16975
|
+
const { temporary = true, onlyIfNotExists = false } = options ?? {};
|
|
16976
|
+
const tableTriggerTypeClause = temporary ? 'TEMP' : '';
|
|
16977
|
+
const onlyIfNotExistsClause = onlyIfNotExists ? 'IF NOT EXISTS' : '';
|
|
16978
|
+
await this.db.execute(/* sql */ `
|
|
16979
|
+
CREATE ${tableTriggerTypeClause} TABLE ${onlyIfNotExistsClause} ${tableName} (
|
|
16985
16980
|
operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
16986
16981
|
id TEXT,
|
|
16987
16982
|
operation TEXT,
|
|
@@ -17020,7 +17015,7 @@ class TriggerManagerImpl {
|
|
|
17020
17015
|
const internalSource = sourceDefinition.internalName;
|
|
17021
17016
|
const triggerIds = [];
|
|
17022
17017
|
const id = await this.getUUID();
|
|
17023
|
-
const releaseStorageClaim = useStorage ? await this.options.claimManager.obtainClaim(id) : null;
|
|
17018
|
+
const releaseStorageClaim = useStorage && !manageDestinationExternally ? await this.options.claimManager.obtainClaim(id) : null;
|
|
17024
17019
|
/**
|
|
17025
17020
|
* We default to replicating all columns if no columns array is provided.
|
|
17026
17021
|
*/
|
|
@@ -17062,11 +17057,16 @@ class TriggerManagerImpl {
|
|
|
17062
17057
|
// Allow user code to execute in this lock context before the trigger is created.
|
|
17063
17058
|
await hooks?.beforeCreate?.(tx);
|
|
17064
17059
|
if (!manageDestinationExternally) {
|
|
17065
|
-
await
|
|
17066
|
-
|
|
17067
|
-
|
|
17068
|
-
|
|
17069
|
-
|
|
17060
|
+
await tx.execute(/* sql */ `
|
|
17061
|
+
CREATE ${tableTriggerTypeClause} TABLE ${destination} (
|
|
17062
|
+
operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
17063
|
+
id TEXT,
|
|
17064
|
+
operation TEXT,
|
|
17065
|
+
timestamp TEXT,
|
|
17066
|
+
value TEXT,
|
|
17067
|
+
previous_value TEXT
|
|
17068
|
+
)
|
|
17069
|
+
`);
|
|
17070
17070
|
}
|
|
17071
17071
|
if (operations.includes(DiffTriggerOperation.INSERT)) {
|
|
17072
17072
|
const insertTriggerId = this.generateTriggerName(DiffTriggerOperation.INSERT, destination, id, manageDestinationExternally);
|