# Migration 023 — live_business_approvals

**Status:** DOCUMENTED ONLY — **NOT EXECUTED**  
**Authority required:** Brad Camp  
**Date drafted:** 2026-07-24  
**Phase:** Live Phase 2A interim uses `App/secure/live/approvals/*.json` (web-denied). This SQL is the future Foundation table.

## Purpose

Persist Live first-use purpose and approval status (`pending` | `approved` | `denied`) per Foundation business (`franchise_id`), without creating a second users or businesses table.

## Proposed SQL (DO NOT RUN until Brad authorizes)

```sql
-- Migration 023 — NOT EXECUTED
-- live_business_approvals

CREATE TABLE IF NOT EXISTS live_business_approvals (
  id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  business_id VARCHAR(64) NOT NULL COMMENT 'Foundation franchise_id',
  user_id BIGINT UNSIGNED NOT NULL COMMENT 'users.id who submitted',
  purpose_text TEXT NOT NULL,
  purpose_hash CHAR(64) NOT NULL,
  status ENUM('pending','approved','denied','superseded') NOT NULL DEFAULT 'pending',
  moderator_source ENUM('none','ai','human','auto') NOT NULL DEFAULT 'none',
  moderator_note TEXT NULL,
  approved_at DATETIME NULL,
  created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (id),
  KEY idx_live_approvals_business (business_id),
  KEY idx_live_approvals_status (status),
  KEY idx_live_approvals_user (user_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
```

## Interim Phase 2A storage

| Path | Role |
|------|------|
| `App/secure/live/approvals/{franchise_id}.json` | Purpose + status per business |
| Parent `.htaccess` | Deny from all |

## Rules

- Do **not** create `users`, `login`, `businesses`, or password tables for Live.
- Do **not** run this migration without Brad’s written authorization.
- After migration is authorized and executed, a follow-on task may move JSON rows into the table and retire the file store.
