@secondlayer/subgraphs 3.24.3 → 3.25.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/dist/src/index.js CHANGED
@@ -242,6 +242,13 @@ var TYPE_MAP = {
242
242
  timestamp: "TIMESTAMPTZ",
243
243
  jsonb: "JSONB"
244
244
  };
245
+ var MAX_IDENT_BYTES = 63;
246
+ function safeIndexName(name) {
247
+ if (name.length <= MAX_IDENT_BYTES)
248
+ return name;
249
+ const hash = createHash("sha256").update(name).digest("hex").slice(0, 8);
250
+ return `${name.slice(0, MAX_IDENT_BYTES - hash.length - 1)}_${hash}`;
251
+ }
245
252
  function escapeLiteralDefault(value) {
246
253
  if (value === null || value === undefined)
247
254
  return "NULL";
@@ -284,6 +291,7 @@ function emitTableDDL(schemaName, tableName, tableDef) {
284
291
  for (const [colName, col] of Object.entries(tableDef.columns)) {
285
292
  if (col.indexed) {
286
293
  statements.push(`CREATE INDEX IF NOT EXISTS ${quotePgIdent(`idx_${schemaName}_${tableName}_${colName}`)} ON ${qualifiedName} (${quotePgIdent(colName)})`);
294
+ statements.push(`CREATE INDEX IF NOT EXISTS ${quotePgIdent(safeIndexName(`idx_${schemaName}_${tableName}_${colName}_id`))} ON ${qualifiedName} (${quotePgIdent(colName)}, ${quotePgIdent("_id")})`);
287
295
  }
288
296
  }
289
297
  for (const [colName, col] of Object.entries(tableDef.columns)) {
@@ -5074,5 +5082,5 @@ export {
5074
5082
  ByoBreakingChangeError
5075
5083
  };
5076
5084
 
5077
- //# debugId=AD9497F805C348C364756E2164756E21
5085
+ //# debugId=4073E46E0CD7575564756E2164756E21
5078
5086
  //# sourceMappingURL=index.js.map