# Deploy Log Templates

Use these templates when creating Deploy Log entries in Notion.

---

## SMALL Tier Template

**When to use:** < 50 lines, no DB changes, no payment logic, easily reversible

```
Deploy: [Short name, e.g., "Fix login button styling"]
Date: [Today]
Status: ✅ Success
Type: Small (no snapshot)
Commit: [hash, e.g., "abc1234"]
Changed Files: [list files, e.g., "admin/src/components/Login.jsx"]
Rollback Command: git revert [commit-hash]
Notes:
[What changed]
- Fixed X
- Updated Y

[Verification]
- Tested locally: ✅
- Smoke test: ✅
```

### Example SMALL Entry

```
Deploy: Fix SMS timestamp display
Date: 2026-01-30
Status: ✅ Success
Type: Small (no snapshot)
Commit: 57151b7
Changed Files: admin/src/components/MessageList.jsx
Rollback Command: git revert 57151b7
Notes:
Changed timestamp format from UTC to local time.

Verification:
- Tested locally: ✅
- Smoke test: ✅ Messages show correct time
```

---

## MEDIUM Tier Template

**When to use:** 50-500 lines, new feature/endpoint, business logic changes

```
Deploy: [Short name, e.g., "Add lead scoring feature"]
Date: [Today]
Status: ✅ Success
Type: Medium (git tag + DB snapshot)
Commit: [hash]
Changed Files:
- [file 1]
- [file 2]
- [file 3]
Git Tag: pre-[feature-name]
Rollback Command:
git checkout pre-[feature-name]
git push -f origin main
Notes:
[What changed]
- Added X
- Modified Y
- Created Z

[Risk assessment]
- Affects: [what areas]
- Rollback safe: Yes/No

[Verification]
- Unit tests: ✅/❌
- Integration test: ✅/❌
- Manual smoke test: ✅/❌
- Tested on mobile: ✅/❌
```

### Example MEDIUM Entry

```
Deploy: Add AI message drafting
Date: 2026-01-30
Status: ✅ Success
Type: Medium (git tag + DB snapshot)
Commit: def5678
Changed Files:
- src/routes/ai.js
- src/services/ai.js
- admin/src/components/MessageComposer.jsx
- admin/src/hooks/useAIDraft.js
Git Tag: pre-ai-drafting
Rollback Command:
git checkout pre-ai-drafting
git push -f origin main
Notes:
Added AI-powered message drafting using GPT-4o.
Users can click "Draft with AI" to generate SMS text.

Risk assessment:
- Affects: Message composition, AI costs
- Rollback safe: Yes (no DB changes)

Verification:
- Unit tests: ✅ All passing
- Integration test: ✅ API responds correctly
- Manual smoke test: ✅ Generated 3 test messages
- Tested on mobile: ✅ Button accessible
```

---

## LARGE Tier Template

**When to use:** DB migration, payment logic, >500 lines, data deletion risk

```
Deploy: [Short name, e.g., "Add user roles schema"]
Date: [Today]
Status: ✅ Success
Type: Large (full snapshot)
Commit: [hash]
Changed Files:
- [file 1]
- [file 2]
- [migration files]
Git Tag: pre-[feature-name]
DB Backup: [timestamp from Supabase, e.g., "2026-01-30 14:30:00"]
Michael Approval: ✅ Approved [date/time]
Rollback Command:
# Step 1: Restore code
git checkout pre-[feature-name]
git push -f origin main

# Step 2: Restore database
# Go to Supabase Dashboard → Database → Backups
# Restore backup from: [timestamp]

# Step 3: Verify
# Check [specific things to verify]
Notes:
[What changed]
- Migration: [what schema changed]
- Code: [what code changed]

[Risk assessment]
- Affects: [what areas]
- Data impact: [what data is affected]
- Rollback complexity: [simple/moderate/complex]

[Pre-deploy checklist]
- [ ] Git tag created
- [ ] DB backup created
- [ ] Michael approved
- [ ] Rollback tested in staging

[Verification]
- Migration ran: ✅/❌
- Data integrity: ✅/❌
- All tests passing: ✅/❌
- Manual verification: ✅/❌
```

### Example LARGE Entry

```
Deploy: Add user roles and permissions
Date: 2026-01-30
Status: ✅ Success
Type: Large (full snapshot)
Commit: ghi9012
Changed Files:
- supabase/migrations/20260130_user_roles.sql
- src/middleware/auth.js
- src/routes/users.js
- admin/src/context/AuthContext.jsx
Git Tag: pre-user-roles
DB Backup: 2026-01-30 14:30:00 UTC
Michael Approval: ✅ Approved 2026-01-30 14:00
Rollback Command:
# Step 1: Restore code
git checkout pre-user-roles
git push -f origin main

# Step 2: Restore database
# Supabase Dashboard → Database → Backups
# Restore: 2026-01-30 14:30:00 UTC

# Step 3: Verify
# Check users can still login
# Check existing permissions work
Notes:
Added role-based access control:
- Migration: Added 'role' column to users table, created roles table
- Code: Auth middleware checks role before allowing actions

Risk assessment:
- Affects: All authenticated routes
- Data impact: Adds column to users (non-destructive)
- Rollback complexity: Moderate (need DB restore)

Pre-deploy checklist:
- [x] Git tag created
- [x] DB backup created
- [x] Michael approved
- [x] Rollback tested in staging

Verification:
- Migration ran: ✅
- Data integrity: ✅ All users have default role
- All tests passing: ✅
- Manual verification: ✅ Tested admin/user access
```

---

## Quick Reference

| Tier | Git Tag | DB Backup | Michael Approval |
|------|---------|-----------|------------------|
| SMALL | No | No | No |
| MEDIUM | Yes | No | No |
| LARGE | Yes | Yes | Yes |

## Creating Entries via API

```bash
curl -X POST "https://api.notion.com/v1/pages" \
  -H "Authorization: Bearer $NOTION_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Notion-Version: 2022-06-28" \
  -d '{
    "parent": { "database_id": "'$DEPLOY_LOG_DB'" },
    "properties": {
      "Deploy": { "title": [{ "text": { "content": "TITLE" } }] },
      "Status": { "select": { "name": "✅ Success" } },
      "Type": { "select": { "name": "Small (no snapshot)" } },
      "Date": { "date": { "start": "2026-01-30" } },
      "Commit": { "rich_text": [{ "text": { "content": "abc1234" } }] },
      "Changed Files": { "rich_text": [{ "text": { "content": "file1.js, file2.js" } }] },
      "Rollback Command": { "rich_text": [{ "text": { "content": "git revert abc1234" } }] },
      "Notes": { "rich_text": [{ "text": { "content": "What changed..." } }] }
    }
  }'
```
