Database Migrations
All migrations are in apps/api/prisma/migrations/. Run with pnpm db:migrate. Never use prisma db push in production.
Migration History (48 migrations)
| # | Migration | Date | Description |
|---|---|---|---|
| 1 | 20260520173158_init | 2026-05-20 | Initial schema: users, invite_codes |
| 2 | 20260520184824_add_password_hash | 2026-05-20 | Add password_hash column to users |
| 3 | 20260520200000_interests_hierarchy | 2026-05-20 | interests_catalog, user_interests with hierarchy + level |
| 4 | 20260520210000_invite_tree | 2026-05-20 | invite_tree_nodes with ltree-style path + depth |
| 5 | 20260520220000_social_circles | 2026-05-20 | circles, circle_members |
| 6 | 20260520230000_reputation | 2026-05-20 | reputation_events, reputation_snapshots |
| 7 | 20260520240000_messaging | 2026-05-20 | conversations, conversation_members, messages |
| 8 | 20260520250000_ai_assistant | 2026-05-20 | assistant_sessions, assistant_turns |
| 9 | 20260520260000_notifications | 2026-05-20 | notifications, notification_preferences |
| 10 | 20260520270000_posts | 2026-05-20 | posts, post_reactions, post_bookmarks |
| 11 | 20260521120000_media_assets | 2026-05-21 | media_assets with presigned upload pattern |
| 12 | 20260522180000_admin_layer | 2026-05-22 | audit_log, reports, admin-facing columns |
| 13 | 20260523100000_discovery_and_interest_meta | 2026-05-23 | connection_intents, interest accentColor and path fields |
| 14 | 20260523120000_audit_log | 2026-05-23 | Audit log performance indexes |
| 15 | 20260523140000_post_replies | 2026-05-23 | post_replies table |
| 16 | 20260523150000_post_repost | 2026-05-23 | quoted_post_id on posts; repost + quote formats |
| 17 | 20260523160000_post_mutes | 2026-05-23 | post_mutes table |
| 18 | 20260523170000_message_reactions | 2026-05-23 | message_reactions table |
| 19 | 20260523180000_convo_mute | 2026-05-23 | mutedAt on conversation_members |
| 20 | 20260523190000_user_mute_and_post_lifecycle | 2026-05-23 | user_mutes, hidden_at/deleted_at on posts |
| 21 | 20260523200000_post_schedule_emit_and_mentions | 2026-05-23 | publish_at, scheduled_emitted_at on posts |
| 22 | 20260523210000_blocks_and_reports | 2026-05-23 | user_blocks, reports table |
| 23 | 20260523220000_password_reset | 2026-05-23 | password_resets table |
| 24 | 20260523230000_muted_keywords | 2026-05-23 | muted_keywords table |
| 25 | 20260524100000_push_tokens | 2026-05-24 | push_tokens table |
| 26 | 20260526000000_audit_perf_indexes | 2026-05-26 | Composite indexes on audit_log for fast admin queries |
| 27 | 20260526200000_post_reply_kind | 2026-05-26 | kind column on post_replies: reaction/criticism/contribution |
| 28 | 20260526210000_circle_invitations | 2026-05-26 | circle_invitations table (bidirectional consent flow) |
| 29 | 20260526220000_reputation_votes | 2026-05-26 | reputation_votes table (peer ±1 voting) |
| 30 | 20260526260000_feature_flags | 2026-05-26 | feature_flags table with known flag seeds |
| 31 | 20260526270000_personas | 2026-05-26 | personas table (user personas, max 5) |
| 32 | 20260526280000_assistant_suggestions | 2026-05-26 | assistant_suggestions table + map-interests flow |
| 33 | 20260526290000_emoji_economy | 2026-05-26 | emoji_wallets, emoji_payments (EmojiPay) |
| 34 | 20260526300000_post_depth | 2026-05-26 | depth column on posts (0..5 content depth) |
| 35 | 20260526310000_post_interests | 2026-05-26 | post_interests junction for multi-interest tagging |
| 36 | 20260526320000_contribution_score | 2026-05-26 | contribution_events, contribution_snapshots |
| 37 | 20260526330000_post_boost | 2026-05-26 | post_boosts table + boost_score/boost_expires_at on posts |
| 38 | 20260527000000_series_follows | 2026-05-27 | series_follows table |
| 39 | 20260527000000_wiki | 2026-05-27 | wiki_entries, wiki_proposals, wiki_votes |
| 40 | 20260527010000_post_views | 2026-05-27 | views counter on posts |
| 41 | 20260527020000_user_follows | 2026-05-27 | user_follows table (follow graph) |
| 42 | 20260527030000_post_pinned | 2026-05-27 | pinned_at on posts (max 3 per author) |
| 43 | 20260527040000_post_series | 2026-05-27 | post_series, post_series_items tables |
| 44 | 20260527050000_post_journalism | 2026-05-27 | is_journalism flag on posts + rep gate |
| 45 | 20260527060000_reputation_appeals | 2026-05-27 | reputation_appeals table + partial unique index |
| 46 | 20260527070000_interest_depth_3 | 2026-05-27 | Interest level extended to 3 (depth-3 catalog) |
| 47 | 20260527080000_post_co_authors | 2026-05-27 | post_co_authors table (co-authorship + mana split) |
| 48 | (ongoing) | — | Future migrations follow the same naming convention |
Running Migrations
bash
# Run all pending migrations
pnpm db:migrate
# Generate a new migration (dev only)
cd apps/api && npx prisma migrate dev --name <name>
# Deploy to production
npx prisma migrate deployNever:
prisma db pushin production (skips migration history).- Hand-edit migration SQL after it's been committed.
- DELETE rows from
_prisma_migrations.