Skip to content

Harden type/data model consistency for chatrooms and realtime events#4

Open
ocrichardbot wants to merge 1 commit intosgzsh269:mainfrom
ocrichardbot:feat/type-data-model-hardening
Open

Harden type/data model consistency for chatrooms and realtime events#4
ocrichardbot wants to merge 1 commit intosgzsh269:mainfrom
ocrichardbot:feat/type-data-model-hardening

Conversation

@ocrichardbot
Copy link

Summary

This PR tackles the type-consistency hardening gap by aligning DB schema types and event payload contracts across API + realtime layers.

Changes

  • Convert chatrooms.is_private from text ("0"/"1") to boolean in Drizzle schema
  • Convert chatroom_invites.max_uses from text to integer in Drizzle schema
  • Add migration 0001_type_hardening.sql to safely convert existing values
  • Add zod request validation for POST /api/chatrooms
  • Update chatroom creation to persist boolean isPrivate directly
  • Update invite usage-limit check to use integer maxUses directly
  • Fix realtime frontend types to use UUID strings for updatedBy.id and member.id

Why

  • Removes fragile text-to-boolean and text-to-number coercions
  • Reduces runtime mismatch risk between backend UUIDs and frontend event types
  • Adds API boundary validation for more predictable behavior

Notes

  • I could not run project lint/tests in this environment because bun is not installed on the host (bun: command not found).

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.

1 participant