gravitino icon indicating copy to clipboard operation
gravitino copied to clipboard

[FEATURE] Add SchemaTool CLI for DB Init/Validation/Info/Upgrade

Open Abyss-lord opened this issue 8 months ago • 1 comments

Describe the feature

Add SchemaTool, SchemaTool is designed to replace the traditional source script import method by providing a unified CLI that implements the following core features:

  • Database Initialization: Automatically detect MySQL or PostgreSQL and execute the corresponding versioned initialization SQL.
  • Integrity Validation: Compare the server version with the schema version and verify key tables and column definitions.
  • Storage Inspection: Output current database connection details, warehouse path, and version status.
  • Smooth Version Upgrades: Load and execute upgrade scripts sequentially based on the specified version range.

Motivation

Currently, Gravitino’s initialization process depends on launching the MySQL client and running the source command to load SQL scripts. This approach has two main drawbacks:

  • Lack of elegance: It requires manually entering the MySQL console, which is cumbersome and error‑prone.
  • No integrity checks: After initialization, there is no automated verification of database objects, which can lead to inconsistencies between environments.

Describe the solution

To address these issues, we need to design a new Schema tool (“SchemaTool”) that provides a standardized CLI for database initialization, integrity validation, storage inspection, and version upgrades.

Additional context

design code:https://docs.google.com/document/d/1D7rUBNIATN1JoBXBlrkwK8ogC6kwzI-Xe1BJoKeFxLc/edit?usp=sharing

Abyss-lord avatar Apr 18 '25 02:04 Abyss-lord

Hi @jerryshao, I'd greatly appreciate it if you could take a look at this design when you have time. Your feedback would be valuable. Thanks so much in advance!

Abyss-lord avatar Apr 20 '25 09:04 Abyss-lord

Thanks @Abyss-lord for your proposal, the doc seems pretty good, and it is very detailed. Is there any other project that uses such a tool for convenience?

My feeling is that though it is useful, only the administrator will use it, and the frequency is very low, is it worth to take a lot of effort to build a such tool?

Can you send a proposal in the dev@ mail list to get more feedbacks. If others think it is useful, then I'm fine with it.

jerryshao avatar May 07 '25 10:05 jerryshao