@voltro/database 0.87.0 → 0.88.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.
Files changed (170) hide show
  1. package/CHANGELOG.md +169 -6
  2. package/THIRD-PARTY-NOTICES.md +1 -1
  3. package/dist/actorSnapshot.js +1 -2
  4. package/dist/arrayCodec.js +1 -2
  5. package/dist/branchExecute.js +1 -2
  6. package/dist/branching.js +1 -2
  7. package/dist/bulkInsertLimits.js +16 -12
  8. package/dist/cdcOffsetsTables.js +1 -2
  9. package/dist/changeEvent.js +1 -2
  10. package/dist/changeIdentity.js +1 -2
  11. package/dist/changeListenerCeiling.js +1 -2
  12. package/dist/columnReference.js +1 -2
  13. package/dist/columns.js +1 -2
  14. package/dist/committedChanges.js +1 -2
  15. package/dist/connectionIdentity.js +1 -2
  16. package/dist/coreTables.js +1 -2
  17. package/dist/coreTablesRegistry.js +1 -2
  18. package/dist/dataTransfers.js +1 -2
  19. package/dist/dbCause.js +1 -2
  20. package/dist/dbMetrics.js +1 -2
  21. package/dist/decimalComparison.js +1 -2
  22. package/dist/derivedRowId.js +1 -2
  23. package/dist/dialect.js +1 -2
  24. package/dist/enumRenames.js +1 -2
  25. package/dist/expiresMixin.js +1 -2
  26. package/dist/fieldEncryption.js +1 -2
  27. package/dist/frameworkTables.js +1 -2
  28. package/dist/ginIndex.js +1 -2
  29. package/dist/hybridSearch.js +1 -2
  30. package/dist/idGenerator.js +1 -2
  31. package/dist/identifierLimits.js +1 -2
  32. package/dist/index.d.ts +5 -7
  33. package/dist/index.js +1 -2
  34. package/dist/indexAudit.js +45 -44
  35. package/dist/indexStorage.js +1 -2
  36. package/dist/joinCompiler.js +1 -2
  37. package/dist/jsonEagerCompiler.js +1 -2
  38. package/dist/jsonPatch.js +1 -2
  39. package/dist/jsonPatchAssignments.js +1 -2
  40. package/dist/jsonPath.js +1 -2
  41. package/dist/localFirstMixin.js +1 -2
  42. package/dist/migrate.js +1 -2
  43. package/dist/migration.js +1 -2
  44. package/dist/migrations/appliedAtValue.js +1 -2
  45. package/dist/migrations/applier.js +1 -2
  46. package/dist/migrations/boot.js +2 -3
  47. package/dist/migrations/branchRehearsal.js +1 -2
  48. package/dist/migrations/columnEquivalence.js +1 -2
  49. package/dist/migrations/ddlError.js +1 -2
  50. package/dist/migrations/ddlStatements.js +1 -2
  51. package/dist/migrations/declaredSchema.js +2 -3
  52. package/dist/migrations/deployLedger.js +1 -2
  53. package/dist/migrations/fileBased.js +1 -2
  54. package/dist/migrations/fileContext.js +1 -2
  55. package/dist/migrations/fileDiscovery.js +1 -2
  56. package/dist/migrations/fileSkipProbes.js +1 -2
  57. package/dist/migrations/fingerprint.js +1 -2
  58. package/dist/migrations/fkCycles.js +1 -2
  59. package/dist/migrations/frameworkLiveTables.js +1 -2
  60. package/dist/migrations/idempotentDdl.js +1 -2
  61. package/dist/migrations/indexPredicate.js +1 -2
  62. package/dist/migrations/introspect.js +3 -4
  63. package/dist/migrations/ledgerRows.js +1 -2
  64. package/dist/migrations/lock.js +1 -2
  65. package/dist/migrations/migrationTableExists.js +1 -2
  66. package/dist/migrations/mssqlColumnDependencies.js +1 -2
  67. package/dist/migrations/mysqlEngine.js +1 -2
  68. package/dist/migrations/namespaceCharset.js +1 -2
  69. package/dist/migrations/planner.js +3 -4
  70. package/dist/migrations/postgresEnumCheck.js +1 -2
  71. package/dist/migrations/reactiveTriggerDrift.js +1 -2
  72. package/dist/migrations/reactiveTriggerName.js +1 -2
  73. package/dist/migrations/renameMssqlCheck.js +1 -2
  74. package/dist/migrations/restoreSnapshots.js +1 -2
  75. package/dist/migrations/resumeLedger.js +1 -2
  76. package/dist/migrations/rollingDeploy.js +1 -2
  77. package/dist/migrations/schemaOwner.js +1 -2
  78. package/dist/migrations/schemaOwnerTable.js +1 -2
  79. package/dist/migrations/softDropSnapshot.js +1 -2
  80. package/dist/migrations/sqlLimit.js +1 -2
  81. package/dist/migrations/sqliteCatalogName.js +1 -2
  82. package/dist/migrations/sqliteConstraintIdentity.js +1 -2
  83. package/dist/migrations/sqliteDecimalBoot.js +1 -2
  84. package/dist/migrations/sqliteDecimalPublication.js +1 -2
  85. package/dist/migrations/sqliteDecimalReview.js +1 -2
  86. package/dist/migrations/sqliteDecimalReviewStore.js +1 -2
  87. package/dist/migrations/sqliteDecimalReviewWitness.js +1 -2
  88. package/dist/migrations/sqliteDecimalSource.js +1 -2
  89. package/dist/migrations/sqliteDecimalStage.js +1 -2
  90. package/dist/migrations/sqliteForeignKeys.js +1 -2
  91. package/dist/migrations/sqliteMigrationBatch.js +1 -2
  92. package/dist/migrations/sqliteRetainedSource.js +1 -2
  93. package/dist/migrations/sqliteRowIdentity.js +1 -2
  94. package/dist/migrations/sqliteSchemaEpoch.js +1 -2
  95. package/dist/migrations/sqliteSnapshotGuard.js +1 -2
  96. package/dist/migrations/sqliteTableContents.js +1 -2
  97. package/dist/migrations/sqliteTableCopy.js +1 -2
  98. package/dist/migrations/sqliteTableSchema.js +1 -2
  99. package/dist/migrations/sqliteWitnessProtection.js +1 -2
  100. package/dist/migrations/squash.js +1 -2
  101. package/dist/migrations/storeCharset.js +1 -2
  102. package/dist/migrations/transactionCause.js +1 -2
  103. package/dist/migrations/undeclaredCharset.js +1 -2
  104. package/dist/migrations/uniqueActiveLowering.js +1 -2
  105. package/dist/mixins.js +1 -2
  106. package/dist/mssqlDecimalDistinct.js +1 -2
  107. package/dist/mssqlJsonValueCheck.js +1 -2
  108. package/dist/mssqlTextStorage.js +1 -2
  109. package/dist/namespace.js +1 -2
  110. package/dist/optimisticVersion.js +1 -2
  111. package/dist/pendingAttribution.js +1 -2
  112. package/dist/pluginRef.js +1 -2
  113. package/dist/predicate.js +1 -2
  114. package/dist/predicateCoercion.js +1 -2
  115. package/dist/projectedColumn.js +1 -2
  116. package/dist/queryBuilder.js +1 -2
  117. package/dist/rawSql.js +1 -2
  118. package/dist/relations.js +1 -2
  119. package/dist/relationsRegistry.js +1 -2
  120. package/dist/replaceInProgress.js +1 -2
  121. package/dist/requiredColumns.js +1 -2
  122. package/dist/residency.js +1 -2
  123. package/dist/retention.js +1 -2
  124. package/dist/rowDecoder.js +1 -2
  125. package/dist/rowKey.js +1 -2
  126. package/dist/rowSchema.js +1 -2
  127. package/dist/scopeKey.js +1 -2
  128. package/dist/seed.js +1 -2
  129. package/dist/snowflake.js +1 -2
  130. package/dist/sqlCompiler.js +1 -2
  131. package/dist/sqlError.js +1 -2
  132. package/dist/sqlMutation.js +1 -2
  133. package/dist/sqlPoolCapacity.js +1 -2
  134. package/dist/sqliteDecimal.js +1 -2
  135. package/dist/sqliteDecimalAggregateSql.js +1 -2
  136. package/dist/sqliteDecimalColumnSql.js +1 -2
  137. package/dist/sqliteDecimalConversion.js +1 -2
  138. package/dist/sqliteDecimalCte.js +1 -2
  139. package/dist/sqliteDecimalEncodeSql.js +1 -2
  140. package/dist/sqliteDecimalOutputs.js +1 -2
  141. package/dist/sqliteDecimalPredicate.js +1 -2
  142. package/dist/sqliteDecimalQuery.js +1 -2
  143. package/dist/sqliteDecimalQueryPlan.js +1 -2
  144. package/dist/sqliteDecimalResultSql.js +1 -2
  145. package/dist/sqliteDecimalRowQuery.js +1 -2
  146. package/dist/sqliteDecimalSetQuery.js +1 -2
  147. package/dist/sqliteDecimalSource.js +1 -2
  148. package/dist/sqliteDecimalStorage.js +1 -2
  149. package/dist/sqliteDecimalSubquery.js +1 -2
  150. package/dist/sqliteDecimalWindowQuery.js +1 -2
  151. package/dist/sqliteValueCoercion.js +1 -2
  152. package/dist/stampId.js +1 -2
  153. package/dist/storeErrors.js +1 -2
  154. package/dist/storeRefusal.js +1 -2
  155. package/dist/stream.js +1 -2
  156. package/dist/subjectGraph.js +1 -2
  157. package/dist/table.js +1 -2
  158. package/dist/tableRegistry.js +1 -2
  159. package/dist/tenantSelection.js +1 -2
  160. package/dist/transactionOutcome.js +1 -2
  161. package/dist/transientContention.js +1 -2
  162. package/dist/typeId.js +1 -2
  163. package/dist/typedStore.js +1 -2
  164. package/dist/upsertUpdate.js +1 -2
  165. package/dist/vectorEmbedding.js +1 -2
  166. package/dist/view.js +1 -2
  167. package/dist/wire.js +1 -2
  168. package/dist/writeAttribution.js +1 -2
  169. package/dist/writeRecorder.js +1 -2
  170. package/package.json +3 -3
