Skip to content

Commit

Permalink
Add deleted_at field to money_pool table and
Browse files Browse the repository at this point in the history
update DeleteMoneyPool method
  • Loading branch information
walnuts1018 committed Nov 6, 2023
1 parent eaf73fd commit fc2f7ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions back/domain/moneypool.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package domain
import (
"fmt"
"log"
"time"

"github.com/pkg/errors"
)
Expand Down Expand Up @@ -116,8 +117,8 @@ func (d *dbImpl) ShareMoneyPoolWithUserGroups(moneyPoolID string, shareUserGroup
}

func (d *dbImpl) DeleteMoneyPool(id string) error {
query := `UPDATE money_pool SET is_deleted = true WHERE id = $1`
result, err := d.db.Exec(query, id)
query := `UPDATE money_pool SET is_deleted = true, deleted_at = $2 WHERE id = $1`
result, err := d.db.Exec(query, id, time.Now())
if err != nil {
return fmt.Errorf("could not delete money pool: %v", err)
}
Expand Down
1 change: 1 addition & 0 deletions back/infra/psql/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ CREATE TABLE IF NOT EXISTS money_pool (
owner_id BIGINT NOT NULL,
emoji VARCHAR(255) NOT NULL,
is_deleted BOOLEAN NOT NULL,
deleted_at DATE,
FOREIGN KEY (owner_id) REFERENCES users(id)
);

Expand Down

0 comments on commit fc2f7ee

Please sign in to comment.