@mastra/mysql 0.3.0 → 0.3.1
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/CHANGELOG.md +22 -0
- package/dist/index.cjs +30 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -2
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/observability/index.d.ts.map +1 -1
- package/dist/storage/domains/operations/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -294,6 +294,16 @@ var StoreOperationsMySQL = class extends StoreOperations {
|
|
|
294
294
|
const pkColumns = tableConfig.compositePrimaryKey.map((col) => quoteIdentifier(col, "primary key column")).join(", ");
|
|
295
295
|
extraConstraints.push(`PRIMARY KEY (${pkColumns})`);
|
|
296
296
|
}
|
|
297
|
+
if (tableName === TABLE_WORKFLOW_SNAPSHOT) {
|
|
298
|
+
extraConstraints.push(
|
|
299
|
+
`PRIMARY KEY (${quoteIdentifier("workflow_name", "column name")}, ${quoteIdentifier("run_id", "column name")})`
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
if (tableName === TABLE_SPANS) {
|
|
303
|
+
extraConstraints.push(
|
|
304
|
+
`PRIMARY KEY (${quoteIdentifier("traceId", "column name")}, ${quoteIdentifier("spanId", "column name")})`
|
|
305
|
+
);
|
|
306
|
+
}
|
|
297
307
|
return `CREATE TABLE IF NOT EXISTS ${tableIdent} (${[...columns, ...extraConstraints].filter(Boolean).join(", ")}) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`;
|
|
298
308
|
}
|
|
299
309
|
isKeyColumn(tableName, columnName) {
|
|
@@ -6886,7 +6896,8 @@ var ObservabilityMySQL = class _ObservabilityMySQL extends ObservabilityStorage
|
|
|
6886
6896
|
statements.push(
|
|
6887
6897
|
generateTableSQL({
|
|
6888
6898
|
tableName: TABLE_SPANS,
|
|
6889
|
-
schema: TABLE_SCHEMAS[TABLE_SPANS]
|
|
6899
|
+
schema: TABLE_SCHEMAS[TABLE_SPANS],
|
|
6900
|
+
compositePrimaryKey: ["traceId", "spanId"]
|
|
6890
6901
|
})
|
|
6891
6902
|
);
|
|
6892
6903
|
for (const idx of _ObservabilityMySQL.getDefaultIndexDefs()) {
|
|
@@ -9872,7 +9883,13 @@ var WorkflowsMySQL = class _WorkflowsMySQL extends WorkflowsStorage {
|
|
|
9872
9883
|
* Exports DDL statements for all managed tables.
|
|
9873
9884
|
*/
|
|
9874
9885
|
static getExportDDL() {
|
|
9875
|
-
return [
|
|
9886
|
+
return [
|
|
9887
|
+
generateTableSQL({
|
|
9888
|
+
tableName: TABLE_WORKFLOW_SNAPSHOT,
|
|
9889
|
+
schema: TABLE_SCHEMAS[TABLE_WORKFLOW_SNAPSHOT],
|
|
9890
|
+
compositePrimaryKey: ["workflow_name", "run_id"]
|
|
9891
|
+
})
|
|
9892
|
+
];
|
|
9876
9893
|
}
|
|
9877
9894
|
constructor({
|
|
9878
9895
|
operations,
|
|
@@ -10050,6 +10067,17 @@ var WorkflowsMySQL = class _WorkflowsMySQL extends WorkflowsStorage {
|
|
|
10050
10067
|
const updatedAtValue = updatedAt ?? now;
|
|
10051
10068
|
try {
|
|
10052
10069
|
const tableName = formatTableName(TABLE_WORKFLOW_SNAPSHOT);
|
|
10070
|
+
const [updateResult] = await this.pool.execute(
|
|
10071
|
+
`UPDATE ${tableName}
|
|
10072
|
+
SET ${quoteIdentifier("resourceId", "column name")} = ?,
|
|
10073
|
+
${quoteIdentifier("snapshot", "column name")} = ?,
|
|
10074
|
+
${quoteIdentifier("updatedAt", "column name")} = ?
|
|
10075
|
+
WHERE ${quoteIdentifier("workflow_name", "column name")} = ? AND ${quoteIdentifier("run_id", "column name")} = ?`,
|
|
10076
|
+
[resourceId ?? null, JSON.stringify(snapshot), transformToSqlValue(updatedAtValue), workflowName, runId]
|
|
10077
|
+
);
|
|
10078
|
+
if (updateResult.affectedRows > 0) {
|
|
10079
|
+
return;
|
|
10080
|
+
}
|
|
10053
10081
|
await this.pool.execute(
|
|
10054
10082
|
`INSERT INTO ${tableName} (${quoteIdentifier("workflow_name", "column name")}, ${quoteIdentifier("run_id", "column name")}, ${quoteIdentifier("resourceId", "column name")}, ${quoteIdentifier("snapshot", "column name")}, ${quoteIdentifier("createdAt", "column name")}, ${quoteIdentifier("updatedAt", "column name")})
|
|
10055
10083
|
VALUES (?, ?, ?, ?, ?, ?)
|