@@ -10,7 +10,7 @@ import { postgresEnumCheckValues as l } from "./postgresEnumCheck.js";
10
10
  import { sqliteCatalogKey as u, sqliteCatalogName as d } from "./sqliteCatalogName.js";
11
11
  import { sqliteNamedUniqueConstraints as f, sqliteUniqueColumnsKey as p } from "./sqliteConstraintIdentity.js";
12
12
  import { Effect as m } from "effect";
13
- //#region src/migrations/introspect.ts
13
+ // src/migrations/introspect.ts
14
14
  var h = (e) => {
15
15
  let t = [String(e)], n = e.cause;
16
16
  for (let e = 0; e < 6 && n != null; e++) t.push(typeof n == "object" && typeof n.message == "string" ? n.message : String(n)), n = typeof n == "object" ? n.cause : void 0;
@@ -501,12 +501,12 @@ var h = (e) => {
501
501
  }), m = new Set(n.map((e) => e.source_column)), g = [];
502
502
  if (s) for (let [t, n] of s) {
503
503
  let r = [...n].sort((e, t) => e.seq_in_index - t.seq_in_index);
504
- (r.length !== 1 || r[0].non_unique !== 0) && (r.length === 1 && r[0].non_unique !== 0 && m.has(r[0].column_name) && t !== `${e.table_name}_${r[0].column_name}_idx` || g.push({
504
+ r.length === 1 && r[0].non_unique === 0 || r.length === 1 && r[0].non_unique !== 0 && m.has(r[0].column_name) && t !== `${e.table_name}_${r[0].column_name}_idx` || g.push({
505
505
  name: t,
506
506
  table: e.table_name,
507
507
  columns: r.map((e) => e.column_name),
508
508
  unique: r[0].non_unique === 0
509
- }));
509
+ });
510
510
  }
511
511
  i.length > 0 && g.push({
512
512
  name: `${e.table_name}_pkey`,
@@ -797,5 +797,4 @@ var h = (e) => {
797
797
  ...e,
798
798
  tables: e.tables.filter((e) => !H.has(e.name))
799
799
  })));
800
- //#endregion
801
800
  export { E as chunkTables, U as introspectSchema, _ as mapPgType, g as parseEnumCheck };
@@ -1,4 +1,3 @@
1
- //#region src/migrations/ledgerRows.ts
1
+ // src/migrations/ledgerRows.ts
2
2
  var e = (e) => e.literal("(source = 'file' AND id NOT LIKE 'plan!_%' ESCAPE '!')"), t = (e) => e.literal("(source IS NULL OR source <> 'file' OR id LIKE 'plan!_%' ESCAPE '!')");
3
- //#endregion
4
3
  export { t as describesSchema, e as isFileMigrationRow };
@@ -1,6 +1,6 @@
1
1
  import { sqlPoolCapacity as e } from "../sqlPoolCapacity.js";
2
2
  import { Effect as t, Exit as n, Fiber as r, Scope as i } from "effect";
3
- //#region src/migrations/lock.ts
3
+ // src/migrations/lock.ts
4
4
  var a = (e, t) => e.executeUnprepared(t, [], void 0), o = 6322741009312437n, s = (e) => {
5
5
  let t = e?.trim();
6
6
  return t === void 0 || t === "" || t === "public" ? void 0 : t;
@@ -87,5 +87,4 @@ var a = (e, t) => e.executeUnprepared(t, [], void 0), o = 6322741009312437n, s =
87
87
  connection: g
88
88
  };
