Skip to content

[BREAKING] Add CLI command for database initialization#617

Open
dean-amar wants to merge 13 commits into
hyperledger:mainfrom
dean-amar:admin-db-init
Open

[BREAKING] Add CLI command for database initialization#617
dean-amar wants to merge 13 commits into
hyperledger:mainfrom
dean-amar:admin-db-init

Conversation

@dean-amar

@dean-amar dean-amar commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Type of change

  • New feature
  • Improvement (code improvement)
  • Test update
  • Documentation update
  • Breaking change

Description

  • Introduces a new committer init-db CLI command that allows administrators to initialize the database (create system tables, metadata tables, and system namespaces) as a standalone operation before starting services. The change includes a BREAKING API modification: the SetupSystemTablesAndNamespaces RPC method has been removed from the VC service as database initialization is now performed via CLI instead of gRPC.

Additional details

  • Usage example: committer init-db --config vc.yaml

Related issues

dean-amar added 4 commits June 1, 2026 20:31
…ust be executed after the database is healthy and running, and before performing any operation against the database.

Signed-off-by: Dean Amar <Dean.Amar@ibm.com>
Signed-off-by: Dean Amar <Dean.Amar@ibm.com>
Signed-off-by: Dean Amar <Dean.Amar@ibm.com>
Signed-off-by: Dean Amar <Dean.Amar@ibm.com>
@coveralls

coveralls commented Jun 1, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 91.648% (+0.1%) from 91.551% — dean-amar:admin-db-init into hyperledger:main

Comment thread cmd/cliutil/flags.go Outdated
Comment thread cmd/config/app_config.go Outdated
Comment thread utils/db/dbinit.go
Comment thread utils/db/dbinit.go Outdated
Comment thread cmd/config/samples/dbinit.yaml Outdated
Comment thread docker/test/container_release_image_test.go Outdated
Comment thread docker/test/common.go Outdated
t.Helper()
client := createValidatorAndCommitClientWithTLS(t, &env.ServerConfigs[0].GRPC.Endpoint, cfg)
_, err := client.SetupSystemTablesAndNamespaces(ctx, nil)
_, err := client.SetLastCommittedBlockNumber(ctx, nil)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this is needed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

SetupSystemTablesAndNamespaces RPC was called to make sure the client actually connected or not in the TestVCSecureConnection. Since this PR removes it, we should call another RPC to verify the same behavior.

Comment thread service/vc/test_exports.go Outdated
Comment thread utils/db/dbinit.go Outdated
Signed-off-by: Dean Amar <Dean.Amar@ibm.com>
Signed-off-by: Dean Amar <Dean.Amar@ibm.com>
Signed-off-by: Dean Amar <Dean.Amar@ibm.com>
Signed-off-by: Dean Amar <Dean.Amar@ibm.com>
@dean-amar dean-amar requested a review from liran-funaro June 14, 2026 11:13
Signed-off-by: Dean Amar <Dean.Amar@ibm.com>

@cendhu cendhu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I recommend reusing the vc config for the db-init command, as it isn't a standalone component and relies on vc code anyway. We already follow this pattern by reusing the service config for health checks, so we can take the same approach here. Furthermore, since this command will be used very rarely (primarily during initial setup and occasional version upgrades), introducing a dedicated config is overkill and adds unnecessary code.

…to reuse the VC configuration.

Signed-off-by: Dean Amar <Dean.Amar@ibm.com>
Signed-off-by: Dean Amar <Dean.Amar@ibm.com>
Signed-off-by: Dean Amar <Dean.Amar@ibm.com>
Signed-off-by: Dean Amar <Dean.Amar@ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[db] Admin DB initialisation

4 participants