drivethrough-cli 0.1.11 → 0.1.12

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 (2) hide show
  1. package/dist/main.mjs +29 -13
  2. package/package.json +1 -1
package/dist/main.mjs CHANGED
@@ -1071,25 +1071,41 @@ var init_universal = __esm({
1071
1071
  json TEXT,
1072
1072
  created_at TEXT
1073
1073
  )`,
1074
- `CREATE INDEX IF NOT EXISTS idx_type ON data(type)`,
1075
- // idx_parent is PARTIAL. D1 bills a written row per index touched, so a full
1076
- // index on parent_id charged every insert for an entry the common case never
1077
- // reads: most rows are top-level (a form submission with no parent), and
1078
- // `WHERE parent_id = ?` can only match a non-null value. Excluding NULLs
1079
- // keeps every query that used it — `type = ?1 AND parent_id = ?2` — on an
1080
- // index, while top-level inserts stop paying for it.
1074
+ // ---- platform indexes ------------------------------------------------------
1075
+ // Named `dt_*`, never `idx_*`. generatedColumnName() emits `idx_<type>_<field>`
1076
+ // for a site's DECLARED indexes, so a site declaring type "type" with an index
1077
+ // on "$.recent" would land on `idx_type_recent` — and applyDeclaredIndexes only
1078
+ // checks for a colliding COLUMN, not a colliding INDEX, so its
1079
+ // `CREATE INDEX IF NOT EXISTS` would silently no-op and the site's declared
1080
+ // index would never exist. `dt_` is unreachable from that generator.
1081
+ //
1082
+ // Each statement pair DROPs the previous name before creating the current one:
1083
+ // `CREATE ... IF NOT EXISTS` would otherwise see the old index and keep it, so
1084
+ // databases provisioned earlier would never upgrade. Once upgraded both are
1085
+ // no-ops, which keeps init() cheap to re-run.
1086
+ // (type, created_at), not (type). Every query against this table leads with
1087
+ // `type`, and the list queries all end `ORDER BY created_at DESC LIMIT n`.
1088
+ // On the single column, SQLite filtered by type and then sorted EVERY row of
1089
+ // that type to honour the ORDER BY — a 10k-row type returning 100 read 10k.
1090
+ // The composite serves the filter exactly as before and satisfies the sort by
1091
+ // walking the index backwards, stopping at the LIMIT. It is still one index,
1092
+ // and D1 bills a written row per index touched rather than per column, so the
1093
+ // read win costs nothing on writes.
1094
+ `DROP INDEX IF EXISTS idx_type`,
1095
+ `CREATE INDEX IF NOT EXISTS dt_type_recent ON data(type, created_at)`,
1096
+ // PARTIAL. A full index on parent_id charged every insert for an entry the
1097
+ // common case never reads: most rows are top-level (a form submission with no
1098
+ // parent), and `WHERE parent_id = ?` can only match a non-null value.
1099
+ // Excluding NULLs keeps every query that used it — `type = ?1 AND
1100
+ // parent_id = ?2` — on an index, while top-level inserts stop paying for it.
1081
1101
  //
1082
1102
  // The one reader of NULL parents (selectSessionRow's `parent_id IS NULL`
1083
1103
  // branch) cannot use a partial index, and did not want this one anyway: it
1084
1104
  // filters on type first, and for the unique_per types it actually runs on,
1085
1105
  // uniq_session_<type> covers it.
1086
- //
1087
- // DROP first, under the old name: databases created before this change
1088
- // already hold the full index, and `CREATE ... IF NOT EXISTS` would see it
1089
- // and silently keep it. Renaming makes both statements true no-ops once the
1090
- // upgrade has happened, so init() stays cheap to re-run.
1091
1106
  `DROP INDEX IF EXISTS idx_parent`,
1092
- `CREATE INDEX IF NOT EXISTS idx_parent_present ON data(parent_id) WHERE parent_id IS NOT NULL`
1107
+ `DROP INDEX IF EXISTS idx_parent_present`,
1108
+ `CREATE INDEX IF NOT EXISTS dt_parent_present ON data(parent_id) WHERE parent_id IS NOT NULL`
1093
1109
  ];
1094
1110
  UNIVERSAL_SCHEMA_SQL = UNIVERSAL_SCHEMA_STATEMENTS.join(";\n") + ";";
1095
1111
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drivethrough-cli",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "Agent-first hosting CLI. Say what you want. Stay in the car.",
5
5
  "type": "module",
6
6
  "license": "MIT",