89
89
  }), k = "a migration needs 2 connections: one holds the migration lock for the whole apply, the other runs the statements. The pool could not hand out the second one — raise its size (DB_MAX_CONNECTIONS / PG_MAX_CONNECTIONS, or the driver's own `maxConnections`) to at least 2 for the migrating process; behind a pooler (PgBouncer, Supavisor) point the migration at the database directly (DB_DIRECT_URL / DB_MIGRATE_URL).", A = (e) => /acquire connection/i.test(String(e?.message ?? e)), j = (e, n, r) => t.acquireUseRelease(O(e, r), () => n.pipe(t.tapError((e) => A(e) ? t.logError(`migrate: ${k}`).pipe(t.annotateLogs({ scope: "voltro:migrate" })) : t.void)), (e) => e.release.pipe(t.orDie));
90
- //#endregion
91
90
  export { k as MIGRATION_NEEDS_TWO_CONNECTIONS, o as VOLTRO_MIGRATION_LOCK_KEY, O as acquireMigrationLock, f as fnv1a64, p as migrationLockKeyForSchema, m as migrationLockNameForSchema, c as resolveMigrationLockSchema, j as withMigrationLock };
@@ -1,9 +1,8 @@
1
1
  import { dialectOf as e } from "./resumeLedger.js";
2
2
  import { Effect as t } from "effect";
3
- //#region src/migrations/migrationTableExists.ts
3
+ // src/migrations/migrationTableExists.ts
4
4
  var n = (n, r) => {
5
5
  let i = e(n);
6
6
  return (i === "sqlite" ? n`SELECT COUNT(*) AS n FROM sqlite_master WHERE type = 'table' AND name = ${r}` : i === "mysql" ? n`SELECT COUNT(*) AS n FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = ${r}` : i === "mssql" ? n`SELECT COUNT(*) AS n FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME = ${r}` : n`SELECT COUNT(*) AS n FROM information_schema.tables WHERE table_schema = current_schema() AND table_name = ${r}`).pipe(t.map((e) => Number(e[0]?.n ?? 0) > 0));
7
7
  };
8
- //#endregion
9
8
  export { n as migrationTableExists };
@@ -1,7 +1,7 @@
1
1
  import { quoteIdent as e } from "../dialect.js";
2
2
  import { sqlError as t } from "../sqlError.js";
3
3
  import { Effect as n } from "effect";
4
- //#region src/migrations/mssqlColumnDependencies.ts
4
+ // src/migrations/mssqlColumnDependencies.ts
5
5
  var r = (t) => e(t, "mssql"), i = (e, i, a, o) => n.gen(function* () {
6
6
  let s = yield* e`
7
7
  SELECT 'foreign key' AS kind FROM sys.foreign_key_columns f
@@ -72,5 +72,4 @@ var r = (t) => e(t, "mssql"), i = (e, i, a, o) => n.gen(function* () {
72
72
  ];
73
73
  yield* n.forEach(g, (t) => e.unsafe(t), { discard: !0 });
74
74
  });
75
- //#endregion
76
75
  export { i as alterColumnWithDependenciesMssql };
@@ -1,5 +1,5 @@
1
1
  import { Effect as e } from "effect";
2
- //#region src/migrations/mysqlEngine.ts
2
+ // src/migrations/mysqlEngine.ts
3
3
  var t = (e) => /mariadb/i.test(e) ? "mariadb" : "mysql", n = /* @__PURE__ */ new WeakMap(), r = (t) => e.suspend(() => {
4
4
  let r = n.get(t);
5
5
  return r === void 0 ? i(t).pipe(e.tap((r) => e.sync(() => n.set(t, r)))) : e.succeed(r);
@@ -7,5 +7,4 @@ var t = (e) => /mariadb/i.test(e) ? "mariadb" : "mysql", n = /* @__PURE__ */ new
7
7
  let n = e[0]?.v;
8
8
  return typeof n == "string" ? t(n) : "mysql";
9
9
  }), e.catch(() => e.succeed("mysql")));
10
- //#endregion
11
10
  export { t as engineFromVersion, r as resolveMysqlEngine };
@@ -1,7 +1,7 @@
1
1
  import { storeCharsetFindings as e } from "./storeCharset.js";
2
2
  import { Effect as t } from "effect";
3
3
  import { SqlClient as n } from "effect/sql";
4
- //#region src/migrations/namespaceCharset.ts
4
+ // src/migrations/namespaceCharset.ts
5
5
  var r = "tenant_", i = (e) => e.map((e) => Object.fromEntries(Object.entries(e).map(([e, t]) => [e.toLowerCase(), t]))), a = async (a, o) => a(t.gen(function* () {
6
6
  let a = yield* n.SqlClient, s = i(yield* a`
7
7
  SELECT schema_name FROM information_schema.schemata
@@ -47,5 +47,4 @@ var r = "tenant_", i = (e) => e.map((e) => Object.fromEntries(Object.entries(e).
47
47
  }
48
48
  return c;
49
49
  }));
50
- //#endregion
51
50
  export { a as tenantNamespaceCharsetFindings };
