Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/controllers/usages.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Usage struct {
ResourceName string `json:"resource_name"`
UsageValue float64 `json:"usage_value"`
UpdateType string `json:"update_type"`
Metadata string `json:"metadata"`

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Minor question for someone who's worked more with this code is if this should be any other type or what. I guess this should mean that we insert blank strings rather than nulls, which is probably fine but maybe someone has a different thought there. Haven't worked to integrate with anything yet either, of course.

}

var (
Expand Down Expand Up @@ -138,6 +139,7 @@ func (s Server) addUsage(ctx context.Context, usage *Usage) error {
UpdateOperationID: updateOperation.ID,
ResourceTypeID: resourceType.ID,
UserID: subscription.UserID,
Metadata: &usage.Metadata,
}
err = tx.WithContext(ctx).Debug().Create(&update).Error
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions internal/model/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ type Update struct {
ResourceType ResourceType `json:"resource_types"`
UserID *string `gorm:"type:uuid" json:"-"`
User User `json:"user"`
Metadata *string `json:"metadata"`
}
7 changes: 7 additions & 0 deletions migrations/000017_updates_metadata.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
BEGIN;

SET search_path = public, pg_catalog;

ALTER TABLE IF EXISTS updates DROP COLUMN IF EXISTS metadata;

COMMIT;
7 changes: 7 additions & 0 deletions migrations/000017_updates_metadata.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
BEGIN;

SET search_path = public, pg_catalog;

ALTER TABLE IF EXISTS updates ADD COLUMN IF NOT EXISTS metadata TEXT;

COMMIT;
Loading