Skip to content

Commit 6103289

Browse files
Digidaiclaude
andcommitted
ci: auto-apply D1 schema migrations before Worker deploy
Runs schema.sql on remote D1 before deploying Worker code. Uses CREATE TABLE/INDEX IF NOT EXISTS so it's safe to run on every deploy. Ensures new tables (ingest_log) and indexes are available when the new Worker code goes live. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 48d49cf commit 6103289

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

.github/workflows/deploy-worker.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ jobs:
3535
cd worker
3636
npx wrangler vectorize create mails-embeddings --dimensions 768 --metric cosine 2>&1 || echo "Vectorize index already exists or creation skipped"
3737
38+
- name: Apply D1 schema migrations
39+
env:
40+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
41+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
42+
D1_ID: ${{ secrets.D1_DATABASE_ID }}
43+
run: cd worker && npx wrangler d1 execute "$D1_ID" --file=schema.sql --remote
44+
3845
- name: Deploy to Cloudflare Workers
3946
uses: cloudflare/wrangler-action@v3
4047
with:

0 commit comments

Comments
 (0)