@@ -7,7 +7,7 @@ import { canonicalIdColumn as c, comparableDefault as l, hasComparableType as u,
7
7
  import { fingerprintSchema as b } from "./fingerprint.js";
8
8
  import { charsetColumnsOf as x, columnTakesCharset as S } from "./storeCharset.js";
9
9
  import { declaredSnapshot as C } from "./declaredSchema.js";
10
- //#region src/migrations/planner.ts
10
+ // src/migrations/planner.ts
11
11
  var w = {
12
12
  postgres: !0,
13
13
  mysql: !0,
@@ -135,11 +135,11 @@ var w = {
135
135
  let l = [], u = [];
136
136
  for (let t of e.indexes) {
137
137
  let e = o.get(i(t.name));
138
- (!e || !I(t, e)) && l.push(t);
138
+ e && I(t, e) || l.push(t);
139
139
  }
140
140
  for (let e of t.indexes) {
141
141
  let t = s.get(i(e.name)) ?? c.get(e);
142
- (!t || !I(t, a?.get(e) ?? e)) && u.push(e);
142
+ t && I(t, a?.get(e) ?? e) || u.push(e);
143
143
  }
144
144
  return {
145
145
  added: l,
@@ -781,5 +781,4 @@ var w = {
781
781
  }
782
782
  };
783
783
  };
784
- //#endregion
785
784
  export { Z as planMigrations };
@@ -1,4 +1,4 @@
1
- //#region src/migrations/postgresEnumCheck.ts
1
+ // src/migrations/postgresEnumCheck.ts
2
2
  var e = (e, t) => {
3
3
  let n = (e.match(/'(?:''|[^'])*'|"(?:""|[^"])*"|::|[A-Za-z_][A-Za-z_0-9$]*|[^\s]/g) ?? []).filter((e) => e !== "(" && e !== ")"), r = 0, i = (e) => n[r]?.toLowerCase() === e && (r++, !0);
4
4
  if (!i("check")) return null;
@@ -18,5 +18,4 @@ var e = (e, t) => {
18
18
  } while (s && i(","));
19
19
  return s && (!i("]") || i("::") && (!i("text") || !i("[") || !i("]"))) ? null : r === n.length ? c : null;
20
20
  };
21
- //#endregion
22
21
  export { e as postgresEnumCheckValues };
@@ -1,6 +1,6 @@
1
1
  import { DEFAULT_CDC_CHANNEL as e, REACTIVE_TRIGGER_PREFIX as t, notifyFunctionName as n, storedReactiveTriggerName as r } from "./reactiveTriggerName.js";
2
2
  import { Effect as i } from "effect";
3
- //#region src/migrations/reactiveTriggerDrift.ts
3
+ // src/migrations/reactiveTriggerDrift.ts
4
4
  var a = (a, o, s = e) => i.gen(function* () {
5
5
  let e = (yield* a`
6
6
  SELECT p.prosrc
@@ -54,5 +54,4 @@ var a = (a, o, s = e) => i.gen(function* () {
54
54
  }
55
55
  return e.functionOutdated && n.push("The change-notify function in this database is OLDER than the framework installed here. Its triggers fire, so nothing looks wrong — but a row too large for a NOTIFY payload (postgres caps it at 8000 bytes) is emitted without its primary key, and a change that carries no key cannot be re-read: it reaches subscriptions as a re-query and reaches every TAP — search index, analytics mirror, cdc-out, row history — as nothing at all. Run `voltro db apply` to replace it."), n.length > 0 ? n.join("\n") : void 0;
56
56
  };
57
- //#endregion
58
57
  export { t as REACTIVE_TRIGGER_PREFIX, a as detectReactiveTriggerDrift, o as formatReactiveTriggerDrift };
@@ -1,7 +1,6 @@
1
- //#region src/migrations/reactiveTriggerName.ts
1
+ // src/migrations/reactiveTriggerName.ts
2
2
  var e = "framework_changes", t = "framework_changes_", n = (e, n) => n === "framework_changes" ? `${t}${e}` : `${t}${n}_${e}`, r = (e, t) => a(n(e, t).replace(/[A-Z]/g, (e) => e.toLowerCase())), i = 63, a = (e) => {
3
3
  let t = new TextEncoder().encode(e);
4
4
  return t.length <= i ? e : new TextDecoder().decode(t.subarray(0, i)).replace(/�+$/u, "");
5
5
  }, o = (e) => e === "framework_changes" ? "framework_notify_change" : `framework_notify_change_${e}`, s = "voltro:notify:v2";
6
- //#endregion
7
6
  export { e as DEFAULT_CDC_CHANNEL, s as NOTIFY_BODY_MARKER, t as REACTIVE_TRIGGER_PREFIX, o as notifyFunctionName, n as reactiveTriggerName, r as storedReactiveTriggerName };
@@ -1,5 +1,5 @@
1
1
  import { quoteIdent as e } from "../dialect.js";
2
- //#region src/migrations/renameMssqlCheck.ts
2
+ // src/migrations/renameMssqlCheck.ts
3
3
  var t = (t, n, r) => {
4
4
  let i = t.match(/'(?:''|[^'])*'|\[(?:\]\]|[^\]])*\]|\s+|[^'\[\s]+/g) ?? [];
5
5
  if (i.join("") !== t || i.some((e) => !e.startsWith("'") && !e.startsWith("[") && /"|\/\*|--/.test(e))) throw Error("Cannot safely rename CHECK: unsupported catalog SQL; use an explicit migration");
@@ -17,5 +17,4 @@ var t = (t, n, r) => {
17
17
  if (o === 0 || i.join("").length === 0) throw Error(`Cannot safely rename CHECK reference '${n}': no exact catalog column token; use an explicit migration`);
18
18
  return i.join("");
19
19
  };
20
- //#endregion
21
20
  export { t as renameMssqlCheck };
@@ -6,7 +6,7 @@ import { withMigrationTransaction as a } from "./transactionCause.js";
6
6
  import { runMigrationOp as o } from "./applier.js";
7
7
  import { Effect as s } from "effect";
8
8
  import { SqlClient as c } from "effect/sql";
9
- //#region src/migrations/restoreSnapshots.ts
9
+ // src/migrations/restoreSnapshots.ts
10
10
  var l = (e) => {
11
11
  let t = /* @__PURE__ */ new Map();
12
12
  for (let n of e) n.kind === "table" && !t.has(n.originalName) && t.set(n.originalName, n.snapshotName);
@@ -202,5 +202,4 @@ var l = (e) => {
202
202
  });
203
203
  return n(t(i)) === "plan-transactional" ? a(i, e) : e;
204
204
  }, (e) => e.release.pipe(s.orDie));
205
- //#endregion
206
205
  export { f as findMigrationSnapshotCandidates, g as planSnapshotRestoration, p as readMigrationSnapshotCandidates, _ as restoreMigrationSnapshots };
@@ -1,6 +1,6 @@
1
1
  import { id as e, integer as t, text as n, timestamp as r } from "../columns.js";
2
2
  import { table as i } from "../table.js";
3
- //#region src/migrations/resumeLedger.ts
3
+ // src/migrations/resumeLedger.ts
4
4
  var a = (e) => e.onDialectOrElse({
5
5
  pg: () => "postgres",
6
6
  mysql: () => "mysql",
@@ -82,5 +82,4 @@ var a = (e) => e.onDialectOrElse({
82
82
  return n === "postgres" && e.kind === "add-index" && t === "online-required" || e.kind === "alter-column-type" && t === "online-required" || r && _.has(e.kind) ? "artefact-repair" : v.has(e.kind) ? "idempotent" : "probe-then-replay";
83
83
  };
84
84
  Object.keys(o);
85
- //#endregion
86
85
  export { o as MIGRATION_ATOMICITY, c as MIGRATION_OPS_TABLE, h as SHADOW_COLUMN_SUFFIX, g as SHADOW_OLD_SUFFIX, m as SQLITE_REBUILD_SUFFIX, l as _voltroMigrationOpsTable, a as dialectOf, s as migrationAtomicityFor, p as opStillOutstanding, d as opTargetLabel, u as opTargets, f as opsShareTarget, y as resumeIdempotencyFor };
@@ -1,4 +1,4 @@
1
- //#region src/migrations/rollingDeploy.ts
1
+ // src/migrations/rollingDeploy.ts
2
2
  var e = (e) => new Set(e.flatMap((e) => e.op.kind === "create-table" ? [e.op.table] : [])), t = (e, t) => t !== void 0 && "table" in e && t.createdTables.has(e.table), n = { safe: !0 }, r = (e, r) => {
3
3
  if (t(e, r)) return n;
4
4
  switch (e.kind) {
@@ -102,5 +102,4 @@ var e = (e) => new Set(e.flatMap((e) => e.op.kind === "create-table" ? [e.op.tab
102
102
  message: `${t}. Old instances would break against the new schema mid-rollout. Split into expand → deploy → contract (see the ⚠ list above), deploy with no overlap (maintenance window / scale-to-zero), or pass --force to override.`
103
103
  };
104
104
  };
105
- //#endregion
106
105
  export { a as assessRollingDeployGate, r as classifyRollingDeploySafety, e as createdTablesOf, i as rollingDeployUnsafeOps };
@@ -3,7 +3,7 @@ import { SCHEMA_OWNER_TABLE as t } from "./schemaOwnerTable.js";
3
3
  import { appliedAtValue as n } from "./appliedAtValue.js";
4
4
  import { ensureSchemaOwnerTable as r } from "./applier.js";
5
5
  import { Effect as i } from "effect";
6
- //#region src/migrations/schemaOwner.ts
6
+ // src/migrations/schemaOwner.ts
7
7
  var a = "owner", o = (e) => i.map(e`SELECT ${e("appName")}, ${e("claimedAt")} FROM ${e(t)} WHERE ${e("id")} = ${a}`, (e) => e[0]), s = (e, t) => e.appName === t ? { kind: "owned" } : {
8
8
  kind: "foreign",
9
9
  owner: e.appName,
@@ -42,5 +42,4 @@ var a = "owner", o = (e) => i.map(e`SELECT ${e("appName")}, ${e("claimedAt")} FR
42
42
  claimedAt: l
43
43
  })} WHERE ${e("id")} = ${a}`, { previous: i?.appName };
44
44
  }), d = (e, t, n) => `this database belongs to the app '${t}'${n === void 0 ? "" : ` (claimed ${n})`}, and '${e}' is a different app. Two apps on one schema each plan to drop the other's tables, and their data is shared with no contract between them. Give this app its own database (DB_URL) or its own schema (DB_SCHEMA); if it needs the other app's data, call it — \`apis:\` on this app, \`service:\` procedures on the other. If this app was RENAMED from '${t}', run \`voltro db claim\` once to hand the schema over.`;
45
- //#endregion
46
45
  export { t as SCHEMA_OWNER_TABLE, l as checkSchemaOwner, d as foreignOwnerMessage, u as transferSchemaOwner };
@@ -1,4 +1,3 @@
1
- //#region src/migrations/schemaOwnerTable.ts
1
+ // src/migrations/schemaOwnerTable.ts
2
2
  var e = "_voltro_schema_owner";
3
- //#endregion
4
3
  export { e as SCHEMA_OWNER_TABLE };
@@ -1,4 +1,4 @@
1
- //#region src/migrations/softDropSnapshot.ts
1
+ // src/migrations/softDropSnapshot.ts
2
2
  var e = (e, t) => {
3
3
  let n = e.op;
4
4
  if (n.kind !== "drop-column" && n.kind !== "drop-table") return e;
@@ -16,5 +16,4 @@ var e = (e, t) => {
16
16
  if (typeof r != "string" || !r.startsWith(`${n}__dropped_`) || !/^\d{14}$/.test(r.slice(n.length + 10))) throw Error("Soft-drop snapshot does not identify the original object");
17
17
  return r;
18
18
  };
19
- //#endregion
20
19
  export { e as bindSoftDropSnapshot, t as readSoftDropSnapshot };
@@ -1,8 +1,7 @@
1
1
  import { dialectOf as e } from "./resumeLedger.js";
2
- //#region src/migrations/sqlLimit.ts
2
+ // src/migrations/sqlLimit.ts
3
3
  var t = (t, n) => {
4
4
  let r = Math.max(1, Math.floor(Number.isFinite(n) ? n : 1));
5
5
  return t.literal(e(t) === "mssql" ? `OFFSET 0 ROWS FETCH NEXT ${r} ROWS ONLY` : `LIMIT ${r}`);
6
6
  };
7
- //#endregion
8
7
  export { t as limitClause };
@@ -1,4 +1,4 @@
1
- //#region src/migrations/sqliteCatalogName.ts
1
+ // src/migrations/sqliteCatalogName.ts
2
2
  var e = (e) => e.replace(/[A-Z]/g, (e) => e.toLowerCase()), t = String.raw`(?:"(?:""|[^"])*"|\x60(?:\x60\x60|[^\x60])*\x60|\[[^\]]*\]|'(?:''|[^'])*'|[^\s.(]+)`, n = {
3
3
  table: String.raw`CREATE\s+(?:TEMP(?:ORARY)?\s+)?TABLE`,
4
4
  index: String.raw`CREATE\s+(?:UNIQUE\s+)?INDEX`
@@ -9,5 +9,4 @@ var e = (e) => e.replace(/[A-Z]/g, (e) => e.toLowerCase()), t = String.raw`(?:"(
9
9
  let c = s[0], l = c === "\"" ? s.slice(1, -1).replaceAll("\"\"", "\"") : c === "`" ? s.slice(1, -1).replaceAll("``", "`") : c === "[" ? s.slice(1, -1) : c === "'" ? s.slice(1, -1).replaceAll("''", "'") : s;
10
10
  return e(l) === e(i) ? l : i;
11
11
  }, i = e;
12
- //#endregion
13
12
  export { i as sqliteCatalogKey, r as sqliteCatalogName };
@@ -1,4 +1,4 @@
1
- //#region src/migrations/sqliteConstraintIdentity.ts
1
+ // src/migrations/sqliteConstraintIdentity.ts
2
2
  var e = (e) => e.replace(/[A-Z]/g, (e) => e.toLowerCase()), t = (t) => JSON.stringify(t.map(e)), n = (e) => {
3
3
  let t = [];
4
4
  for (let n = 0; n < e.length;) {
@@ -93,5 +93,4 @@ var e = (e) => e.replace(/[A-Z]/g, (e) => e.toLowerCase()), t = (t) => JSON.stri
93
93
  }
94
94
  return l === 0 ? i : /* @__PURE__ */ new Map();
95
95
  };
96
- //#endregion
97
96
  export { r as sqliteNamedUniqueConstraints, t as sqliteUniqueColumnsKey };
@@ -2,7 +2,7 @@ import { parseSqliteDecimalStorageType as e, sqliteDecimalStorageShape as t } fr
2
2
  import { sqlError as n } from "../sqlError.js";
3
3
  import { dialectOf as r } from "./resumeLedger.js";
4
4
  import { Effect as i } from "effect";
5
- //#region src/migrations/sqliteDecimalBoot.ts
5
+ // src/migrations/sqliteDecimalBoot.ts
6
6
  var a = (a, o) => i.gen(function* () {
7
7
  if (o.length === 0) return;
8
8
  let s = r(a);
@@ -18,5 +18,4 @@ var a = (a, o) => i.gen(function* () {
18
18
  }
19
19
  }
20
20
  });
21
- //#endregion
22
21
  export { a as verifySqliteDecimalStorage };
@@ -13,7 +13,7 @@ import { sqliteTableCopyDifferenceSql as _ } from "./sqliteTableCopy.js";
13
13
  import { sqliteRetainedReviewNames as v, sqliteRetainedSourceNames as y } from "./sqliteRetainedSource.js";
14
14
  import { prepareSqliteDecimalStage as b } from "./sqliteDecimalStage.js";
15
15
  import { Effect as x } from "effect";
16
- //#region src/migrations/sqliteDecimalPublication.ts
16
+ // src/migrations/sqliteDecimalPublication.ts
17
17
  var S = (s, p, g, C = []) => x.gen(function* () {
18
18
  let j = (t) => x.fail(e(t));
19
19
  if (!p.decimalReview) return yield* j("Decimal publication requires reviewed conversion decisions");
@@ -253,5 +253,4 @@ var S = (s, p, g, C = []) => x.gen(function* () {
253
253
  }),
254
254
  catch: (t) => e("Invalid decimal publication review", t)
255
255
  }), A = (e) => `(SELECT json_group_array(json_object('type',type,'name',name,'sql',sql,'table',tbl_name)) FROM (SELECT type,name,sql,tbl_name FROM main.sqlite_master WHERE tbl_name IN (${e.map(E).join(", ")}) AND type IN ('table','index','trigger') ORDER BY tbl_name COLLATE BINARY,type COLLATE BINARY,name COLLATE BINARY))`;
256
- //#endregion
257
256
  export { w as cleanupSqliteDecimalPublication, S as publishSqliteDecimalStage, C as rollbackSqliteDecimalPublication };
@@ -1,5 +1,5 @@
1
1
  import { convertSqliteDecimalValue as e } from "../sqliteDecimalConversion.js";
2
- //#region src/migrations/sqliteDecimalReview.ts
2
+ // src/migrations/sqliteDecimalReview.ts
3
3
  var t = (e) => {
4
4
  let t = e.value;
5
5
  return JSON.stringify({
@@ -26,5 +26,4 @@ var t = (e) => {
26
26
  }
27
27
  };
28
28
  }, r = (e) => JSON.stringify([e.rowIdentity, e.column]);
29
- //#endregion
30
29
  export { n as normalizeSqliteDecimalCell, r as sqliteDecimalDecisionIdentity, t as sqliteDecimalObservationIdentity };
@@ -8,7 +8,7 @@ import { createSqliteDecimalReviewWitness as l } from "./sqliteDecimalReviewWitn
8
8
  import { sqliteWitnessProtectionStatements as u } from "./sqliteWitnessProtection.js";
9
9
  import { Effect as d, Option as f } from "effect";
10
10
  import { SqlClient as p } from "effect/sql";
11
- //#region src/migrations/sqliteDecimalReviewStore.ts
11
+ // src/migrations/sqliteDecimalReviewStore.ts
12
12
  var m = (n, i, a) => d.gen(function* () {
13
13
  let s = (t) => e("Invalid stored decimal review", t), l = yield* p.SqlClient, m = yield* d.serviceOption(l.transactionService);
14
14
  if (f.isNone(m)) return yield* d.fail(e("Decimal review import requires a pinned transaction"));
@@ -184,5 +184,4 @@ var m = (n, i, a) => d.gen(function* () {
184
184
  catch: i
185
185
  });
186
186
  }), C = (e) => Buffer.from(s(e), "utf16le").swap16().toString("hex"), w = (e) => "\"" + e.replaceAll("\"", "\"\"") + "\"";
187
- //#endregion
188
187
  export { x as forEachSqliteDecimalReviewRow, m as importSqliteDecimalReview, g as readSqliteDecimalReviewStore, h as reopenSqliteDecimalReview, b as verifySqliteDecimalReviewCoverage, v as verifySqliteDecimalReviewStore };
@@ -1,6 +1,6 @@
1
1
  import { normalizeSqliteDecimalCell as e, sqliteDecimalDecisionIdentity as t } from "./sqliteDecimalReview.js";
2
2
  import { createHash as n } from "node:crypto";
3
- //#region src/migrations/sqliteDecimalReviewWitness.ts
3
+ // src/migrations/sqliteDecimalReviewWitness.ts
4
4
  var r = () => {
5
5
  let e = n("sha256").update("["), r = 0, i, a = !1, o = !1;
6
6
  return {
@@ -34,5 +34,4 @@ var r = () => {
34
34
  n.return?.();
35
35
  }
36
36
  };
37
- //#endregion
38
37
  export { r as createSqliteDecimalReviewWitness, i as sqliteDecimalReviewInputWitness };
@@ -2,7 +2,7 @@ import { encodeSqliteDecimal as e } from "../sqliteDecimal.js";
2
2
  import { sqlError as t } from "../sqlError.js";
3
3
  import { readSqliteTableSchema as n } from "./sqliteTableSchema.js";
4
4
  import { Effect as r } from "effect";
5
- //#region src/migrations/sqliteDecimalSource.ts
5
+ // src/migrations/sqliteDecimalSource.ts
6
6
  var i = (e) => `CASE WHEN typeof(${e}) IN ('text','blob') THEN hex(${e}) ELSE quote(${e}) END`, a = (a, o, c, l, u) => r.gen(function* () {
7
7
  let d = (e) => r.fail(t(e));
8
8
  if (c.length === 0 || new Set(c).size !== c.length || new Set(l.map((e) => e.name)).size !== l.length) return yield* d("Decimal source requires distinct key and conversion columns");
@@ -65,5 +65,4 @@ var i = (e) => `CASE WHEN typeof(${e}) IN ('text','blob') THEN hex(${e}) ELSE qu
65
65
  for (let t of e) o.push(t);
66
66
  })), o;
67
67
  }), s = (e) => "\"" + e.replaceAll("\"", "\"\"") + "\"";
68
- //#endregion
69
68
  export { a as forEachSqliteDecimalSourcePage, o as readSqliteDecimalSource, i as sqliteDecimalKeyValueSql };
@@ -15,7 +15,7 @@ import { forEachSqliteDecimalReviewRow as h } from "./sqliteDecimalReviewStore.j
15
15
  import { prepareSqliteRetainedSource as g } from "./sqliteRetainedSource.js";
16
16
  import { Effect as _, Option as v } from "effect";
17
17
  import { SqlClient as y } from "effect/sql";
18
- //#region src/migrations/sqliteDecimalStage.ts
18
+ // src/migrations/sqliteDecimalStage.ts
19
19
  var b = (b, T, E) => _.gen(function* () {
20
20
  let y = (e) => _.fail(n(e)), D = T.decimalReview;
21
21
  if (!D || D.columns.length === 0 || E.name !== T.source) return yield* y("Decimal stage requires complete reviewed cells and the matching target table");
@@ -131,5 +131,4 @@ var b = (b, T, E) => _.gen(function* () {
131
131
  };
132
132
  return t(0, e.length);
133
133
  };
134
- //#endregion
135
134
  export { b as prepareSqliteDecimalStage };
@@ -1,6 +1,6 @@
1
1
  import { sqlError as e } from "../sqlError.js";
2
2
  import { Effect as t } from "effect";
3
- //#region src/migrations/sqliteForeignKeys.ts
3
+ // src/migrations/sqliteForeignKeys.ts
4
4
  var n = (e) => "\"" + e.replaceAll("\"", "\"\"") + "\"", r = (e) => e.replace(/[A-Z]/g, (e) => e.toLowerCase()), i = (i) => t.gen(function* () {
5
5
  let a = (e) => i.executeUnprepared(e, [], void 0), o = () => t.fail(e("SQLite schema rewrite would leave invalid foreign key references")), s = yield* a("SELECT name FROM main.sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'"), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
6
6
  for (let { name: e } of s) {
@@ -34,5 +34,4 @@ var n = (e) => "\"" + e.replaceAll("\"", "\"\"") + "\"", r = (e) => e.replace(/[
34
34
  }
35
35
  }
36
36
  });
37
- //#endregion
38
37
  export { i as assertSqliteForeignKeys };
@@ -3,7 +3,7 @@ import { dialectOf as t } from "./resumeLedger.js";
3
3
  import { assertSqliteForeignKeys as n } from "./sqliteForeignKeys.js";
4
4
  import { Effect as r, Option as i } from "effect";
5
5
  import { randomUUID as a } from "node:crypto";
6
- //#region src/migrations/sqliteMigrationBatch.ts
6
+ // src/migrations/sqliteMigrationBatch.ts
7
7
  var o = (t, n) => r.try({
8
8
  try: () => t.executeUnprepared(n, [], void 0),
9
9
  catch: (t) => e("Failed to prepare SQLite migration statement", t)
@@ -33,5 +33,4 @@ var o = (t, n) => r.try({
33
33
  }), (e) => e.committed ? r.void : i("ROLLBACK").pipe(r.orDie)), () => s.pipe(r.orDie));
34
34
  }));
