Ai-Mee Help Centre
Home
Features
How-To Guides
FAQ
Need Help?
Home
Features
How-To Guides
FAQ
Need Help?

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

StepFileFocusPrerequisites
1step-1-db-migration.mdDrop customer_posts.scheduled columnNone
2step-2-posts-service.mdRewrite scheduling service functions to operate on customer_platform_post.scheduled_atStep 1
3step-3-clients-service.mdUpdate listScheduledPosts, listAllScheduledPosts, getClientDashboard, getDailyBriefingSummaryStep 2
4step-4-plan-schedule-route.mdRewrite planAndScheduleApprovedPosts to full-algorithmic per-platformSteps 2–3
5step-5-bot-tools.mdUpdate bot tool descriptions + behaviourSteps 2–3
6step-6-frontend-types-store.mdRemove scheduled from types, store, shared componentsStep 1
7step-7-client-overview.mdAdd week calendar to ClientOverview scheduled tab, remove scheduled columnStep 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.scheduled column, all code that reads/writes it, all LLM scheduling logic
  • Existing: customer_platform_post.scheduled_at column (already in schema) is now the single source of truth for scheduling
  • Scheduling logic: Algorithmic only — uses customer_posting_schedule.frequency (and custom_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 a scheduled_at
  • Manual scheduling via bot: schedule_post and schedule_multiple_posts bot 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.scheduled today

Verification Checklist

After all steps are complete:

  • [ ] customer_posts table has no scheduled column in Supabase Studio
  • [ ] customer_platform_post.scheduled_at is populated after calling POST /plan_post_schedule
  • [ ] Platform posts for different platforms have different scheduled_at values reflecting their respective frequencies
  • [ ] customer_posts.status = 'scheduled' after platform posts are scheduled
  • [ ] GET /client/:id/posts/scheduled returns platform-post-level data
  • [ ] Bot schedule_post tool schedules platform posts (not parent post)
  • [ ] pnpm test:tsc in front-end/ passes with no scheduled field errors
  • [ ] pnpm test:routes in api/ passes
  • [ ] ClientOverview → Scheduled tab → week calendar renders platform chips on correct days
  • [ ] No scheduled column visible in either the Pending or Scheduled post tables