Skip to content

Restructure: Consolidate db package and fix regression#545

Merged
roosterfish merged 7 commits intocanonical:v3from
roosterfish:restructure_packages_db
Nov 26, 2025
Merged

Restructure: Consolidate db package and fix regression#545
roosterfish merged 7 commits intocanonical:v3from
roosterfish:restructure_packages_db

Conversation

@roosterfish
Copy link
Contributor

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 internal package.

After the restructuring all the DB related functionality will be under the microcluster/db package alongside the app construct which is located in microcluster. See https://github.com/canonical/microcluster/pull/534/files

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>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 Update type from internal/db/schema to cluster/db for public access
  • Moves query helper functions (SelectStrings, SelectIntegers, SelectObjects, Scan) from internal/db/query to cluster/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>
@roosterfish roosterfish marked this pull request as ready for review November 26, 2025 15:02
@roosterfish roosterfish merged commit c61ac07 into canonical:v3 Nov 26, 2025
5 checks passed
@roosterfish roosterfish deleted the restructure_packages_db branch November 26, 2025 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants