Skip to content

RHINENG-26544: add workspace columns#2215

Merged
TenSt merged 1 commit into
RedHatInsights:masterfrom
TenSt:stepan/RHINENG-26544-add-workspace-columns
May 27, 2026
Merged

RHINENG-26544: add workspace columns#2215
TenSt merged 1 commit into
RedHatInsights:masterfrom
TenSt:stepan/RHINENG-26544-add-workspace-columns

Conversation

@TenSt
Copy link
Copy Markdown
Collaborator

@TenSt TenSt commented May 27, 2026

This PR:

  • adds new workspace_* columns
  • creates new trigger on insert/update of the old workspace column
  • updates schema
  • updates test data
  • updates tests

Summary by Sourcery

Simplify workspace handling by introducing dedicated workspace columns on system inventory and synchronizing them from the existing workspaces JSON field.

Enhancements:

  • Add workspace_id and workspace_name columns to system_inventory and keep them in sync via a trigger driven by the workspaces JSON array.
  • Enforce non-empty workspace data on system_inventory inserts to ensure each system is associated with a workspace.
  • Update schema version and add migrations to apply and roll back the new workspace columns and trigger.
  • Adjust test helpers, mocks, and test data to use stable workspace UUIDs and populate workspaces for created systems.

@TenSt TenSt requested a review from a team as a code owner May 27, 2026 12:06
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 27, 2026

Reviewer's Guide

Adds normalized workspace_id/workspace_name columns to system_inventory, wires a trigger to keep them in sync with the existing workspaces JSONB field and enforce presence on insert, bumps the schema version/migrations accordingly, and updates test data and tests to use concrete workspace UUIDs and helper functions.

File-Level Changes

Change Details Files
Normalize workspaces on system_inventory and enforce workspace presence via trigger.
  • Add workspace_id (UUID) and workspace_name (TEXT with non-empty CHECK) columns to system_inventory table definition and migration.
  • Introduce sync_system_inventory_workspace() trigger function that derives workspace_id/name from the first element of workspaces JSONB, raising on missing/empty workspace for INSERTs.
  • Register partition triggers system_inventory_sync_workspace to run BEFORE INSERT or UPDATE OF workspaces on system_inventory partitions, and provide a down migration to drop these triggers, function, and columns.
database_admin/schema/create_schema.sql
database_admin/migrations/156_simplify_workspaces.up.sql
database_admin/migrations/156_simplify_workspaces.down.sql
Update seed/test data to use concrete workspace UUIDs and ensure workspaces is populated or explicitly empty where required.
  • Replace legacy inventory-group-* IDs in workspaces JSON with stable UUIDs for group1, group2, and other across all system_inventory INSERTs.
  • Add an UPDATE to set workspaces = '[]'::jsonb for selected system_inventory rows to cover empty-workspace cases under the new trigger rules.
dev/test_data.sql
Refactor tests to work with workspace UUIDs and new workspace requirements.
  • Introduce shared test workspace UUID constants and a helper returning a Groups slice for group1, and use them when creating test system_inventory rows in various components.
  • Update tests that assert on grouped workspace IDs (CSV exports, filters, Kessel mocks, grouping utilities, listener uploads, culling, admin flows) to expect the new UUID-based IDs and to populate Workspaces/Groups fields where inserts would otherwise fail the new trigger.
base/database/testing.go
base/database/utils_test.go
listener/common_test.go
listener/upload_test.go
listener/upload_test.go
manager/controllers/template_systems_export_test.go
manager/controllers/utils_test.go
manager/controllers/advisory_systems_export_test.go
manager/controllers/systems_export_test.go
manager/controllers/template_systems_update_test.go
manager/middlewares/kessel_test.go
platform/kessel.go
tasks/system_culling/system_culling_test.go
turnpike/controllers/admin_test.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

We failed to fetch pull request #2215.

You can try again by commenting this pull request with @sourcery-ai review, or contact us for help.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.18%. Comparing base (6c5b053) to head (7da5735).

Files with missing lines Patch % Lines
base/database/testing.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2215      +/-   ##
==========================================
- Coverage   59.23%   59.18%   -0.06%     
==========================================
  Files         137      137              
  Lines        8795     8798       +3     
==========================================
- Hits         5210     5207       -3     
- Misses       3037     3043       +6     
  Partials      548      548              
Flag Coverage Δ
unittests 59.18% <0.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TenSt TenSt merged commit c17b4a2 into RedHatInsights:master May 27, 2026
8 checks passed
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.

3 participants