35
35
  });
36
- //#endregion
37
36
  export { c as registerSqliteMigrationBatch, u as runSqliteMigrationBatch, o as runSqliteMigrationStatement, l as sqliteMigrationBatchStatements };
@@ -12,7 +12,7 @@ import { assertSqliteTableCopy as h } from "./sqliteTableCopy.js";
12
12
  import { Effect as g, Option as _ } from "effect";
13
13
  import { createHash as v } from "node:crypto";
14
14
  import { SqlClient as y } from "effect/sql";
15
- //#region src/migrations/sqliteRetainedSource.ts
15
+ // src/migrations/sqliteRetainedSource.ts
16
16
  var b = (e) => {
17
17
  let t = `_voltro_review_${v("sha256").update(JSON.stringify([e.migrationId, e.source])).digest("hex")}`;
18
18
  return {
@@ -102,5 +102,4 @@ var b = (e) => {
102
102
  };
103
103
  })) : yield* y("Retained sources require a SQLite-family client");
104
104
  }).pipe(g.provideService(y.SqlClient, v)), C = (e) => "\"" + e.replaceAll("\"", "\"\"") + "\"", w = (e) => "'" + e.replaceAll("'", "''") + "'";
105
- //#endregion
106
105
  export { S as prepareSqliteRetainedSource, b as sqliteRetainedReviewNames, x as sqliteRetainedSourceNames };
