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-alt] - make migration optional #20803

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

patrickkuo
Copy link
Contributor

Description

Apps indexer might not be managing the DB schema, making migration optional to cater that use case.

Test plan

How did you test the new or updated feature?


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):
  • gRPC:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:

Copy link

vercel bot commented Jan 7, 2025

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 Jan 7, 2025 0:33am
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Jan 7, 2025 0:33am
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Jan 7, 2025 0:33am
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Jan 7, 2025 0:33am

@patrickkuo patrickkuo temporarily deployed to sui-typescript-aws-kms-test-env January 7, 2025 11:50 — with GitHub Actions Inactive
@patrickkuo patrickkuo temporarily deployed to sui-typescript-aws-kms-test-env January 7, 2025 12:32 — with GitHub Actions Inactive
@patrickkuo patrickkuo requested review from wlmyng and amnn January 7, 2025 14:00
@patrickkuo patrickkuo marked this pull request as ready for review January 7, 2025 14:00
@patrickkuo patrickkuo temporarily deployed to sui-typescript-aws-kms-test-env January 7, 2025 14:00 — with GitHub Actions Inactive
Copy link
Contributor

@wlmyng wlmyng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beyond making Indexer::new accept an optional migrations, it looks like we'd just need to modify the function to not run db.run_migrations, around L145

I'm not sure if we need to make the other modifications, for the ResetDatabase command, an app indexer should just provide the skip-migrations flag

Comment on lines 371 to 383
pub fn migrations(
migrations: &'static EmbeddedMigrations,
migrations: Option<&'static EmbeddedMigrations>,
) -> impl MigrationSource<Pg> + Send + Sync + 'static {
struct Migrations(&'static EmbeddedMigrations);
struct Migrations(Option<&'static EmbeddedMigrations>);
impl MigrationSource<Pg> for Migrations {
fn migrations(&self) -> migration::Result<Vec<Box<dyn Migration<Pg>>>> {
let mut migrations = MIGRATIONS.migrations()?;
migrations.extend(self.0.migrations()?);
if let Some(more_migrations) = self.0 {
migrations.extend(more_migrations.migrations()?);
}
Ok(migrations)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like this can still be kept as non-optional. it's only called when the ResetDatabase command is invoked. There, an indexer that isn't responsible for managing db-schema would pass skip-migrations

Comment on lines +79 to 80
(!skip_migrations).then(|| Indexer::migrations(Some(&MIGRATIONS))),
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think an app indexer would just provide the skip-migrations flag

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