Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: vault soft delete #1395

Merged
merged 1 commit into from
May 24, 2024
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
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
}
Loading