apache / apache/gravitino

[FEATURE] Opt-in auto-create relational entity store schema on startup

Open
#10,843 0 comments 0 reactions 0 assignees View on GitHub
feature
Dominant language
Java
Stars
3.2k
Forks
935
Avg merge
1d 16h
Merged PRs (30d)
298

Description

### Describe the feature

When Gravitino uses an external relational database backend (e.g., MySQL/PostgreSQL) for the relational entity store, allow the server to automatically initialize the required schema/tables on startup (opt-in).

### Motivation

Today, operators must manually run schema/upgrade SQL scripts. In dev/test environments it is easy to hit missing-table errors after upgrading or starting the server against a fresh database (schema not initialized). Auto-creating the schema (opt-in) can significantly improve the developer/test experience and reduce manual setup steps.

### Describe the solution

Introduce a new configuration property:

- `gravitino.entity.store.relational.autoCreateSchema` (default: `false`)

When enabled, and the JDBC backend is **non-embedded**, the server checks whether the schema exists; if not, it executes the current schema initialization script under:

- `${GRAVITINO_HOME}/scripts/{mysql,postgresql}/schema-${CURRENT_SCRIPT_VERSION}-*.sql`

Safety / constraints:

- Embedded H2 behavior remains unchanged.
- Unsupported JDBC types should be skipped with a warning.
- If the schema script is missing, skip with a warning (no startup failure).

### Additional context

- Related PR (implementation): https://github.com/apache/gravitino/pull/10819
- Suggested test:
- `./gradlew :core:test`
- Start server with relational store backed by MySQL/PostgreSQL and `gravitino.entity.store.relational.autoCreateSchema=true`, ensure tables are created and server starts without missing-table errors.

Contributor guide

Open the contributing guide

Research direction

Review related PR #10819 and the relational entity store startup path. Run ./gradlew :core:test, then test with MySQL or PostgreSQL and gravitino.entity.store.relational.autoCreateSchema=true. Done means the required tables are created for supported non-embedded backends without missing-table startup errors, while unsupported types and missing scripts only warn.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, mysql, postgresql
Domain
backend, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.