Skip to content

Commit

Permalink
Feature: add social category (#300)
Browse files Browse the repository at this point in the history
* Feature: add social category

* Fix: tests

* Fix: auth endpoints validation
  • Loading branch information
aopoltorzhicky authored Nov 4, 2024
1 parent c4561f4 commit 6c0b40f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/api/handler/constant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ func (s *ConstantTestSuite) TestEnums() {
s.Require().Len(enums.EventType, 59)
s.Require().Len(enums.MessageType, 76)
s.Require().Len(enums.Status, 2)
s.Require().Len(enums.Categories, 4)
s.Require().Len(enums.Categories, 5)
}
4 changes: 2 additions & 2 deletions cmd/api/handler/rollup_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type createRollupRequest struct {
Explorer string `json:"explorer" validate:"omitempty,url"`
Stack string `json:"stack" validate:"omitempty"`
Links []string `json:"links" validate:"omitempty,dive,url"`
Category string `json:"category" validate:"omitempty,oneof=nft gaming finance uncategorized"`
Category string `json:"category" validate:"omitempty,category"`
Type string `json:"type" validate:"omitempty,oneof=settled sovereign"`
Compression string `json:"compression" validate:"omitempty"`
VM string `json:"vm" validate:"omitempty"`
Expand Down Expand Up @@ -162,7 +162,7 @@ type updateRollupRequest struct {
Bridge string `json:"bridge" validate:"omitempty,eth_addr"`
Explorer string `json:"explorer" validate:"omitempty,url"`
Stack string `json:"stack" validate:"omitempty"`
Category string `json:"category" validate:"omitempty,oneof=nft gaming finance uncategorized"`
Category string `json:"category" validate:"omitempty,category"`
Type string `json:"type" validate:"omitempty,oneof=settled sovereign"`
Compression string `json:"compression" validate:"omitempty"`
Provider string `json:"provider" validate:"omitempty"`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT

package migrations

import (
"context"

"github.com/uptrace/bun"
)

func init() {
Migrations.MustRegister(upSocialCategory, downSocialCategory)
}

func upSocialCategory(ctx context.Context, db *bun.DB) error {
if _, err := db.ExecContext(ctx, `ALTER TYPE rollup_category ADD VALUE IF NOT EXISTS 'social' AFTER 'nft'`); err != nil {
return err
}
return nil
}

func downSocialCategory(_ context.Context, _ *bun.DB) error {
return nil
}
3 changes: 2 additions & 1 deletion internal/storage/types/rolllup.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ package types
uncategorized,
finance,
gaming,
nft
nft,
social
)
*/
//go:generate go-enum --marshal --sql --values --names
Expand Down
5 changes: 5 additions & 0 deletions internal/storage/types/rolllup_enum.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6c0b40f

Please sign in to comment.