PhoenixKit.Migrations.Postgres.V36 (phoenix_kit v1.7.71)

Copy Markdown View Source

PhoenixKit V36 Migration: Connections Module - Social Relationships System

Adds complete social relationships system with follows, connections, and blocking.

Architecture

Each relationship type has two tables:

  • Main table: Current state only (one row per user pair)
  • History table: Activity log of all changes over time

Changes

User Follows Table (phoenix_kit_user_follows)

  • One-way follow relationships (no consent required)
  • Stores only CURRENT follows (row deleted when unfollowed)
  • Unique constraint ensures one row per user pair

User Follows History Table (phoenix_kit_user_follows_history)

  • Logs all follow/unfollow events
  • Actions: "follow", "unfollow"
  • Preserves full audit trail

User Connections Table (phoenix_kit_user_connections)

  • Two-way mutual relationships (requires acceptance)
  • Stores only CURRENT status per user pair
  • Status: "pending", "accepted" (rejected rows are deleted)

User Connections History Table (phoenix_kit_user_connections_history)

  • Logs all connection events
  • Actions: "requested", "accepted", "rejected", "removed"
  • Preserves full audit trail

User Blocks Table (phoenix_kit_user_blocks)

  • Blocking prevents all interaction
  • Stores only CURRENT blocks (row deleted when unblocked)
  • Unique constraint ensures one row per user pair

User Blocks History Table (phoenix_kit_user_blocks_history)

  • Logs all block/unblock events
  • Actions: "block", "unblock"
  • Preserves full audit trail

Settings

  • connections_enabled: Enable/disable entire module

Features

  • UUIDv7 primary keys for time-sortable IDs
  • Comprehensive indexes for efficient queries
  • Foreign key constraints for data integrity
  • Complete activity history for auditing

Summary

Functions

Rollback the V36 migration.

Run the V36 migration to add connections system.

Functions

down(opts)

Rollback the V36 migration.

up(opts)

Run the V36 migration to add connections system.