Restructure: Consolidate db package and fix regression#545
Merged
roosterfish merged 7 commits intocanonical:v3from Nov 26, 2025
Merged
Restructure: Consolidate db package and fix regression#545roosterfish merged 7 commits intocanonical:v3from
roosterfish merged 7 commits intocanonical:v3from
Conversation
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
This is a regression caused by canonical#518. Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
There was a problem hiding this comment.
Pull request overview
This PR restructures the database package by consolidating database-related types and functions. The primary goal is to move database utilities that should be publicly accessible from internal packages to the cluster/db package.
- Moves the
Updatetype frominternal/db/schematocluster/dbfor public access - Moves query helper functions (
SelectStrings,SelectIntegers,SelectObjects,Scan) frominternal/db/querytocluster/db - Updates all import statements and usages across the codebase to use the new package structure
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/db/update/update_test.go | Updates imports and type references to use clusterDB.Update and clusterDB.SelectIntegers |
| internal/db/update/update.go | Updates type references to use clusterDB.Update instead of schema.Update |
| internal/db/update/schema.go | Updates imports and uses clusterDB for query functions and Update type |
| internal/db/update/cluster.go | Updates imports to use cluster/db instead of internal/db/query |
| internal/db/schema/schema.go | Removes the Update type definition (moved to cluster/db) |
| internal/db/query/transaction_test.go | Updates to use clusterDB.SelectStrings |
| internal/db/dqlite.go | Updates imports and type references to use clusterDB.Update |
| internal/db/db_test.go | Updates imports and type references throughout test functions |
| internal/daemon/daemon.go | Updates imports and type references in daemon Args struct |
| example/database/extended_schema.go | Updates imports and type references to use public db.Update |
| example/database/extended.mapper.go | Updates imports to use cluster/db for query functions |
| cluster/token_records.mapper.go | Updates imports to use cluster/db for query functions |
| cluster/db/slices_test.go | Renames package from query_test to db_test |
| cluster/db/slices.go | Renames package from query to db |
| cluster/db/schema.go | Adds the Update type definition (moved from internal/db/schema) |
| cluster/db/objects_test.go | Renames package from query_test to db_test |
| cluster/db/objects.go | Renames package from query to db |
| cluster/cluster_members.mapper.go | Updates imports to use cluster/db for query functions |
Comments suppressed due to low confidence (2)
cluster/db/slices.go:1
- Package documentation is incomplete. Consider updating to: "Package db provides slice functions that match LXD's slice handling patterns."
cluster/db/objects.go:1 - Package documentation is incomplete. Consider updating to: "Package db provides object functions that match LXD's object handling patterns."
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
kadinsayani
approved these changes
Nov 26, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the first PR taken from a single commit in #534.
The final package layout will be different but to allow reviewing the changes in smaller chunks I will split this PR by its commits.
It consolidates the DB funcs and ensures the ones that should be used externally are public and not in the
internalpackage.After the restructuring all the DB related functionality will be under the
microcluster/dbpackage alongside the app construct which is located inmicrocluster. See https://github.com/canonical/microcluster/pull/534/files