---
id: w3/m9/t001
title: "`notification_settings` store: per-workspace/per-member preferences (deploy started/succeeded/failed)"
worker: worker3
status: todo
estimate: 45m
depends_on: []
---

## Objective

Add a store for per-workspace (and optionally per-member) notification preferences: which deploy-lifecycle events (started/succeeded/failed) trigger a notification.

## Context

- `lego/backend/internal/store/` — control-plane Postgres migrations live here (see `0009_git_connections.up.sql` for the migration pattern).
- `lego/backend/internal/workspaces/` — workspace model to key preferences off of.

## Steps

1. Add a migration creating a `notification_settings` table (workspace id, event types enabled, default: failure-only, matching Render's default).
2. Add a Go store package exposing get/set for a workspace's settings.

## Files

- `lego/backend/internal/store/migrations/00NN_notification_settings.{up,down}.sql`
- new `lego/backend/internal/notifications/` package

## Acceptance criteria

- [ ] Migration applies cleanly against a real Postgres instance.
- [ ] Settings default to Render's documented default (failure notifications on) when a workspace has none set.

## Out of scope

- Member-level opt-out granularity beyond what's needed for t003/t004 — keep it workspace-scoped unless Render's shape requires per-member.
