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

Copy Markdown View Source

PhoenixKit V29 Migration: Posts System

Adds complete social posts system with media attachments, comments, likes, tags, user groups, and scheduled publishing.

Changes

Posts Table (phoenix_kit_posts)

  • Main posts storage with type-specific layouts (post/snippet/repost)
  • Privacy controls (draft/public/unlisted/scheduled)
  • Denormalized counters for performance (likes, comments, views)
  • SEO-friendly slugs
  • Scheduled publishing support

Post Media Junction (phoenix_kit_post_media)

  • Many-to-many between posts and files (Storage system)
  • Ordered image galleries with captions
  • Position-based ordering

Post Likes (phoenix_kit_post_likes)

  • User likes on posts
  • Unique constraint per user/post

Post Comments (phoenix_kit_post_comments)

  • Nested threaded comments (unlimited depth)
  • Self-referencing for comment threads
  • Depth tracking for efficient queries

Post Mentions (phoenix_kit_post_mentions)

  • Tag users as contributors/mentions
  • Unique per user/post

Post Tags (phoenix_kit_post_tags)

  • Hashtag system for categorization
  • Auto-slugification
  • Usage counter tracking

Post Tag Assignments (phoenix_kit_post_tag_assignments)

  • Many-to-many between posts and tags

Post Groups (phoenix_kit_post_groups)

  • User-created collections (Pinterest-style)
  • Public/private visibility
  • Cover images
  • Manual ordering

Post Group Assignments (phoenix_kit_post_group_assignments)

  • Many-to-many between posts and groups
  • Position-based ordering within groups

Post Views (phoenix_kit_post_views)

  • Analytics tracking (future feature)
  • Session-based deduplication

Settings

  • Content limits: max media, title length, subtitle length, content length, mentions, tags
  • Module config: enabled, per-page, default status
  • Feature toggles: comments, likes, scheduling, groups, reposts, SEO, view counts
  • Moderation: require approval, comment moderation

Features

  • UUIDv7 primary keys for time-sortable IDs
  • Comprehensive indexes for efficient queries
  • Foreign key constraints for data integrity
  • Denormalized counters to avoid expensive COUNT queries
  • Support for scheduled publishing via Oban
  • Type-specific post layouts

Summary

Functions

Rollback the V29 migration.

Run the V29 migration to add posts system.

Functions

down(opts)

Rollback the V29 migration.

up(opts)

Run the V29 migration to add posts system.