@mastra/libsql 1.24.0-alpha.2 → 1.24.0
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/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-deployment-workers.md +7 -2
- package/dist/docs/references/docs-memory-overview.md +1 -1
- package/dist/docs/references/reference-storage-retention.md +1 -1
- package/dist/index.cjs +46 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/schedules/index.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -11231,6 +11231,7 @@ var SchedulesLibSQL = class SchedulesLibSQL extends SchedulesStorage {
|
|
|
11231
11231
|
});
|
|
11232
11232
|
}
|
|
11233
11233
|
async init() {
|
|
11234
|
+
await this.#migrateLegacyTriggersTable();
|
|
11234
11235
|
await this.#db.createTable({
|
|
11235
11236
|
tableName: TABLE_SCHEDULES,
|
|
11236
11237
|
schema: TABLE_SCHEMAS[TABLE_SCHEDULES]
|
|
@@ -11239,6 +11240,15 @@ var SchedulesLibSQL = class SchedulesLibSQL extends SchedulesStorage {
|
|
|
11239
11240
|
tableName: TABLE_SCHEDULE_TRIGGERS,
|
|
11240
11241
|
schema: TABLE_SCHEMAS[TABLE_SCHEDULE_TRIGGERS]
|
|
11241
11242
|
});
|
|
11243
|
+
try {
|
|
11244
|
+
await this.#db.alterTable({
|
|
11245
|
+
tableName: TABLE_SCHEDULES,
|
|
11246
|
+
schema: TABLE_SCHEMAS[TABLE_SCHEDULES],
|
|
11247
|
+
ifNotExists: ["owner_type", "owner_id"]
|
|
11248
|
+
});
|
|
11249
|
+
} catch (error) {
|
|
11250
|
+
if (!(await this.#db.hasColumn(TABLE_SCHEDULES, "owner_type") && await this.#db.hasColumn(TABLE_SCHEDULES, "owner_id"))) throw error;
|
|
11251
|
+
}
|
|
11242
11252
|
await this.#client.batch([{
|
|
11243
11253
|
sql: `CREATE INDEX IF NOT EXISTS idx_schedules_status_next_fire ON "${TABLE_SCHEDULES}" ("status", "next_fire_at")`,
|
|
11244
11254
|
args: []
|
|
@@ -11247,6 +11257,42 @@ var SchedulesLibSQL = class SchedulesLibSQL extends SchedulesStorage {
|
|
|
11247
11257
|
args: []
|
|
11248
11258
|
}], "write");
|
|
11249
11259
|
}
|
|
11260
|
+
/**
|
|
11261
|
+
* Trigger tables created before the ownership/audit schema change are keyed
|
|
11262
|
+
* by `run_id` (NOT NULL) and store `status` instead of `outcome`. SQLite
|
|
11263
|
+
* cannot change a primary key or rename-and-retype in place, so the table is
|
|
11264
|
+
* rebuilt in the current shape inside one write transaction. Legacy run ids
|
|
11265
|
+
* are unique, so they become the new row ids.
|
|
11266
|
+
*/
|
|
11267
|
+
async #migrateLegacyTriggersTable() {
|
|
11268
|
+
const isLegacy = async () => await this.#db.hasColumn(TABLE_SCHEDULE_TRIGGERS, "status") && !await this.#db.hasColumn(TABLE_SCHEDULE_TRIGGERS, "outcome");
|
|
11269
|
+
if (!await isLegacy()) return;
|
|
11270
|
+
const shadow = `${TABLE_SCHEDULE_TRIGGERS}__legacy_rebuild`;
|
|
11271
|
+
try {
|
|
11272
|
+
await this.#client.batch([
|
|
11273
|
+
`DROP TABLE IF EXISTS "${shadow}"`,
|
|
11274
|
+
`CREATE TABLE "${shadow}" (
|
|
11275
|
+
"id" TEXT NOT NULL PRIMARY KEY,
|
|
11276
|
+
"schedule_id" TEXT NOT NULL,
|
|
11277
|
+
"run_id" TEXT,
|
|
11278
|
+
"scheduled_fire_at" INTEGER NOT NULL,
|
|
11279
|
+
"actual_fire_at" INTEGER NOT NULL,
|
|
11280
|
+
"outcome" TEXT NOT NULL,
|
|
11281
|
+
"error" TEXT,
|
|
11282
|
+
"trigger_kind" TEXT NOT NULL,
|
|
11283
|
+
"parent_trigger_id" TEXT,
|
|
11284
|
+
"metadata" TEXT
|
|
11285
|
+
)`,
|
|
11286
|
+
`INSERT INTO "${shadow}" ("id", "schedule_id", "run_id", "scheduled_fire_at", "actual_fire_at", "outcome", "error", "trigger_kind")
|
|
11287
|
+
SELECT "run_id", "schedule_id", "run_id", "scheduled_fire_at", "actual_fire_at", "status", "error", 'schedule-fire'
|
|
11288
|
+
FROM "${TABLE_SCHEDULE_TRIGGERS}"`,
|
|
11289
|
+
`DROP TABLE "${TABLE_SCHEDULE_TRIGGERS}"`,
|
|
11290
|
+
`ALTER TABLE "${shadow}" RENAME TO "${TABLE_SCHEDULE_TRIGGERS}"`
|
|
11291
|
+
], "write");
|
|
11292
|
+
} catch (error) {
|
|
11293
|
+
if (await isLegacy()) throw error;
|
|
11294
|
+
}
|
|
11295
|
+
}
|
|
11250
11296
|
async dangerouslyClearAll() {
|
|
11251
11297
|
await this.#db.deleteData({ tableName: TABLE_SCHEDULE_TRIGGERS });
|
|
11252
11298
|
await this.#db.deleteData({ tableName: TABLE_SCHEDULES });
|