Skip to content

[Refactor] Approval workflow uses in-memory store — all submissions lost on restart #774

Description

@RUKAYAT-CODER

Overview

src/app/api/approvals/route.ts uses a module-level Map as its data store. Content submitted for approval disappears on every server restart or cold start. In a production environment with autoscaling or periodic restarts, this makes the approval workflow completely unreliable.

Specifications

Features:

  • Approval submissions are persisted to the database
  • The approval queue survives restarts and works across multiple server instances

Tasks:

  • Create a content_approvals table with all ApprovalItem fields
  • Replace in-memory CRUD operations with SQL queries
  • Update GET/POST/PATCH handlers to be async with proper error handling
  • Migrate the generateId helper to use uuid for database-compatible IDs

Impacted Files:

  • src/app/api/approvals/route.ts
  • src/lib/db/ (new migration)

Acceptance Criteria

  • Approval items persist across server restarts
  • Two concurrent server instances see the same approval queue
  • GET /api/approvals returns items from the database, not module memory

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions