Skip to content

Commit

Permalink
feat: vault soft delete (#1395)
Browse files Browse the repository at this point in the history
  • Loading branch information
phucledien authored May 24, 2024
1 parent 93f2aa4 commit d18b72a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- +migrate Up
ALTER TABLE
vaults
ADD
COLUMN deleted_at timestamptz;

-- +migrate Down
ALTER TABLE
vaults DROP COLUMN deleted_at;
1 change: 1 addition & 0 deletions pkg/model/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Vault struct {
WalletNumber int64 `json:"wallet_number"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at"`
VaultTreasurers []VaultTreasurer `json:"vault_treasurers" gorm:"foreignkey:VaultId"`
TotalAmountEVM string `json:"total_amount_evm" gorm:"-"`
TotalAmountSolana string `json:"total_amount_solana" gorm:"-"`
Expand Down
3 changes: 3 additions & 0 deletions pkg/repo/vault/pg.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ func (pg *pg) GetLatestWalletNumber() (walletNumber sql.NullInt64, err error) {

func (pg *pg) List(q ListQuery) (vaults []model.Vault, err error) {
db := pg.db
if !q.GetArchived {
db = db.Where("vaults.deleted_at IS NULL")
}
if q.GuildID != "" {
db = db.Where("vaults.guild_id = ?", q.GuildID)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/repo/vault/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ type ListQuery struct {
SolanaWallet string
Threshold string
VaultIDs []string
GetArchived bool
}

0 comments on commit d18b72a

Please sign in to comment.