Skip to content

feat(postgres): expose workload Postgres uses with branches - #560

Merged
rbjornstad merged 10 commits into
mainfrom
feat/workload-postgres-usages
Oct 15, 2026
Merged

rbjornstad merged 10 commits into
mainfrom
feat/workload-postgres-usages

Conversation

@rbjornstad

@rbjornstad rbjornstad commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Change Workload.postgreses to a paginated PostgresUsesConnection for Application and Job.
  • Each PostgresUse includes envPrefix, effective role, the referenced postgres, and branch as the resolved PostgresBranch.
  • Resolve explicit branch pins first; otherwise use the observed active branch, falling back to main until an active branch is observed.

Tests

  • Focused postgres_workloads, postgres_branch_selection, and postgres_branches Lua integration suites.
  • Postgres domain tests and go test ./internal/graph.
  • GraphQL generation and Lua formatting.

Copilot AI 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.

🟢 Approval recommended

The implementation is consistent with existing behavior and has focused coverage for branch selection and error cases.

0 open findings

What changed in this PR

Adds resolved Postgres branch usages to application and job workloads while preserving existing fields.

Changes:

  • Adds Workload.postgresUsages and supporting models/resolvers.
  • Centralizes explicit, observed-active, and fallback branch selection.
  • Covers branch resolution and failure cases with unit and integration tests.
File Description
internal/​persistence/​postgres/​queries.go Resolves workload Postgres usages and branches.
internal/​persistence/​postgres/​queries_test.go Tests duplicate-use handling.
internal/​persistence/​postgres/​models.go Adds the usage relationship model.
internal/​persistence/​postgres/​delete_test.go Tests resolved usage branches.
internal/​graph/​schema/​postgres.graphqls Exposes the new GraphQL field and type.
internal/​graph/​postgres.resolvers.go Resolves usages for applications and jobs.
internal/​graph/​gengql/​root_.generated.go Updates generated root schema code.
internal/​graph/​gengql/​postgres.generated.go Adds generated usage serialization.
internal/​graph/​gengql/​jobs.generated.go Adds generated job field handling.
internal/​graph/​gengql/​applications.generated.go Adds generated application field handling.
integration_tests/​postgres_workloads.lua Tests workload usage results.
integration_tests/​postgres_branch_selection.lua Tests selection and missing-branch behavior.
Files not reviewed (3)
  • internal/graph/gengql/applications.generated.go: Generated file
  • internal/graph/gengql/jobs.generated.go: Generated file
  • internal/graph/gengql/postgres.generated.go: Generated file

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@rbjornstad
rbjornstad marked this pull request as ready for review October 14, 2026 09:03
@rbjornstad
rbjornstad requested a review from a team as a code owner October 14, 2026 09:03
@thokra-nav

Copy link
Copy Markdown
Contributor

Spørsmål til denne. Skulle vi hatt en uses: WorkloadUsesConnection! hvor vi har et interface eller union for WorkloadUse? (names tbd)

Mtp at flere ting skal inn der, så kanskje vi skal samle det?

@rbjornstad rbjornstad changed the title feat(postgres): expose resolved Postgres usages on workloads feat(graphql): expose typed workload uses Oct 14, 2026
@rbjornstad

rbjornstad commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor Author

@thokra-nav Godt poeng. Jeg jobber med saken i rom 5 :D

@rbjornstad

Copy link
Copy Markdown
Contributor Author

@thokra-nav Oppdatering: jeg fjernet workload-feltet postgreses helt, slik at Workload.uses er den samlede flaten for eksterne ressurser. Team.postgreses og Postgres.workloads er separate felt og er urørt.

Copilot AI 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.

🟡 Changes recommended

It removes a public field without deprecation and resolves resources outside the requested page.

2 open findings
Files not reviewed (4)
  • internal/graph/gengql/applications.generated.go: Generated file
  • internal/graph/gengql/complexity.go: Generated file
  • internal/graph/gengql/jobs.generated.go: Generated file
  • internal/graph/gengql/postgres.generated.go: Generated file

🧠 Review effort: Balanced

Comment thread internal/graph/schema/postgres.graphqls Outdated
Comment thread internal/persistence/postgres/queries.go
@rbjornstad rbjornstad changed the title feat(graphql): expose typed workload uses feat(postgres): expose Postgres uses on workloads Oct 14, 2026
Comment thread internal/graph/schema/postgres.graphqls Outdated
Comment thread internal/graph/schema/postgres.graphqls Outdated

Copilot AI 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.

🟡 Changes recommended

The public schema breaks existing clients, omits promised configured fields, and has inconsistent pagination validation.

6 open findings
Files not reviewed (4)
  • internal/graph/gengql/applications.generated.go: Generated file
  • internal/graph/gengql/complexity.go: Generated file
  • internal/graph/gengql/jobs.generated.go: Generated file
  • internal/graph/gengql/postgres.generated.go: Generated file

🧠 Review effort: Balanced

Comment thread internal/graph/schema/postgres.graphqls Outdated
Comment thread internal/graph/postgres.resolvers.go Outdated
Comment thread internal/graph/schema/postgres.graphqls
Comment thread internal/graph/postgres.resolvers.go Outdated
@rbjornstad rbjornstad changed the title feat(postgres): expose Postgres uses on workloads feat(postgres): expose workload Postgres uses with branches Oct 14, 2026

Copilot AI 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.

🔵 Needs a closer look

The existing public GraphQL field is changed incompatibly without a deprecated compatibility path.

0 open findings

6 resolved since last review
Files not reviewed (4)
  • internal/graph/gengql/applications.generated.go: Generated file
  • internal/graph/gengql/complexity.go: Generated file
  • internal/graph/gengql/jobs.generated.go: Generated file
  • internal/graph/gengql/postgres.generated.go: Generated file

🧠 Review effort: Balanced

@rbjornstad
rbjornstad merged commit 620e68b into main Oct 15, 2026
14 checks passed
@rbjornstad
rbjornstad deleted the feat/workload-postgres-usages branch October 15, 2026 06:40
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.

4 participants