@mastra/mysql 0.8.5-alpha.0 → 0.8.5-alpha.2

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/README.md CHANGED
@@ -8,51 +8,9 @@ MySQL storage implementation for Mastra, providing persistent storage for thread
8
8
  npm install @mastra/mysql
9
9
  ```
10
10
 
11
- ## Prerequisites
12
-
13
- - MySQL 8.0 or higher
14
-
15
11
  ## Usage
16
12
 
17
- ```typescript
18
- import { MySQLStore } from '@mastra/mysql';
19
-
20
- const store = new MySQLStore({
21
- connectionString: 'mysql://user:password@localhost:3306/mastra',
22
- });
23
-
24
- // Create a thread
25
- await store.saveThread({
26
- thread: {
27
- id: 'thread-123',
28
- resourceId: 'resource-456',
29
- title: 'My Thread',
30
- metadata: { key: 'value' },
31
- createdAt: new Date(),
32
- updatedAt: new Date(),
33
- },
34
- });
35
-
36
- // Add messages to thread
37
- await store.saveMessages({
38
- messages: [
39
- {
40
- id: 'msg-789',
41
- threadId: 'thread-123',
42
- role: 'user',
43
- content: { content: 'Hello' },
44
- resourceId: 'resource-456',
45
- createdAt: new Date(),
46
- },
47
- ],
48
- });
49
-
50
- // Query threads and messages
51
- const savedThread = await store.getThreadById({ threadId: 'thread-123' });
52
- const messages = await store.listMessages({ threadId: 'thread-123' });
53
- ```
54
-
55
- ### With Mastra
13
+ Configure the database credentials required by your provider.
56
14
 
57
15
  ```typescript
58
16
  import { Mastra } from '@mastra/core';
@@ -65,88 +23,14 @@ export const mastra = new Mastra({
65
23
  });
