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

automated clickhouse migrations #133

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

iuwqyir
Copy link
Collaborator

@iuwqyir iuwqyir commented Jan 14, 2025

TL;DR

Added database migration support using golang-migrate to manage Clickhouse schema changes.

Each storage type has it's own migrations due to them having different connection configurations.

Migration detects if any storage types are configured for the same database and will combine the migration files in a temporary folder (this is due to the limitation of the migration tool that does not allow specifying different migration tables per migration and doesn't allow multiple migrations in one table)

What changed?

  • Created a new db package with migration functionality
  • Added initial migration files for orchestrator, staging, and main storage types
  • Integrated migration execution into the orchestrator startup process
  • Moved existing SQL schema files into organized migration directories
  • Added documentation for managing migrations

How to test?

  1. Start the indexer orchestrator
  2. Verify migrations run successfully on startup
  3. Check Clickhouse for the presence of the following tables:
    • Orchestrator: block_failures, cursors
    • Staging: block_data
    • Main: blocks, logs, transactions, traces

Why make this change?

To establish a proper database schema management system that:

  • Ensures consistent schema across environments
  • Automates schema updates during deployment
  • Reduces manual intervention in database maintenance

Copy link
Collaborator Author

iuwqyir commented Jan 14, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@iuwqyir iuwqyir marked this pull request as ready for review January 14, 2025 15:09
@iuwqyir iuwqyir force-pushed the 01-13-improve_delete_performance_for_clickhouse branch from e5a19e4 to 3aea63b Compare January 14, 2025 21:47
@iuwqyir iuwqyir force-pushed the 01-14-automated_clickhouse_migrations branch from 64ea021 to b9a6178 Compare January 14, 2025 21:48
@iuwqyir iuwqyir force-pushed the 01-13-improve_delete_performance_for_clickhouse branch from 3aea63b to 7e42585 Compare January 15, 2025 11:12
@iuwqyir iuwqyir force-pushed the 01-14-automated_clickhouse_migrations branch from b9a6178 to 39afb02 Compare January 15, 2025 11:12
@iuwqyir iuwqyir changed the base branch from 01-13-improve_delete_performance_for_clickhouse to graphite-base/133 January 15, 2025 11:52
@iuwqyir iuwqyir force-pushed the 01-14-automated_clickhouse_migrations branch from 39afb02 to 0ebb742 Compare January 15, 2025 11:52
@iuwqyir iuwqyir changed the base branch from graphite-base/133 to main January 15, 2025 11:53
@iuwqyir iuwqyir force-pushed the 01-14-automated_clickhouse_migrations branch from 0ebb742 to 4c9bc7b Compare January 15, 2025 11:53
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.

1 participant