Alert Slack when PlanetScale database changes stall
Checks your PlanetScale database changes every hour on weekdays and posts one Slack alert when something is stuck, errored, or waiting on approval.
Every hour on weekdays, check our PlanetScale deploy requests and tell us in Slack when a schema migration is stalling, so that nothing sits waiting silently.
Start by listing the PlanetScale databases in our organization so the check covers all of them rather than a hardcoded few. For each database, list its deploy requests and keep the ones that are still open. Also get the deploy queue for each database, so you can see what is currently lined up to be applied and how long it has been sitting there.
For every open deploy request, get the deploy request detail and list its reviews. The detail gives you the branch, the deploy request number, when it was opened, its current state, and the schema changes it contains. Remember that deploy requests are addressed by number rather than by id. The reviews tell you who has looked at it and whether anyone actually approved it, as opposed to just commenting.
Flag a deploy request when any of these three things is true. First, it has been open for more than 24 hours and has no approving review. Second, it is in an errored state. Third, it has been sitting in the deploy queue longer than expected, which by default means more than 30 minutes without progressing.
If anything is flagged, post one grouped message to our engineering Slack channel. Do not send a separate message per deploy request. Group the findings under three headings, waiting on review, errored, and stuck in the queue. For each item, name the database, the branch, the deploy request number, how long it has been waiting in plain terms such as 3 days or 6 hours, and who still owes a review. If nobody has been requested as a reviewer, say that plainly rather than guessing at a name.
For each flagged deploy request, add one short plain language sentence describing what the schema change actually does, for example adding a nullable column to a table, dropping an index, or widening a column type. Base this on the deploy request detail rather than speculating, and if the change is unclear say so instead of inventing a description. The goal is that someone skimming the channel understands the risk without opening PlanetScale.
If nothing meets the criteria, do nothing at all and send no Slack message. A quiet channel is the correct output for a healthy hour. Posting an all clear message every hour would make the alert easy to tune out, which defeats the point.
This workflow is strictly read only against PlanetScale. Never queue a deploy request, never complete a gated deploy request, and never revert one, even if a deploy request looks obviously ready or obviously broken, and even if a revert window is about to close. Reporting is the entire job and a human decides what to do next.
Keep the 24 hour review threshold, the deploy queue threshold, the target Slack channel, and the PlanetScale organization name as clearly labelled settings at the top of the workflow, since we will want to tune them without rewriting the logic.
What does this prompt do?
- Checks every hour on weekdays for database changes waiting to go live across all of your databases
- Flags three problems: changes open more than 24 hours with nobody approving, changes that hit an error, and changes stuck in line waiting to be applied
- Posts a single grouped Slack message naming the database, the branch, how long it has been waiting, and who still owes an approval
- Adds a plain language sentence explaining what each pending change actually does, and stays completely silent when everything is healthy
What do I need to use this?
- A PlanetScale account with access to the databases you want watched
- The name of your PlanetScale organization
- A Slack workspace and a channel where engineering alerts should land
How can I customize it?
- Change the 24 hour no-approval threshold to match how quickly your team normally reviews changes
- Point the alert at a different Slack channel, or run separate copies per team or per database
- Adjust the schedule, which runs hourly on weekdays by default, or narrow it to only your production databases
FAQs
Will this ever apply or undo a database change on its own?
What happens when nothing is wrong?
Does it check all of our databases or just one?
Can I change how long something waits before it gets flagged?
Will it keep alerting about the same stuck change every hour?
Related templates
When someone leaves, we check which shared passwords they used in their final months and post a ranked rotation list to your security channel.
Every Monday, check every S3 bucket for public exposure, missing encryption and weak backup settings, then get the risks ranked in Slack.
Twice every weekday, the conversations from your social inbox land on the right HubSpot contact timelines, with a Slack recap for sales.
Every morning, find the addresses that hard bounced or filed a spam complaint, update the matching HubSpot contacts, and post a short Slack recap.
Every weekday at 4pm, spot the threads that went quiet, stage a ready-to-send nudge in your mailbox, and get a ranked Slack recap.
When you merge a fix in GitHub, this agent checks the matching dead-letter queue, replays the failed messages, and reports back on the pull request and in Slack.
Stop letting database changes sit unnoticed.
Get one Slack nudge the moment a schema change stalls, errors, or waits too long on a reviewer, and silence when everything is on track.