Java >= 11 is required.
-
Clone the repository
git clone --recursive https://github.com/mfvanek/pg-index-health.git cd pg-index-health
-
Build with Gradle
- On Linux and macOS:
./gradlew build
- On Windows:
.\gradlew.bat build
This will build the project and run tests.
- On Linux and macOS:
By default, PostgreSQL 16.2 from Testcontainers is used to run tests.
Set TEST_PG_VERSION
environment variable to use any of other available PostgreSQL version:
TEST_PG_VERSION=11.20-alpine
List of all available PostgreSQL versions can be found here.
Each database structure check starts with an SQL query to the pg_catalog.
- SQL queries for checks are located in a separate repository https://github.com/mfvanek/pg-index-health-sql
- That repository is pulled into the current project as a git submodule
- SQLFluff is used as a linter for all sql queries
- All requests must be schema-aware (see example)
pg-index-health is a multimodule Gradle project.
Domain model is located in a pg-index-health-model.
All domain classes should be minimalistic and well-defined.
They should include enough information to generate corrective SQL migrations via pg-index-health-generator.
All checks can be divided into 2 parts:
- Runtime checks (those that make sense to run only on a production database)
- Static checks (which can be run in tests on an empty database)
Runtime checks usually require aggregation of data from all nodes in the cluster. Because of this, it became necessary to create our own abstraction over the database connection.
- Checks on a specific host https://github.com/mfvanek/pg-index-health/tree/master/pg-index-health/src/main/java/io/github/mfvanek/pg/checks/host
Implement a new class extending AbstractCheckOnHost.
- Checks on the cluster https://github.com/mfvanek/pg-index-health/tree/master/pg-index-health/src/main/java/io/github/mfvanek/pg/checks/cluster
Implement a new class extending AbstractCheckOnCluster.
- Your code must be 100% covered.
- Mutation tests via pitest should work.
- Update readme and add information about the new check
- Update Spring Boot starter.
- Add sample code to the demo apps (first, second). Use a locally built pg-index-health version and send a draft PR.