-
Notifications
You must be signed in to change notification settings - Fork 17
Database migrations toolkit for ENSNode Schema in ENSDb #1779
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 3 commits
f593595
82feb70
9b96470
1ad9002
177324a
8f6994d
4e6c2c0
7f477c5
cf6bd47
825972e
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 @@ | ||
| --- | ||
| "@ensnode/ensdb-sdk": minor | ||
| --- | ||
|
|
||
| Introduced toolkit for managing ENSDb migrations for ENSNode Schema. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,31 @@ | ||
| # ENSDb SDK | ||
|
|
||
| This package is a utility library for interacting with ENSDb. | ||
|
|
||
| ## Database schema definitions | ||
|
|
||
| ### ENSIndexer Schema | ||
|
|
||
| This schema consist of database object definitions exported from `src/ensindexer` module. | ||
|
tk-o marked this conversation as resolved.
Outdated
|
||
| Defining database objects is done by using functionality from `ponder` package. | ||
|
tk-o marked this conversation as resolved.
Outdated
tk-o marked this conversation as resolved.
Outdated
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. This sentence isn't clear. Why are we saying this here? What is the goal? Exactly which functionality from the
Member
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. I wanted to show distinction between ENSIndexer Schema and ENSNode Schema when it comes to defining database objects like tables and enums. ENSIndexer Schema must remain compatible with On the other hand, ENSNode Schema should use schema builder API directly from |
||
|
|
||
| #### Applying schema definition updates | ||
|
|
||
| Updating database object definitions in ENSIndexer Schema _does not_ require any extra steps. ENSIndexer app is built on top of Ponder app. The Ponder app runtime takes care of generating migrations and having them executed during application runtime. In other words, ENSIndexer Schema in ENSDb gets auto-updated when ENSIndexer app starts. | ||
|
tk-o marked this conversation as resolved.
Outdated
|
||
|
|
||
| ### ENSNode Schema | ||
|
|
||
| This schema consist of database object definitions exported from `src/ensnode` module. | ||
| Defining database objects is done by using functionality from `drizzle-orm` package. | ||
|
tk-o marked this conversation as resolved.
Outdated
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. Please see my related question above. What is written here currently is not clear. |
||
|
|
||
| #### Applying schema definition updates | ||
|
|
||
| Updating database object definitions in ENSNode Schema _does_ require an extra step: generating SQL queries to be executed for ENSNode Schema in ENSDb. | ||
|
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. Be precise. See related comment above for how to improve how you communicate. |
||
|
|
||
| Generating SQL queries can be done with the following CLI command: | ||
|
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. "Generating SQL queries"? That suggests these are just random SQL queries being generated? Be precise. |
||
| ``` | ||
|
tk-o marked this conversation as resolved.
Outdated
|
||
| pnpm -F @ensnode/ensdb-sdk drizzle-kit:generate | ||
| ``` | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| This command will update files inside the `migrations` directory, including SQL files. | ||
|
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. Be more precise. Improve the writing. |
||
| The `migrations` directory can be later reference by application runtime (i.e. ENSIndexer app) in order to execute pending SQL migrations for ENSNode Schema in ENSDb. | ||
|
tk-o marked this conversation as resolved.
Outdated
tk-o marked this conversation as resolved.
Outdated
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { defineConfig } from "drizzle-kit"; | ||
|
|
||
| const ensNodeSchemaPath = "./src/ensnode/index.ts"; | ||
|
|
||
| export default defineConfig({ | ||
| casing: "snake_case", | ||
| dialect: "postgresql", | ||
| out: "migrations", | ||
| schema: ensNodeSchemaPath, | ||
|
tk-o marked this conversation as resolved.
|
||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| CREATE SCHEMA IF NOT EXISTS ensnode; | ||
|
|
||
| CREATE TABLE "ensnode"."metadata" ( | ||
| "ens_indexer_schema_name" text NOT NULL, | ||
| "key" text NOT NULL, | ||
| "value" jsonb NOT NULL, | ||
| CONSTRAINT "metadata_pkey" PRIMARY KEY("ens_indexer_schema_name","key") | ||
| ); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| { | ||
| "id": "d661dcae-f64d-4ecd-a4da-3d5783e17e2c", | ||
| "prevId": "00000000-0000-0000-0000-000000000000", | ||
| "version": "7", | ||
| "dialect": "postgresql", | ||
| "tables": { | ||
| "ensnode.metadata": { | ||
| "name": "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": { | ||
| "metadata_pkey": { | ||
| "name": "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": 1773743108514, | ||
| "tag": "0000_cultured_captain_cross", | ||
| "breakpoints": true | ||
| } | ||
| ] | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.