Skip to content

feat: add database migrations for D1 schema initialization#18

Merged
taco-jpg merged 1 commit into
mainfrom
claude/wonderful-bell-RMVsb
May 24, 2026
Merged

feat: add database migrations for D1 schema initialization#18
taco-jpg merged 1 commit into
mainfrom
claude/wonderful-bell-RMVsb

Conversation

@taco-jpg
Copy link
Copy Markdown
Owner

Summary

  • Add D1 database migration files that were missing from the repository
  • Create P2PSignal table for WebRTC signaling coordination
  • Create Message table for encrypted relay message storage
  • Add performance indexes for message lookups

Why This Matters

The README documented the migration steps (npx wrangler d1 migrations apply) but the actual migration files were not in the repository, blocking deployment of Serotine to fresh Cloudflare D1 instances.

Changes

  • Create migrations/0001_init_schema.sql with:
    • P2PSignal table schema (matches usage in app/actions.ts)
    • Message table schema (matches usage in app/actions.ts)
    • Indexes on messageId, receiverPubKeyHash, and expiresAt for query performance

Validation

  • ✅ Next.js build succeeds
  • ✅ TypeScript compilation passes
  • ✅ ESLint check passes
  • ✅ Migration SQL syntax is valid SQLite

Generated by Claude Code

- Create P2PSignal table for WebRTC signaling coordination
- Create Message table for encrypted relay message storage
- Add indexes for performant lookups on messageId and receiverPubKeyHash
- Enables deployment of Serotine on fresh Cloudflare D1 instances
Copilot AI review requested due to automatic review settings May 24, 2026 10:05
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
serotine c13b653 Commit Preview URL

Branch Preview URL
May 24 2026, 10:05 AM

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c13b653de9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

);

-- Create index on messageId for fast lookups
CREATE INDEX IF NOT EXISTS idx_p2psignal_messageid ON P2PSignal(messageId);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Remove redundant index on unique messageId

messageId is declared UNIQUE, which already creates an index in SQLite/D1; adding idx_p2psignal_messageid duplicates that index and adds unnecessary write/storage overhead on every insert/update to P2PSignal. This is most noticeable under frequent signaling updates, where each write now maintains two indexes for the same key.

Useful? React with 👍 / 👎.

@taco-jpg taco-jpg merged commit 478b586 into main May 24, 2026
1 of 2 checks passed
@taco-jpg taco-jpg deleted the claude/wonderful-bell-RMVsb branch May 24, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants