Add organization deletion

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2025-08-07 17:08:04 +02:00
parent c9ab0678be
commit ab97fc8cf8
16 changed files with 958 additions and 232 deletions

View File

@@ -156,3 +156,28 @@ WHERE
return nil
}
func (o *Organization) Delete(
ctx context.Context,
conn pg.Conn,
scope Scoper,
) error {
q := `
DELETE FROM organizations
WHERE
%s
AND id = @id
`
q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{"id": o.ID}
maps.Copy(args, scope.SQLArguments())
_, err := conn.Exec(ctx, q, args)
if err != nil {
return fmt.Errorf("cannot delete organization: %w", err)
}
return nil
}