@@ -2,7 +2,7 @@ import { sqlError as e } from "../sqlError.js";
2
2
  import { sqliteDecimalKeyValueSql as t } from "./sqliteDecimalSource.js";
3
3
  import { Effect as n } from "effect";
4
4
  import { createHash as r } from "node:crypto";
5
- //#region src/migrations/sqliteRowIdentity.ts
5
+ // src/migrations/sqliteRowIdentity.ts
6
6
  var i = (e) => {
7
7
  if (typeof e != "object" || !e) return !1;
8
8
  let t = e;
@@ -59,5 +59,4 @@ WHERE ${o === void 0 ? "1" : `${r} > CAST(? AS INTEGER)`} ORDER BY ${r} LIMIT 25
59
59
  if (!/^\d+$/.test(n)) throw TypeError("Invalid SQLite sequence watermark");
60
60
  return t.sequenceBackend === "turso" ? [`SELECT setval(${g(p(e))},${n})`] : [`UPDATE main.sqlite_sequence SET seq=${n} WHERE name=${g(e)}`, `INSERT INTO main.sqlite_sequence(name,seq) SELECT ${g(e)},${n} WHERE NOT EXISTS (SELECT 1 FROM main.sqlite_sequence WHERE name=${g(e)})`];
61
61
  }, f = (e) => `CAST(json_array(${e.map((e) => `json_array(typeof(${h(e)}), ${t(h(e))})`).join(", ")}) AS TEXT)`, p = (e) => "__turso_internal_autoincrement_" + e, m = (e) => "__turso_internal_seq_" + p(e), h = (e) => "\"" + e.replaceAll("\"", "\"\"") + "\"", g = (e) => "'" + e.replaceAll("'", "''") + "'";
62
- //#endregion
63
62
  export { s as assertSqliteRowIdentity, i as isSqliteRowIdentity, o as readSqliteRowIdentity, d as restoreSqliteSequenceSql, a as sqliteRowidAlias, u as sqliteSequenceMatchesSql };
@@ -1,6 +1,6 @@
1
1
  import { sqlError as e } from "../sqlError.js";
2
2
  import { Effect as t } from "effect";
