Post Scheduler — Per-Platform Scheduling Migration
This migration replaces the single-timestamp customer_posts.scheduled column with per-platform scheduling via customer_platform_post.scheduled_at. Scheduling is driven by each platform's customer_posting_schedule frequency entry (algorithmic — no LLM). The ClientOverview scheduled tab gains a week calendar showing individual platform post chips.
Steps
| Step | File | Focus | Prerequisites |
|---|---|---|---|
| 1 | step-1-db-migration.md | Drop customer_posts.scheduled column | None |
| 2 | step-2-posts-service.md | Rewrite scheduling service functions to operate on customer_platform_post.scheduled_at | Step 1 |
| 3 | step-3-clients-service.md | Update listScheduledPosts, listAllScheduledPosts, getClientDashboard, getDailyBriefingSummary | Step 2 |
| 4 | step-4-plan-schedule-route.md | Rewrite planAndScheduleApprovedPosts to full-algorithmic per-platform | Steps 2–3 |
| 5 | step-5-bot-tools.md | Update bot tool descriptions + behaviour | Steps 2–3 |
| 6 | step-6-frontend-types-store.md | Remove scheduled from types, store, shared components | Step 1 |
| 7 | step-7-client-overview.md | Add week calendar to ClientOverview scheduled tab, remove scheduled column | Step 6 |
Dependency Order
Step 1 (DB migration — apply locally via `pnpm supabase db reset`)
└── Step 2 (posts.service.ts — core scheduling functions)
├── Step 3 (clients.service.ts — query updates)
├── Step 4 (plan-schedule route — algorithmic scheduler)
└── Step 5 (bot tools — description + behaviour)
Step 6 (frontend types/store — independent of API steps after Step 1)
└── Step 7 (ClientOverview calendar tab)
Steps 2–5 can be done in any order relative to Steps 6–7, as long as Step 1 is applied first.
Scope Summary
- Removed:
customer_posts.scheduledcolumn, all code that reads/writes it, all LLM scheduling logic - Existing:
customer_platform_post.scheduled_atcolumn (already in schema) is now the single source of truth for scheduling - Scheduling logic: Algorithmic only — uses
customer_posting_schedule.frequency(andcustom_interval_days) per platform to compute next-slot times - Parent post status:
customer_posts.status = 'scheduled'is still valid; set when any platform post receives ascheduled_at - Manual scheduling via bot:
schedule_postandschedule_multiple_postsbot tools are kept; they now operate on platform posts instead of the parent - No auto-publisher changes: The scheduler directory is empty; there is no background job that reads
customer_posts.scheduledtoday
Verification Checklist
After all steps are complete:
- [ ]
customer_poststable has noscheduledcolumn in Supabase Studio - [ ]
customer_platform_post.scheduled_atis populated after callingPOST /plan_post_schedule - [ ] Platform posts for different platforms have different
scheduled_atvalues reflecting their respective frequencies - [ ]
customer_posts.status='scheduled'after platform posts are scheduled - [ ]
GET /client/:id/posts/scheduledreturns platform-post-level data - [ ] Bot
schedule_posttool schedules platform posts (not parent post) - [ ]
pnpm test:tscinfront-end/passes with noscheduledfield errors - [ ]
pnpm test:routesinapi/passes - [ ] ClientOverview → Scheduled tab → week calendar renders platform chips on correct days
- [ ] No
scheduledcolumn visible in either the Pending or Scheduled post tables