drivethrough-cli 0.1.10 → 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.
- package/dist/main.mjs +35 -2
- package/package.json +1 -1
package/dist/main.mjs
CHANGED
|
@@ -1071,8 +1071,41 @@ var init_universal = __esm({
|
|
|
1071
1071
|
json TEXT,
|
|
1072
1072
|
created_at TEXT
|
|
1073
1073
|
)`,
|
|
1074
|
-
|
|
1075
|
-
|
|
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.
|
|
1101
|
+
//
|
|
1102
|
+
// The one reader of NULL parents (selectSessionRow's `parent_id IS NULL`
|
|
1103
|
+
// branch) cannot use a partial index, and did not want this one anyway: it
|
|
1104
|
+
// filters on type first, and for the unique_per types it actually runs on,
|
|
1105
|
+
// uniq_session_<type> covers it.
|
|
1106
|
+
`DROP INDEX IF EXISTS idx_parent`,
|
|
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`
|
|
1076
1109
|
];
|
|
1077
1110
|
UNIVERSAL_SCHEMA_SQL = UNIVERSAL_SCHEMA_STATEMENTS.join(";\n") + ";";
|
|
1078
1111
|
}
|