@ultimat3/entity 31.7.0 → 31.8.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/entity",
3
- "version": "31.7.0",
3
+ "version": "31.8.0",
4
4
  "description": "A table + its domain type + invariants the database also enforces",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -44,9 +44,9 @@
44
44
  "test": "bun test"
45
45
  },
46
46
  "dependencies": {
47
- "@ultimat3/core": "31.7.0",
48
- "@ultimat3/db": "31.7.0",
49
- "@ultimat3/schema": "31.7.0",
50
- "@ultimat3/time": "31.7.0"
47
+ "@ultimat3/core": "31.8.0",
48
+ "@ultimat3/db": "31.8.0",
49
+ "@ultimat3/schema": "31.8.0",
50
+ "@ultimat3/time": "31.8.0"
51
51
  }
52
52
  }
@@ -66,7 +66,8 @@ export const declaredIndexOf = <C extends ColumnMap>(
66
66
  // Absent stays absent: `btree` written out would be a field every existing snapshot lacks,
67
67
  // and `indexMethodOf` reads the two the same way precisely so nothing regenerates.
68
68
  ...(index.using === undefined || index.using === 'btree' ? {} : { using: index.using }),
69
- // How it is BUILT, so not part of the name: `true` or absent, like `appendOnly`.
70
- ...(index.concurrently === true ? { concurrently: true as const } : {}),
69
+ // How it is BUILT, so not part of the name. Absent stays absent — the default every existing
70
+ // index already projects — and only an explicit ask, either way, rides along.
71
+ ...(index.concurrently === undefined ? {} : { concurrently: index.concurrently }),
71
72
  };
72
73
  };
package/src/describe.ts CHANGED
@@ -363,8 +363,9 @@ export const describeEntity = <Row>(input: DescribeInput<Row>): EntityDescriptio
363
363
  // Spread, never `?? null`: absent is what `@ultimat3/db` reads as the btree it always was,
364
364
  // and a written-out `null` would be a field no existing snapshot carries.
365
365
  ...(index.using === undefined ? {} : { using: index.using }),
366
- // `true` or absent, never `false`, for the same reason: `x verify` hashes this projection.
367
- ...(index.concurrently === true ? { concurrently: true as const } : {}),
366
+ // Absent stays absent for the same reason — `x verify` hashes this projection, and an index
367
+ // that asks nothing must hash what it always did. An explicit ask, `true` or `false`, rides.
368
+ ...(index.concurrently === undefined ? {} : { concurrently: index.concurrently }),
368
369
  })),
369
370
  tags: input.tags,
370
371
  cacheTag: input.cacheTag,
@@ -28,8 +28,9 @@ const identity = (index: IndexDef): string =>
28
28
  * definition keeps both, and two `create index` statements sharing a name is `42P07` on the next
29
29
  * migration.
30
30
  *
31
- * A duplicate that asks for `concurrently: true` hands that ask to the one kept: dropping it would
32
- * silently build a hot table's index inside the migration's transaction after all.
31
+ * A duplicate's ask about how to build is handed to the one kept: `true` over everything, since
32
+ * dropping it would build a hot table's index inside a transaction after all, then an explicit
33
+ * `false` over the default it opted out of.
33
34
  */
34
35
  export function distinctIndexes(declared: readonly IndexDef[]): readonly IndexDef[] {
35
36
  return declared
@@ -37,10 +38,14 @@ export function distinctIndexes(declared: readonly IndexDef[]): readonly IndexDe
37
38
  (index, position) =>
38
39
  declared.findIndex((other) => identity(other) === identity(index)) === position,
39
40
  )
40
- .map((index) =>
41
- index.concurrently !== true &&
42
- declared.some((other) => other.concurrently === true && identity(other) === identity(index))
43
- ? { ...index, concurrently: true as const }
44
- : index,
45
- );
41
+ .map((index) => {
42
+ const asks = declared
43
+ .filter((other) => identity(other) === identity(index))
44
+ .map((other) => other.concurrently);
45
+ const ask = asks.includes(true) ? true : asks.includes(false) ? false : undefined;
46
+ // `undefined` means no duplicate asked, so `index` itself asked nothing either.
47
+ return ask === undefined || ask === index.concurrently
48
+ ? index
49
+ : { ...index, concurrently: ask };
50
+ });
46
51
  }
package/src/index-init.ts CHANGED
@@ -36,6 +36,9 @@ export interface IndexInit<C extends ColumnMap> {
36
36
  * `<id>_concurrently.sql` beside the migration (or as the migration, when it is the only change),
37
37
  * marked `-- transaction: false`; an index on a table the same migration creates is still built
38
38
  * inside that migration's transaction — the table is empty and nobody else can see it.
39
+ *
40
+ * Absent is the default: concurrent on a table that already exists; `false` is the plain build
41
+ * `x db gen` marks `-- lock-heavy: true`.
39
42
  */
40
43
  readonly concurrently?: boolean;
41
44
  }
package/src/registry.ts CHANGED
@@ -138,10 +138,11 @@ export interface IndexDescription {
138
138
  */
139
139
  readonly using?: IndexMethod | undefined;
140
140
  /**
141
- * `true` when the index is built with `create index concurrently`, outside a transaction; absent
142
- * otherwise, so an entity that never asked hashes exactly what it hashed before.
141
+ * How the index is built, when the entity asked: `true` for `create index concurrently` outside a
142
+ * transaction, `false` for the plain build `x db gen` marks `-- lock-heavy: true`. Absent is the
143
+ * default (concurrently on an existing table), so an entity that never asked hashes as before.
143
144
  */
144
- readonly concurrently?: true | undefined;
145
+ readonly concurrently?: boolean | undefined;
145
146
  }
146
147
 
147
148
  export interface EntityDescription {
package/src/types.ts CHANGED
@@ -489,6 +489,9 @@ export interface IndexDef {
489
489
  * one fact that this release exists to stop.
490
490
  */
491
491
  readonly using?: IndexMethod;
492
- /** `indexes: [{ concurrently: true }]` — `true` or absent, never `false` (`IndexInit`). */
493
- readonly concurrently?: true;
492
+ /**
493
+ * How it is built (`IndexInit`). Absent is the default: concurrently on a table that already
494
+ * exists. `false` is the opt-out, a plain build `x db gen` marks `-- lock-heavy: true`.
495
+ */
496
+ readonly concurrently?: boolean;
494
497
  }