Skip to content
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

indexer: ensure schema always matches what diesel generated #19337

Merged
merged 4 commits into from
Sep 12, 2024

Conversation

amnn
Copy link
Contributor

@amnn amnn commented Sep 12, 2024

Description

Create a script that regenerates the schema and run it to standardise our schema. Also merge schema/mod.rs and schema/pg.rs into one schema.rs -- otherwise we have an opportunity for things to go out of sync because a module is present in the generated schema (pg.rs) but not in the module entrypoint (mod.rs).

Run this script to refresh the schema (some inconsistencies already crept in!) and set it up to run under CI.

Test plan

sui$ ./scripts/generate_indexer_schema.rs`

and CI


Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • Indexer:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:
  • REST API:

## Description

Create a script that regenerates the schema and run it to standardise
our schema. Also merge `schema/mod.rs` and `schema/pg.rs` into one
`schema.rs` -- otherwise we have an opportunity for things to go out of
sync because a module is present in the generated schema (`pg.rs`) but
not in the module entrypoint (`mod.rs`).

## Test plan

```
sui$ ./scripts/generate_indexer_schema.sh
```
## Description

Run `./scripts/generate_indexer_schema.sh` during CI, so that if it
changes anything, we learn about it when `changed-files.sh` runs.

## Test plan

CI
Copy link

vercel bot commented Sep 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 12, 2024 6:37pm
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Sep 12, 2024 6:37pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Sep 12, 2024 6:37pm
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Sep 12, 2024 6:37pm

@amnn
Copy link
Contributor Author

amnn commented Sep 12, 2024

I'm expecting the CI to fail initially, because I'm not running the postgres service in the job that runs the test.

My inclination is to add a new job that runs the postgres service and just the script to generate the schema, another option is to run the same service during test-extra.

Yet another option is to find some way to run an ephemeral postgres instance just for the duration of the script, but I'm not sure that's easy to achieve out of the box.

cc @bmwill if you have any other ideas, or a strong preference on one of these options.

@bmwill
Copy link
Contributor

bmwill commented Sep 12, 2024

Yet another option is to find some way to run an ephemeral postgres instance just for the duration of the script, but I'm not sure that's easy to achieve out of the box.

This actually shouldn't be too hard to do in a bash script since we'll have the postgres binaries on the path. its just a few steps of:

  • create DB with initdb
  • start postgres service
  • run test
  • shutdown postgres on exit

I'm happy to help with the above since i had to get somewhat familiar with how to do this via shelling out from rust for the tempdb work

@amnn
Copy link
Contributor Author

amnn commented Sep 12, 2024

Oh nice, I see it now -- I'll crib off tempdb.rs thanks for the pointer!

@amnn amnn merged commit 02fbd47 into main Sep 12, 2024
48 checks passed
@amnn amnn deleted the amnn/diesel-schema-ci branch September 12, 2024 20:50
suiwombat pushed a commit that referenced this pull request Sep 16, 2024
## Description 

Create a script that regenerates the schema and run it to standardise
our schema. Also merge `schema/mod.rs` and `schema/pg.rs` into one
`schema.rs` -- otherwise we have an opportunity for things to go out of
sync because a module is present in the generated schema (`pg.rs`) but
not in the module entrypoint (`mod.rs`).

Run this script to refresh the schema (some inconsistencies already
crept in!) and set it up to run under CI.

## Test plan 

```
sui$ ./scripts/generate_indexer_schema.rs`
```

and CI

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants