mitbringsl/backend/migrations/000002_add_invite_code.up.sql
Tronax 69591df12a
Feature: Shared lists & Invite Code invitation mechanism
- Backend:
  - Migration 000002: add invite_code column to lists & list_members auto-population
  - ListStore: GetLists/GetList check owner_id & list_members; add GetInviteCode & JoinByInviteCode
  - HTTP API: add POST /api/lists/{id}/invite & POST /api/lists/join
- Android App:
  - DTOs & MitbringslApi: add JoinListRequestDto, InviteCodeResponseDto & endpoints
  - ListsScreen & ViewModel: add 'Liste beitreten' action button & dialog for entering invite code
  - ListDetailScreen & ViewModel: add 'Liste teilen' action icon in top bar with System Share Sheet
- ADB reinstall & launch verified 
2026-08-05 20:36:43 +02:00

13 lines
507 B
SQL

-- Add invite_code to lists table for sharing
ALTER TABLE lists ADD COLUMN IF NOT EXISTS invite_code TEXT UNIQUE;
-- Generate random 8-character invite code for lists that don't have one
UPDATE lists
SET invite_code = UPPER(SUBSTRING(MD5(RANDOM()::TEXT) FROM 1 FOR 8))
WHERE invite_code IS NULL;
-- Automatically insert owner into list_members on list creation if missing
INSERT INTO list_members (list_id, user_id, role)
SELECT id, owner_id, 'owner'
FROM lists
ON CONFLICT (list_id, user_id) DO NOTHING;