Skip to content

Commit

Permalink
create VIEWs for hidden entities too
Browse files Browse the repository at this point in the history
  • Loading branch information
zeeshanakram3 committed Feb 17, 2024
1 parent 551cb30 commit 7fa630a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

## Misc
- Patch `@subsquid/typeorm-config` & `@subsquid/typeorm-migration` packages to change `squid-typeorm-migration apply` command to apply a single migrations file too using `--filename` option instead of applying the whole `db/migrations` directory.
- Patch `@subsquid/openreader` and `@subsquid/typeorm-codegen` dependencies to include the db schema `name` too in the generated typeorm/postgres migrations, and an optional `schema` directive to specify the schema of any GRAPHQL entity
- Patch `@subsquid/openreader` and `@subsquid/typeorm-codegen` dependencies to include the db schema `name` too in the generated typeorm/postgres migrations, and an optional `schema` directive to specify the schema of any GRAPHQL entity.

## DB Migrations
- Update `generate-migrations` makefile command. Now the existing `*-Data.js` will not be overwritten, instead a new `*-Data.js` migration file (containing only changes compared to the previous DB state) will be added whenever there are GRAPHQL schema changes. The `*-Views.js` migration file will also be updated whenever the GRAPHQL schema changes.
Expand Down
21 changes: 21 additions & 0 deletions db/viewDefinitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,27 @@ function getViewDefinitions(db) {
],
nft_history_entry: [`EXISTS(SELECT 1 FROM "event" WHERE "id"="event_id")`],
nft_activity: [`EXISTS(SELECT 1 FROM "event" WHERE "id"="event_id")`],
// *** HIDDEN entities ***
// Even though the following entities are hidden by default (because they are part of "admin" schema)
// we still define these in the views definitions to create their VIEW in the public schema as they are
// exposed by the GRAPHQL API, so that when querying the GRAPHQL API, the response is just empty object
// instead of `"relation does not exist"` error.
video_view_event: ['FALSE'],
channel_follow: ['FALSE'],
report: ['FALSE'],
exclusion: ['FALSE'],
session: ['FALSE'],
notification_email_delivery: ['FALSE'],
channel_verification: ['FALSE'],
channel_suspension: ['FALSE'],
user: ['FALSE'],
account: ['FALSE'],
token: ['FALSE'],
nft_featuring_request: ['FALSE'],
gateway_config: ['FALSE'],
email_delivery_attempt: ['FALSE'],
// TODO (notifications v2): make this part of the admin schema with appropriate resolver for queries
// notification: ['FALSE'],
}
}

Expand Down

0 comments on commit 7fa630a

Please sign in to comment.