Skip to content

Conversation

@GeertJohan
Copy link
Member

No description provided.

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 adds support for roles with different creation types, replacing the simple db_users list with a more structured roles configuration. The implementation distinguishes between roles created by migrations, externally managed roles, and temporary roles used during migration generation.

  • Introduced three role creation types: migration (created by SQL DDL), external (managed by operators), and temporary (for intermediate migration compatibility)
  • Refactored configuration structure from db_users list to roles with name and creation type properties
  • Renamed internal types for clarity: DatabaseInstance, package internalconfiguration

Reviewed changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/stages/06-roles.trek.yaml Adds test configuration demonstrating all three role creation types
tests/stages/06-roles.dbm Adds test DBM file with roles configured for sql-disabled based on creation type
tests/run.sh Updates test script to support per-stage trek.yaml overrides and renames TREK_DATABASE_USERS to TREK_ROLES
tests/output/trek.yaml Updates output showing new roles structure with creation types
tests/output/santas_warehouse.sql Adds CREATE ROLE statement for migration-created role
tests/output/santas_warehouse.dbm Adds role definitions with appropriate sql-disabled settings
tests/output/migrations/007_roles.up.sql Empty migration file for roles test stage
internal/templates/trek.yaml.tmpl Updates template to generate roles with creation type instead of simple user list
internal/templates/dbm.tmpl Updates to use roleNames instead of db_users
internal/templates.go Changes parameter type to configuration.Template and uses 'any' instead of 'interface{}'
internal/postgres/embedded.go Renames type from postgresDatabaseEmbedded to postgresInstanceEmbedded
internal/postgres/common.go Renames Database interface to Instance, function names, and removes CreateUsers function
internal/dbm/dbm.go Refactors inline structs to named Role and Database types
internal/configuration/config.go Moves from internal package, adds Role type with creation field and validation logic
cmd/init.go Updates to use configuration package, renames database-users flag to roles
cmd/generate.go Implements role creation logic based on creation type and adds role statement generation
cmd/check.go Updates validation to check role creation types match sql-disabled settings
cmd/apply.go Implements role creation and cleanup logic for different creation types
Comments suppressed due to low confidence (2)

internal/configuration/config.go:92

  • The error message uses the full Role struct in string formatting instead of just the role name. This will produce unclear output like "Database user {name creation}" instead of "Database user 'name'". Use role.Name instead of role.
    internal/configuration/config.go:102
  • The error message uses the full Role struct in string formatting instead of just the role name. This will produce unclear output like "Database user {name creation}" instead of "Database user 'name'". Use role.Name instead of role.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@GeertJohan GeertJohan force-pushed the new-roles-config branch 2 times, most recently from fc7c348 to 8ecd1f2 Compare December 20, 2025 19:25
@provokateurin
Copy link
Collaborator

Could you split it into multiple commits, so that the renamings and so on are not mixed with everything else? That would be much easier to review.

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

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (2)

internal/configuration/config.go:78

  • The error message is printing the role struct instead of the role name. This should be role.Name to properly display which role name contains invalid characters.
    internal/configuration/config.go:77
  • The error message still refers to "Database user" instead of "Role" after the refactoring. This message should be updated to match the new terminology.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@provokateurin provokateurin left a comment

Choose a reason for hiding this comment

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

I'm not really sure about the behavior change regarding roles. I think the config checks should be dropped/changed, as we now support roles with sql-disabled=true, which must be managed externally?

@GeertJohan GeertJohan merged commit 8aa35aa into main Dec 26, 2025
1 check passed
@provokateurin provokateurin deleted the new-roles-config branch December 26, 2025 19:38
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