From fc2f7ee46206c44c3c80d36a86266f1f5561ebae Mon Sep 17 00:00:00 2001 From: Walnuts Date: Mon, 6 Nov 2023 18:30:06 +0900 Subject: [PATCH] Add deleted_at field to money_pool table and update DeleteMoneyPool method --- back/domain/moneypool.go | 5 +++-- back/infra/psql/init.sql | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/back/domain/moneypool.go b/back/domain/moneypool.go index 0ef4eec..d108f27 100644 --- a/back/domain/moneypool.go +++ b/back/domain/moneypool.go @@ -3,6 +3,7 @@ package domain import ( "fmt" "log" + "time" "github.com/pkg/errors" ) @@ -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) } diff --git a/back/infra/psql/init.sql b/back/infra/psql/init.sql index 7c2cf03..f5209ec 100644 --- a/back/infra/psql/init.sql +++ b/back/infra/psql/init.sql @@ -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) );