66
24
  ```
67
25
 
68
- ## Configuration
69
-
70
- `MySQLStore` supports two connection methods:
71
-
72
- **1. Connection String**
73
-
74
- ```typescript
75
- const store = new MySQLStore({
76
- connectionString: 'mysql://user:password@localhost:3306/mastra',
77
- });
78
- ```
79
-
80
- **2. Host/Port/Database**
26
+ ## Documentation
81
27
 
82
- ```typescript
83
- const store = new MySQLStore({
84
- host: 'localhost',
85
- port: 3306,
86
- user: 'mastra',
87
- password: 'mastra',
88
- database: 'mastra',
89
- });
90
- ```
91
-
92
- ### Optional Configuration
93
-
94
- - `ssl`: Enable SSL or provide custom SSL options (`true` | `false` | object)
95
- - `max`: Maximum pool connections (default: `10`)
96
- - `database`: Override the database name parsed from the connection string
97
- - `waitForConnections`: Queue requests when the pool is full (default: `true`, host config only)
98
- - `queueLimit`: Maximum queued connection requests, `0` for unlimited (default: `0`, host config only)
99
- - `skipDefaultIndexes`: Skip creating the built-in performance indexes during setup (default: `false`)
100
- - `indexes`: Additional custom indexes to create during setup
101
-
102
- ## Features
103
-
104
- - Persistent storage for threads, messages, workflows, scores, datasets, and experiments
105
- - Full observability/tracing storage (spans and traces)
106
- - Atomic transactions for data consistency
107
- - Efficient batch operations
108
- - Connection pooling via `mysql2`
109
- - Automatic table and index setup on first use
110
- - Rich metadata support with JSON columns
111
- - Timestamp tracking and cascading deletes
112
-
113
- ## Storage Methods
114
-
115
- - `saveThread({ thread })`: Create or update a thread
116
- - `getThreadById({ threadId })`: Get a thread by ID
117
- - `deleteThread({ threadId })`: Delete a thread and its messages
118
- - `saveMessages({ messages })`: Save multiple messages in a transaction
119
- - `listMessages({ threadId, perPage?, page? })`: Get messages for a thread with pagination
120
- - `deleteMessages(messageIds)`: Delete specific messages
121
-
122
- ## Development
28
+ This README is the package guide. `MySQLStore` provides Mastra's storage domains through a MySQL connection pool, including agents, messages, workflows, observability, scores, datasets, prompt blocks, MCP records, and workspaces.
123
29
 
124
- ### Environment Variables
30
+ ## Changelog
125
31
 
126
- The test suite reads the following variables to connect to MySQL, falling back to the defaults shown:
127
-
128
- - `MYSQL_HOST` (default: `localhost`)
129
- - `MYSQL_PORT` (default: `3306`)
130
- - `MYSQL_USER` (default: `mastra`)
131
- - `MYSQL_PASSWORD` (default: `mastra`)
132
- - `MYSQL_DB` (default: `mastra`)
133
-
134
- ### Running Tests
135
-
136
- Unit tests run without a database:
137
-
138
- ```bash
139
- pnpm test src/storage/index.unit.test.ts
140
- ```
141
-
142
- Integration tests use Docker to start a MySQL instance, run the suite, and clean up afterward:
143
-
144
- ```bash
145
- # Ensure Docker is running
146
- pnpm test
147
- ```
32
+ See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/stores/mysql/CHANGELOG.md) for version history and release notes.
148
33
 
149
- ## Related Links
34
+ ## Support
150
35
 
151
- - [Mastra Storage Documentation](https://mastra.ai/docs)
152
- - [MySQL Documentation](https://dev.mysql.com/doc/)
36
+ We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
package/dist/index.cjs CHANGED
@@ -10379,6 +10379,7 @@ function rowToDefinition(row) {
10379
10379
  if (transformed.metadata != null) def.metadata = transformed.metadata;
10380
10380
  if (transformed.stateSchema != null) def.stateSchema = transformed.stateSchema;
10381
10381
  if (transformed.requestContextSchema != null) def.requestContextSchema = transformed.requestContextSchema;
10382
+ if (transformed.schedule != null) def.schedule = transformed.schedule;
10382
10383
  if (transformed.authorId != null) def.authorId = String(transformed.authorId);
10383
10384
  return def;
10384
10385
  }
@@ -10404,6 +10405,11 @@ var WorkflowDefinitionsMySQL = class extends _mastra_core_storage.WorkflowDefini
10404
10405
  tableName: _mastra_core_storage.TABLE_WORKFLOW_DEFINITIONS,
10405
10406
  schema: _mastra_core_storage.WORKFLOW_DEFINITIONS_SCHEMA
10406
10407
  });
10408
+ await this.operations.alterTable({
10409
+ tableName: _mastra_core_storage.TABLE_WORKFLOW_DEFINITIONS,
10410
+ schema: _mastra_core_storage.WORKFLOW_DEFINITIONS_SCHEMA,
10411
+ ifNotExists: ["schedule"]
10412
+ });
10407
10413
  }
10408
10414
  async dangerouslyClearAll() {
10409
10415
  await this.operations.clearTable({ tableName: _mastra_core_storage.TABLE_WORKFLOW_DEFINITIONS });
@@ -10423,6 +10429,7 @@ var WorkflowDefinitionsMySQL = class extends _mastra_core_storage.WorkflowDefini
10423
10429
  stateSchema: input.stateSchema ?? null,
10424
10430
  requestContextSchema: input.requestContextSchema ?? null,
10425
10431
  graph: input.graph,
10432
+ schedule: "schedule" in input ? input.schedule ?? null : null,
10426
10433
  status: "active",
10427
10434
  source: "storage",
10428
10435
  authorId: "authorId" in input ? input.authorId ?? null : null,
@@ -10453,6 +10460,7 @@ var WorkflowDefinitionsMySQL = class extends _mastra_core_storage.WorkflowDefini
10453
10460
  if ("stateSchema" in input && input.stateSchema !== void 0) data.stateSchema = input.stateSchema;
10454
10461
  if ("requestContextSchema" in input && input.requestContextSchema !== void 0) data.requestContextSchema = input.requestContextSchema;
10455
10462
  if ("graph" in input && input.graph !== void 0) data.graph = input.graph;
10463
+ if ("schedule" in input && input.schedule !== void 0) data.schedule = input.schedule;
10456
10464
  if ("status" in input && input.status !== void 0) data.status = input.status;
10457
10465
  if ("authorId" in input && input.authorId !== void 0) data.authorId = input.authorId;
10458
10466
  await this.operations.update({