3
- //#region src/migrations/sqliteSchemaEpoch.ts
3
+ // src/migrations/sqliteSchemaEpoch.ts
4
4
  var n = (n) => t.gen(function* () {
5
5
  let r = yield* n.executeUnprepared("PRAGMA main.schema_version", [], void 0), i = r[0]?.schema_version;
6
6
  return r.length !== 1 || typeof i != "number" || !Number.isInteger(i) || i < -2147483648 || i > 2147483647 ? yield* t.fail(e("Cannot verify SQLite schema epoch")) : i;
@@ -8,5 +8,4 @@ var n = (n) => t.gen(function* () {
8
8
  if (!Number.isInteger(e) || e < -2147483648 || e > 2147483647 || !Number.isSafeInteger(t) || t < 0 || t > 2147483647) throw TypeError("Invalid SQLite schema epoch guard");
9
9
  return `(SELECT schema_version FROM pragma_schema_version) = ${e + t | 0}`;
10
10
  };
11
- //#endregion
12
11
  export { n as readSqliteSchemaEpoch, r as sqliteSchemaEpochMatchesSql };
@@ -2,9 +2,8 @@ import { sqlError as e } from "../sqlError.js";
2
2
  import { assertSqliteRowIdentity as t } from "./sqliteRowIdentity.js";
3
3
  import { assertSqliteTableContents as n } from "./sqliteTableContents.js";
4
4
  import { Effect as r } from "effect";
5
- //#region src/migrations/sqliteSnapshotGuard.ts
5
+ // src/migrations/sqliteSnapshotGuard.ts
6
6
  var i = (e, i, o, s) => r.gen(function* () {
7
7
  yield* a(o, s), yield* n(e, i, o), yield* t(e, i, s);
8
8
  }), a = (t, n) => JSON.stringify(t.columns) === JSON.stringify(n.columns) ? r.void : r.fail(e("Retained content and physical identity columns differ"));
9
- //#endregion
10
9
  export { i as assertSqliteSnapshot };
@@ -3,7 +3,7 @@ import { readSqliteTableSchema as t } from "./sqliteTableSchema.js";
3
3
  import { sqliteDecimalKeyValueSql as n } from "./sqliteDecimalSource.js";
4
4
  import { Effect as r } from "effect";
5
5
  import { createHash as i } from "node:crypto";
6
- //#region src/migrations/sqliteTableContents.ts
6
+ // src/migrations/sqliteTableContents.ts
7
7
  var a = 1024, o = (o, s) => r.gen(function* () {
8
8
  yield* t(o, s);
9
9
  let c = (yield* o.executeUnprepared(`PRAGMA main.table_xinfo(${l(s)})`, [], void 0)).map((e) => e.name);
@@ -30,5 +30,4 @@ GROUP BY ${u} COLLATE BINARY ORDER BY ${u} COLLATE BINARY LIMIT ${a}`, f === voi
30
30
  let a = yield* s(t, n);
31
31
  if (a.digest !== i.digest || JSON.stringify(a.columns) !== JSON.stringify(i.columns)) return yield* r.fail(e("Retained source contents changed; refuse publication or rollback"));
32
32
  }), l = (e) => "\"" + e.replaceAll("\"", "\"\"") + "\"";
33
- //#endregion
34
33
  export { c as assertSqliteTableContents, s as readSqliteTableContents };
@@ -1,7 +1,7 @@
1
1
  import { sqlError as e } from "../sqlError.js";
2
2
  import { assertSqliteTableSchema as t } from "./sqliteTableSchema.js";
3
3
  import { Effect as n } from "effect";
4
- //#region src/migrations/sqliteTableCopy.ts
4
+ // src/migrations/sqliteTableCopy.ts
5
5
  var r = (e) => "\"" + e.replaceAll("\"", "\"\"") + "\"", i = (e, t, n) => {
6
6
  if (n.length === 0) throw TypeError("Table copy comparison requires columns");
7
7
  let i = n.flatMap((e) => [`typeof(${r(e)})`, `${r(e)} COLLATE BINARY`]), a = (e) => `SELECT ${i.join(", ")}, COUNT(*) FROM main.${r(e)} GROUP BY ${i.join(", ")}`;
@@ -21,5 +21,4 @@ OR EXISTS (SELECT * FROM missing_from_source)`;
21
21
  if (d.length === 0 || d.length !== f.length || d.some((e, t) => e !== f[t])) return yield* l("source and copy columns differ");
22
22
  if ((yield* a.executeUnprepared(i(o, s, d), [], void 0)).length > 0) return yield* l("source rows changed or the retained copy is incomplete");
23
23
  });
24
- //#endregion
25
24
  export { a as assertSqliteTableCopy, i as sqliteTableCopyDifferenceSql };
@@ -1,6 +1,6 @@
1
1
  import { sqlError as e } from "../sqlError.js";
2
2
  import { Effect as t } from "effect";
3
- //#region src/migrations/sqliteTableSchema.ts
3
+ // src/migrations/sqliteTableSchema.ts
4
4
  var n = (e, t) => {
5
5
  let n = `main.sqlite_master WHERE tbl_name = ${r(e)} COLLATE NOCASE AND type IN ('table', 'index', 'trigger')`;
6
6
  return [`(SELECT COUNT(*) FROM ${n}) = ${t.objects.length}`, ...t.objects.map((e) => `EXISTS (SELECT 1 FROM ${n} AND type = ${r(e.type)} AND name = ${r(e.name)} AND sql IS ${e.sql === null ? "NULL" : r(e.sql)})`)].join(" AND ");
@@ -15,5 +15,4 @@ var n = (e, t) => {
15
15
  let o = yield* i(n, r);
16
16
  if (JSON.stringify(o) !== JSON.stringify(a)) return yield* t.fail(e("Source table schema changed; retain the source and review the conversion stage again"));
17
17
  });
18
- //#endregion
19
18
  export { a as assertSqliteTableSchema, i as readSqliteTableSchema, n as sqliteTableSchemaMatchesSql };
@@ -1,8 +1,7 @@
1
- //#region src/migrations/sqliteWitnessProtection.ts
1
+ // src/migrations/sqliteWitnessProtection.ts
2
2
  var e = (e, t) => n.map((n) => `CREATE TRIGGER ${r(`${t}_protect_${n.toLowerCase()}`)} BEFORE ${n} ON ${r(e)} BEGIN SELECT RAISE(ABORT, 'Retained conversion witness is immutable'); END`), t = (e) => n.map((t) => `DROP TRIGGER ${r(`${e}_protect_${t.toLowerCase()}`)}`), n = [
3
3
  "INSERT",
4
4
  "UPDATE",
5
5
  "DELETE"
6
6
  ], r = (e) => "\"" + e.replaceAll("\"", "\"\"") + "\"";
7
- //#endregion
8
7
  export { t as dropSqliteWitnessProtectionStatements, e as sqliteWitnessProtectionStatements };
@@ -3,7 +3,7 @@ import { withMigrationTransaction as t } from "./transactionCause.js";
3
3
  import { Effect as n } from "effect";
4
4
  import { createHash as r, randomUUID as i } from "node:crypto";
5
5
  import { SqlClient as a } from "effect/sql";
6
- //#region src/migrations/squash.ts
6
+ // src/migrations/squash.ts
7
7
  var o = (e) => n.gen(function* () {
8
8
  let t = yield* a.SqlClient;
9
9
  if (!Number.isFinite(Date.parse(e.before))) return yield* n.fail(/* @__PURE__ */ Error("squash: cut-off must be a valid date"));
@@ -77,5 +77,4 @@ var o = (e) => n.gen(function* () {
77
77
  };
78
78
  })));
79
79
  });
80
- //#endregion
81
80
  export { s as previewMigrationSquash, c as squashMigrationPlans };
@@ -1,6 +1,6 @@
1
1
  import { isMysqlFamily as e } from "../dialect.js";
2
2
  import { isSoftDropSnapshotName as t } from "./frameworkLiveTables.js";
3
- //#region src/migrations/storeCharset.ts
3
+ // src/migrations/storeCharset.ts
4
4
  var n = ["utf8mb3", "utf8mb4"], r = (e) => e === "utf8mb3" || e === "utf8mb4", i = (e) => {
5
5
  switch (e.type) {
6
6
  case "text":
@@ -62,5 +62,4 @@ var n = ["utf8mb3", "utf8mb4"], r = (e) => e === "utf8mb3" || e === "utf8mb4", i
62
62
  case "mixed": return `${e.table}: its string columns are not in one character set — ${t}`;
63
63
  }
64
64
  }, d = "declare the store's character set in app.config.ts — store: { dialect: 'mariadb' | 'mysql', charset: 'utf8mb4' } — and run `voltro db plan`: every table the app declares is created with it and converted to it (a table rewrite; foreign keys are re-created around it). `utf8mb3` is accepted too, for a database that must stay there.";
65
- //#endregion
66
65
  export { n as MYSQL_CHARSETS, d as STORE_CHARSET_REMEDY, o as charsetColumnsOf, i as columnTakesCharset, u as describeStoreCharsetFinding, r as isMysqlCharset, a as stampDeclaredCharset, l as storeCharsetFindings };
@@ -1,10 +1,9 @@
1
1
  import { Cause as e, Effect as t, Equal as n } from "effect";
2
- //#region src/migrations/transactionCause.ts
2
+ // src/migrations/transactionCause.ts
3
3
  var r = (r, i) => t.suspend(() => {
4
4
  let a;
5
5
  return r.withTransaction(i.pipe(t.tapCause((e) => t.sync(() => {
6
6
  a = e;
7
7
  })))).pipe(t.catchCause((r) => t.failCause(a !== void 0 && !n.equals(a, r) ? e.combine(a, r) : r)));
8
8
  });
9
- //#endregion
10
9
  export { r as withMigrationTransaction };