Skip to content

Commit

Permalink
add gorm type for JSONB fields (#7975)
Browse files Browse the repository at this point in the history
## Summary
- newer version of GORM wants to migrate these fields to `type:text`,
explicitly tag to make sure automigrate doesn't happen
- remove `Retryable` from automigrated models as it is unused, it also
has `type:text` on this field
<!--
Ideally, there is an attached GitHub issue that will describe the "why".

If relevant, use this section to call out any additional information
you'd like to _highlight_ to the reviewer.
-->

## How did you test this change?
- ran `make start` locally to automigrate, made sure all of these
columns had `jsonb` type
<!--
Frontend - Leave a screencast or a screenshot to visually describe the
changes.
-->

## Are there any deployment considerations?
- want to deploy this to fix automigrate in previous GORM PR, can revert
this and previous commit if issues
<!--
 Backend - Do we need to consider migrations or backfilling data?
-->

## Does this work require review from our design team?
- no
<!--
 Request review from julian-highlight / our design team 
-->
  • Loading branch information
mayberryzane committed Mar 11, 2024
1 parent a9a7dfb commit 47d1eeb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
9 changes: 4 additions & 5 deletions backend/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ var Models = []interface{}{
&IntegrationWorkspaceMapping{},
&EmailOptOut{},
&BillingEmailHistory{},
&Retryable{},
&Service{},
&SetupEvent{},
&SessionAdminsView{},
Expand Down Expand Up @@ -713,7 +712,7 @@ type Session struct {
Environment string `json:"environment"`
AppVersion *string `json:"app_version"`
ServiceName string
UserObject JSONB `json:"user_object" sql:"type:jsonb"`
UserObject JSONB `json:"user_object" sql:"type:jsonb" gorm:"type:jsonb"`
UserProperties string `json:"user_properties"`
// Whether this is the first session created by this user.
FirstTime *bool `json:"first_time" gorm:"default:false"`
Expand All @@ -733,7 +732,7 @@ type Session struct {
// The version of Highlight's Firstload.
FirstloadVersion string `json:"firstload_version"`
// The client configuration that the end-user sets up. This is used for debugging purposes.
ClientConfig *string `json:"client_config" sql:"type:jsonb"`
ClientConfig *string `json:"client_config" sql:"type:jsonb" gorm:"type:jsonb"`
// Determines whether this session should be viewable. This enforces billing.
WithinBillingQuota *bool `json:"within_billing_quota" gorm:"default:true"`
// Used for shareable links. No authentication is needed if IsPublic is true
Expand Down Expand Up @@ -1266,7 +1265,7 @@ type TimelineIndicatorEvent struct {
Timestamp float64
Type int
SID float64
Data JSONB `json:"data" sql:"type:jsonb"`
Data JSONB `json:"data" sql:"type:jsonb" gorm:"type:jsonb"`
}

type RageClickEvent struct {
Expand Down Expand Up @@ -1404,7 +1403,7 @@ type Retryable struct {
Type RetryableType
PayloadType string
PayloadID string
Payload JSONB `sql:"type:jsonb"`
Payload JSONB `sql:"type:jsonb" gorm:"type:jsonb"`
Error string
}

Expand Down
1 change: 1 addition & 0 deletions backend/public-graph/graph/resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ func TestInitializeSessionImpl(t *testing.T) {
session, err := resolver.InitializeSessionImpl(ctx, &kafka_queue.InitializeSessionArgs{
ProjectVerboseID: project.VerboseID(),
ServiceName: "my-frontend-app",
ClientConfig: "{}",
})
assert.NoError(t, err)
assert.NotNil(t, session.ID)
Expand Down

0 comments on commit 47d1eeb

Please sign in to comment.