-
Notifications
You must be signed in to change notification settings - Fork 16
ENSDb SDK: group database schema objects #1778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7b42209
1e56df4
a6b47b5
b528f5c
2f48b1c
6f3f1e6
abe0751
f7ece8f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "ensindexer": minor | ||
| --- | ||
|
|
||
| Made `ponder.schema.ts` to explicitly import just ENSIndexer Schema. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@ensnode/ensdb-sdk": minor | ||
| --- | ||
|
|
||
| Created isolated database schema definitions: ENSIndexer Schema and ENSNode Schema. | ||
tk-o marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| // export database schema definition for ENSIndexer | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we have this Is there a special reason why whatever is importing this
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a requirement from Ponder app:
Exports from the |
||
| export * from "@ensnode/ensdb-sdk"; | ||
| export * from "@ensnode/ensdb-sdk/ensindexer"; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| /** | ||
| * Merge the various sub-schemas into ENSIndexer Schema. | ||
| */ | ||
|
|
||
| // TODO: remove `ensnode-metadata.schema` export when database migrations | ||
| // for ENSNode Schema are executable. | ||
|
Comment on lines
+5
to
+6
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Track this TODO with an issue to avoid stale compatibility exports. Linking the removal condition to an issue/milestone will make cleanup auditable. Would you like me to draft an issue template with explicit removal criteria? 🤖 Prompt for AI Agents |
||
| export * from "./ensnode-metadata.schema"; | ||
| export * from "./ensv2.schema"; | ||
| export * from "./protocol-acceleration.schema"; | ||
| export * from "./registrars.schema"; | ||
| export * from "./subgraph.schema"; | ||
| export * from "./tokenscope.schema"; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import { pgSchema, primaryKey } from "drizzle-orm/pg-core"; | ||
|
|
||
| /** | ||
| * ENSNode Schema Name | ||
| * | ||
| * The name of the ENSNode schema in an ENSDb. | ||
| */ | ||
| const ENSNODE_SCHEMA_NAME = "ensnode"; | ||
|
|
||
| /** | ||
| * ENSNode Schema | ||
| * | ||
| * Defines database objects within the ENSNode Schema in ENSDb. | ||
| */ | ||
| const ENSNODE_SCHEMA = pgSchema(ENSNODE_SCHEMA_NAME); | ||
|
|
||
| /** | ||
| * ENSNode Metadata | ||
| * | ||
| * Possible key value pairs are defined by 'EnsNodeMetadata' type: | ||
| * - `EnsNodeMetadataEnsDbVersion` | ||
| * - `EnsNodeMetadataEnsIndexerPublicConfig` | ||
| * - `EnsNodeMetadataEnsIndexerIndexingStatus` | ||
| */ | ||
| export const metadata = ENSNODE_SCHEMA.table( | ||
| "metadata", | ||
| (t) => ({ | ||
tk-o marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /** | ||
| * ENSIndexer Schema Name | ||
| * | ||
| * References the name of the ENSIndexer Schema that the metadata record | ||
| * belongs to. This allows multi-tenancy where multiple ENSIndexer | ||
| * instances can write to the same ENSNode Metadata table. | ||
| */ | ||
| ensIndexerSchemaName: t.text().notNull(), | ||
|
|
||
| /** | ||
| * Key | ||
| * | ||
| * Allowed keys: | ||
| * - `EnsNodeMetadataEnsDbVersion['key']` | ||
| * - `EnsNodeMetadataEnsIndexerPublicConfig['key']` | ||
| * - `EnsNodeMetadataEnsIndexerIndexingStatus['key']` | ||
| */ | ||
| key: t.text().notNull(), | ||
|
|
||
| /** | ||
| * Value | ||
| * | ||
| * Allowed values: | ||
| * - `EnsNodeMetadataEnsDbVersion['value']` | ||
| * - `EnsNodeMetadataEnsIndexerPublicConfig['value']` | ||
| * - `EnsNodeMetadataEnsIndexerIndexingStatus['value']` | ||
| * | ||
| * Guaranteed to be a serialized representation of JSON object. | ||
| */ | ||
| value: t.jsonb().notNull(), | ||
| }), | ||
| (table) => [ | ||
| /** | ||
| * Primary key constraint on 'ensIndexerSchemaName' and 'key' columns, | ||
| * to ensure that there is only one record for each key per ENSIndexer instance. | ||
| */ | ||
| primaryKey({ | ||
| name: "metadata_pkey", | ||
| columns: [table.ensIndexerSchemaName, table.key], | ||
| }), | ||
|
Comment on lines
+35
to
+67
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify ENSNode metadata write paths include ensIndexerSchemaName and composite conflict targets.
# 1) Find imports/usages of ensdb-sdk ensnode schema.
rg -nP --type=ts -C3 '(`@ensnode/ensdb-sdk/ensnode`|ensdb-sdk/src/ensnode)'
# 2) Inspect metadata insert callsites and written fields.
rg -nP --type=ts -C6 '\.insert\(\s*(metadata|ensNodeMetadata)\s*\)'
rg -nP --type=ts -C8 '\.values\(\s*\{'
# 3) Inspect upsert conflict targets for composite key usage.
rg -nP --type=ts -C8 'onConflictDoUpdate\('
rg -nP --type=ts -C8 'target:\s*\[[^\]]*ensIndexerSchemaName[^\]]*key'Repository: namehash/ensnode Length of output: 50373 🏁 Script executed: # Get more context around the metadata insert in ensdb-client.ts
sed -n '150,230p' apps/ensindexer/src/lib/ensdb-client/ensdb-client.tsRepository: namehash/ensnode Length of output: 1777 🏁 Script executed: # Check imports and confirm what ensNodeMetadata is
head -50 apps/ensindexer/src/lib/ensdb-client/ensdb-client.tsRepository: namehash/ensnode Length of output: 1633 🏁 Script executed: # Search more specifically for ensNodeMetadata inserts/upserts to ensure we found all paths
rg -n "ensNodeMetadata" apps/ensindexer/src/lib/ensdb-client/ensdb-client.tsRepository: namehash/ensnode Length of output: 307 🏁 Script executed: # Find all calls to upsertEnsNodeMetadata
rg -n "upsertEnsNodeMetadata" --type tsRepository: namehash/ensnode Length of output: 443 🏁 Script executed: # Check the method signatures in EnsDbClient to understand the class structure
sed -n '80,160p' apps/ensindexer/src/lib/ensdb-client/ensdb-client.tsRepository: namehash/ensnode Length of output: 2307 🏁 Script executed: # Get the constructor and class setup of EnsDbClient
sed -n '60,95p' apps/ensindexer/src/lib/ensdb-client/ensdb-client.tsRepository: namehash/ensnode Length of output: 902 🏁 Script executed: # Look for any ensIndexerSchemaName usage in this file
rg -n "ensIndexerSchemaName" apps/ensindexer/src/lib/ensdb-client/ensdb-client.tsRepository: namehash/ensnode Length of output: 42 🏁 Script executed: # Check the schema definition to understand what ensIndexerSchemaName is
sed -n '1,100p' packages/ensdb-sdk/src/ensnode/index.tsRepository: namehash/ensnode Length of output: 1889 🏁 Script executed: # Look for where EnsDbClient is instantiated to see if ensIndexerSchemaName is passed
rg -n "new EnsDbClient\|EnsDbClient(" apps/ensindexer --type ts -A 3Repository: namehash/ensnode Length of output: 168 🏁 Script executed: # Fix the regex - search for EnsDbClient constructor calls
rg -n "new EnsDbClient" apps/ensindexer --type ts -A 3Repository: namehash/ensnode Length of output: 3598 🏁 Script executed: # Also check how databaseSchemaName is passed
rg -n "databaseSchemaName" apps/ensindexer --type ts -B 2 -A 2Repository: namehash/ensnode Length of output: 13812 🏁 Script executed: # Check if databaseSchemaName is stored in the EnsDbClient instance
sed -n '45,70p' apps/ensindexer/src/lib/ensdb-client/ensdb-client.tsRepository: namehash/ensnode Length of output: 754 🏁 Script executed: # Look for any private fields in EnsDbClient
sed -n '45,210p' apps/ensindexer/src/lib/ensdb-client/ensdb-client.ts | head -60Repository: namehash/ensnode Length of output: 1690 🏁 Script executed: # Check the entire EnsDbClient class to see all private/public fields
cat apps/ensindexer/src/lib/ensdb-client/ensdb-client.tsRepository: namehash/ensnode Length of output: 5837 Both metadata readers and writers must include The
Store 🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will fix that in another PR that will overhaul
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The items to track would be:
🧠 Learnings used |
||
| ], | ||
| ); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1 @@ | ||
| /** | ||
| * Merge the various sub-schemas into a single ponder (drizzle) schema. | ||
| */ | ||
|
|
||
| export * from "./schemas/ensnode-metadata.schema"; | ||
| export * from "./schemas/ensv2.schema"; | ||
| export * from "./schemas/protocol-acceleration.schema"; | ||
| export * from "./schemas/registrars.schema"; | ||
| export * from "./schemas/subgraph.schema"; | ||
| export * from "./schemas/tokenscope.schema"; | ||
| export * from "./ensindexer"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| { | ||
| "extends": "@ensnode/shared-configs/tsconfig.ponder.json", | ||
| "extends": "@ensnode/shared-configs/tsconfig.lib.json", | ||
| "compilerOptions": { | ||
| "rootDir": "." // necessary for 'The project root is ambiguous' | ||
| }, | ||
| "include": ["./**/*.ts"], | ||
| "exclude": ["node_modules"] | ||
| } | ||
tk-o marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Minor grammar suggestion in changeset description.
The description is technically correct but could read more naturally:
✏️ Suggested improvement
📝 Committable suggestion
🧰 Tools
🪛 markdownlint-cli2 (0.21.0)
[warning] 5-5: First line in a file should be a top-level heading
(MD041, first-line-heading, first-line-h1)
🤖 Prompt for AI Agents