Skip to content

Commit

Permalink
feat: introduce indexed tag
Browse files Browse the repository at this point in the history
  • Loading branch information
toopay committed Oct 25, 2024
1 parent 14155f8 commit bfbb805
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/generator/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ func BuildRelationTag(r *state.Relation) string {
jsonTag := fmt.Sprintf("json:%q", utils.ToSnakeCase(r.Table)+",omitempty")
tags = append(tags, jsonTag)

if r.Index != nil {
tags = append(tags, "indexed")
}

if r.Action != nil {

onUpdate, onDelete := objects.RelationActionDefaultLabel, objects.RelationActionDefaultLabel
Expand Down
1 change: 1 addition & 0 deletions pkg/generator/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func TestGenerateModels(t *testing.T) {
ForeignKey: "test_table_id",
PrimaryKey: "id",
Action: &relationshipAction,
Index: &objects.Index{Schema: "public", Table: "related_table", Name: "test_table_id", Definition: "CREATE INDEX test_table_id ON related_table(test_table_id);"},
},
},
Policies: objects.Policies{},
Expand Down

0 comments on commit bfbb805

Please sign in to comment.