@mastra/pg 1.17.0-alpha.3 → 1.17.0-alpha.4

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @mastra/pg
2
2
 
3
+ ## 1.17.0-alpha.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix factory storage error classification and schema drift handling. ([#20002](https://github.com/mastra-ai/mastra/pull/20002))
8
+
9
+ - `isUniqueViolation` in the LibSQL factory storage now only matches real unique-index violations (`SQLITE_CONSTRAINT_UNIQUE` / `SQLITE_CONSTRAINT_PRIMARYKEY`). Previously any `SQLITE_CONSTRAINT` failure — including NOT NULL violations — was reported as a "Unique constraint violation", which masked the real error (seen as `Unique constraint violation on collection 'factory_rule_evaluations'` when polled ingestion inserted nullable columns into a stale table).
10
+ - `ensureCollections` in both the LibSQL and Postgres factory storage adapters now relaxes stale NOT NULL constraints when a column becomes nullable in the schema. Postgres uses `ALTER COLUMN ... DROP NOT NULL`; LibSQL rebuilds the table in place since SQLite cannot drop NOT NULL directly. Existing rows and unique indexes are preserved.
11
+
12
+ - Updated dependencies:
13
+ - @mastra/core@1.52.0-alpha.13
14
+
3
15
  ## 1.17.0-alpha.3
4
16
 
5
17
  ### Patch Changes
@@ -3,7 +3,7 @@ name: mastra-pg
3
3
  description: Documentation for @mastra/pg. Use when working with @mastra/pg APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/pg"
6
- version: "1.17.0-alpha.3"
6
+ version: "1.17.0-alpha.4"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.17.0-alpha.3",
2
+ "version": "1.17.0-alpha.4",
3
3
  "package": "@mastra/pg",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -20620,6 +20620,10 @@ var PgFactoryStorage = class extends storage.FactoryStorage {
20620
20620
  for (const [name, spec] of Object.entries(schema.columns)) {
20621
20621
  await this.#pool.query(`ALTER TABLE "${schema.name}" ADD COLUMN IF NOT EXISTS ${this.#columnDdl(name, spec)}`);
20622
20622
  }
20623
+ for (const [name, spec] of Object.entries(schema.columns)) {
20624
+ if (!spec.nullable || spec.type === "uuid-pk" || spec.primaryKey) continue;
20625
+ await this.#pool.query(`ALTER TABLE "${schema.name}" ALTER COLUMN "${name}" DROP NOT NULL`);
20626
+ }
20623
20627
  for (const index of schema.uniqueIndexes ?? []) {
20624
20628
  assertIdentifier("index", index.name);
20625
20629
  index.columns.forEach((column) => assertIdentifier("column", column));