diff --git a/CLAUDE.md b/CLAUDE.md index 6d3044e..af7d516 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -33,7 +33,6 @@ Cloudflare Workers with two entry points exported from `src/index.js`: | GET | `/` | inline | Health check | | POST | `/webhook/telegram` | `bot-commands.js` | grammY `webhookCallback("cloudflare-mod")` | | POST | `/webhook/status/:secret` | `statuspage-webhook.js` | Receives Statuspage webhooks (URL secret) | -| POST | `/migrate/:secret` | inline | One-time KV migration (remove after use) | ### Data Flow diff --git a/README.md b/README.md index 376b716..daecd43 100644 --- a/README.md +++ b/README.md @@ -105,16 +105,6 @@ It will prompt for your bot token and worker URL. You should see `{"ok":true}` f Replace `` with the secret you set in step 4. -### 8. Run migration (if upgrading) - -If you have existing subscribers from an older version, run the migration endpoint once: - -```bash -curl -X POST https:///migrate/ -``` - -This converts the old single-key format to per-subscriber KV keys. Remove the `/migrate` route from `src/index.js` after confirming success. - ## Local Development ```bash diff --git a/src/index.js b/src/index.js index 6f658f0..c0d254d 100644 --- a/src/index.js +++ b/src/index.js @@ -2,8 +2,6 @@ import { Hono } from "hono"; import { handleTelegramWebhook } from "./bot-commands.js"; import { handleStatuspageWebhook } from "./statuspage-webhook.js"; import { handleQueue } from "./queue-consumer.js"; -import { migrateFromSingleKey } from "./kv-store.js"; -import { timingSafeEqual } from "./crypto-utils.js"; const app = new Hono(); @@ -24,15 +22,6 @@ app.get("/", (c) => c.text("Claude Status Bot is running")); app.post("/webhook/telegram", (c) => handleTelegramWebhook(c)); app.post("/webhook/status/:secret", (c) => handleStatuspageWebhook(c)); -// One-time migration route — remove after migration is confirmed -app.post("/migrate/:secret", async (c) => { - const secret = c.req.param("secret"); - if (!await timingSafeEqual(secret, c.env.WEBHOOK_SECRET)) { - return c.text("Unauthorized", 401); - } - const count = await migrateFromSingleKey(c.env.claude_status); - return c.json({ migrated: count }); -}); export default { fetch: app.fetch, diff --git a/src/kv-store.js b/src/kv-store.js index cf67f14..c3a74ed 100644 --- a/src/kv-store.js +++ b/src/kv-store.js @@ -136,31 +136,3 @@ export async function getSubscribersByType(kv, eventType, componentName = null) return results; } - -/** - * One-time migration from single-key "subscribers" to per-key format. - * Returns count of migrated entries. - */ -export async function migrateFromSingleKey(kv) { - const old = await kv.get("subscribers", "json"); - if (!old) return 0; - - const entries = Object.entries(old); - for (const [compositeKey, value] of entries) { - const data = { types: value.types || [], components: value.components || [] }; - await kv.put(`${KEY_PREFIX}${compositeKey}`, JSON.stringify(data), { - metadata: buildMetadata(data.types, data.components), - }); - } - - // Verify migrated count before deleting old key - const migrated = await listAllSubscriberKeys(kv); - if (migrated.length >= entries.length) { - await kv.delete("subscribers"); - console.log(`Migration complete: ${entries.length} subscribers migrated`); - } else { - console.error(`Migration verification failed: expected ${entries.length}, got ${migrated.length}`); - } - - return entries.length; -}