-
Notifications
You must be signed in to change notification settings - Fork 16
WIP ENSDb migrations #1771
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
WIP ENSDb migrations #1771
Changes from all commits
6acbea0
eed4800
16c5584
92afddf
b5bd5ca
3f7f0e8
c1964a2
b4fb135
6b6f805
9c05883
f13b6af
1791217
03fecc1
e300888
a1656f6
d53db6d
7ec0fb8
8a056f2
38f30d8
49c7deb
0c65914
3a4ebe6
b94f93d
c5ef04d
20af541
b235706
a6ea0b9
a9b1d39
c07ac36
1767c4e
1252713
069f133
867d643
0d2ee64
6b8c42f
b803f50
d08743c
2d760ee
6c8b6d7
1be0947
7705910
16e5660
d53f0bf
5297c9c
12359f8
f35edb0
79a176d
b4b5b0b
24f66e7
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 | ||
| --- | ||
|
|
||
| Extended `EnsDbClient` with `EnsDbClientMigration` interface implementation. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "ensapi": minor | ||
| --- | ||
|
|
||
| Replaced ENSIndexer Public Config source, from ENSIndexer to ENSDb. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@ensnode/ensnode-schema": minor | ||
| --- | ||
|
|
||
| Split database schemas into Ponder Schema, ENSIndexer Schema, and ENSNode Schema. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@ensnode/ensnode-sdk": minor | ||
| --- | ||
|
|
||
| Introduced `EnsDbClientMigration` interface. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "ensindexer": minor | ||
| --- | ||
|
|
||
| Introduced database migration toolkit based on `drizzle-kit`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "ensapi": minor | ||
| --- | ||
|
|
||
| Updated ENSDb connections to be always read-only. |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,11 +1,22 @@ | ||||||
| import config from "@/config"; | ||||||
|
|
||||||
| import * as schema from "@ensnode/ensnode-schema"; | ||||||
| import { EnsIndexerDbReader } from "@ensnode/ensnode-schema"; | ||||||
|
|
||||||
| import { makeDrizzle } from "@/lib/handlers/drizzle"; | ||||||
| // TODO: pending rename `config.databaseUrl` to `config.ensDbUrl` | ||||||
| // Will be executed once https://github.com/namehash/ensnode/issues/1763 is resolved. | ||||||
| const ensDbUrl = config.databaseUrl; | ||||||
| // TODO: pending rename `config.databaseSchemaName` to `config.ensIndexerSchemaName` | ||||||
| // Will be executed once https://github.com/namehash/ensnode/issues/1762 is resolved. | ||||||
| const ensIndexerSchemaName = config.databaseSchemaName; | ||||||
|
|
||||||
| export const db = makeDrizzle({ | ||||||
| databaseUrl: config.databaseUrl, | ||||||
| databaseSchema: config.databaseSchemaName, | ||||||
| schema, | ||||||
| }); | ||||||
| const ensIndexerDbReader = new EnsIndexerDbReader(ensDbUrl, ensIndexerSchemaName); | ||||||
|
|
||||||
| /** | ||||||
| * Read-only Drizzle instance for queries to ENSIndexer Schema in ENSDb. | ||||||
| */ | ||||||
| export const ensIndexerDbReadonly = ensIndexerDbReader.db; | ||||||
|
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.
Suggested change
I don't think it's necessary to include the detail that this object is readonly in the variable name. This attribute can simply be noted in the JSDoc for it (which you've already done). |
||||||
|
|
||||||
| /** | ||||||
| * Read-only Drizzle instance for queries to ENSIndexer Schema in ENSDb. | ||||||
| */ | ||||||
| export const db = ensIndexerDbReadonly; | ||||||
|
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. Suggest to remove this ( Goal: remove ambiguity from code which schema each database operation is executing against. |
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { fileURLToPath } from "node:url"; | ||
|
|
||
| import { defineConfig } from "drizzle-kit"; | ||
|
|
||
| // Resolve the path to the database schema file for Drizzle migrations. | ||
| const dbSchemaPath = fileURLToPath(new URL("./schema.ts", import.meta.url)); | ||
|
|
||
| export default defineConfig({ | ||
| casing: "snake_case", | ||
| dialect: "postgresql", | ||
| out: `drizzle-kit/migrations`, | ||
| schema: dbSchemaPath, | ||
| }); | ||
|
Comment on lines
+8
to
+13
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 Consider using an absolute path for the The ♻️ Suggested improvement for consistent path resolution+const migrationsOutPath = fileURLToPath(new URL("./migrations", import.meta.url));
+
export default defineConfig({
casing: "snake_case",
dialect: "postgresql",
- out: `drizzle-kit/migrations`,
+ out: migrationsOutPath,
schema: dbSchemaPath,
});🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| CREATE SCHEMA IF NOT EXISTS ensnode; | ||
|
|
||
| CREATE TABLE "ensnode"."ensnode_metadata" ( | ||
| "ens_indexer_schema_name" text NOT NULL, | ||
| "key" text NOT NULL, | ||
| "value" jsonb NOT NULL, | ||
| CONSTRAINT "ensnode_metadata_pkey" PRIMARY KEY("ens_indexer_schema_name","key") | ||
| ); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| { | ||
| "id": "033e8b27-4739-4da9-b9da-517b0c2700d7", | ||
| "prevId": "00000000-0000-0000-0000-000000000000", | ||
| "version": "7", | ||
| "dialect": "postgresql", | ||
| "tables": { | ||
| "ensnode.ensnode_metadata": { | ||
| "name": "ensnode_metadata", | ||
| "schema": "ensnode", | ||
| "columns": { | ||
| "ens_indexer_schema_name": { | ||
| "name": "ens_indexer_schema_name", | ||
| "type": "text", | ||
| "primaryKey": false, | ||
| "notNull": true | ||
| }, | ||
| "key": { | ||
| "name": "key", | ||
| "type": "text", | ||
| "primaryKey": false, | ||
| "notNull": true | ||
| }, | ||
| "value": { | ||
| "name": "value", | ||
| "type": "jsonb", | ||
| "primaryKey": false, | ||
| "notNull": true | ||
| } | ||
| }, | ||
| "indexes": {}, | ||
| "foreignKeys": {}, | ||
| "compositePrimaryKeys": { | ||
| "ensnode_metadata_pkey": { | ||
| "name": "ensnode_metadata_pkey", | ||
| "columns": [ | ||
| "ens_indexer_schema_name", | ||
| "key" | ||
| ] | ||
| } | ||
| }, | ||
| "uniqueConstraints": {}, | ||
| "policies": {}, | ||
| "checkConstraints": {}, | ||
| "isRLSEnabled": false | ||
| } | ||
| }, | ||
| "enums": {}, | ||
| "schemas": {}, | ||
| "sequences": {}, | ||
| "roles": {}, | ||
| "policies": {}, | ||
| "views": {}, | ||
| "_meta": { | ||
| "columns": {}, | ||
| "schemas": {}, | ||
| "tables": {} | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "version": "7", | ||
| "dialect": "postgresql", | ||
| "entries": [ | ||
| { | ||
| "idx": 0, | ||
| "version": "7", | ||
| "when": 1773421837301, | ||
| "tag": "0000_certain_slyde", | ||
| "breakpoints": true | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| // Re-export the ENSNode schema for Drizzle migrations. | ||
| export * from "@ensnode/ensnode-schema/ensnode"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| // export the shared ponder schema | ||
| export * from "@ensnode/ensnode-schema"; | ||
| // export the ENSIndexer schema for Ponder to use when indexing data | ||
| export * from "@ensnode/ensnode-schema/ensindexer"; |
This file was deleted.
This file was deleted.
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.
Release note text appears outdated relative to the migration direction.
This sentence describes extending
EnsDbClient, while this PR’s stated direction is moving to ENSNode reader/writer abstractions. Please update the note so release consumers get an accurate migration message.✏️ Suggested wording
📝 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