Skip to content

Database Migrations

All migrations are in apps/api/prisma/migrations/. Run with pnpm db:migrate. Never use prisma db push in production.


Migration History (75 migrations)

Newest last. Generated from ls apps/api/prisma/migrations/; descriptions inferred from each migration.sql.

#MigrationDescription
120260520173158_initInitial schema: users, invite_codes
220260520184824_add_password_hashAdd password_hash to users
320260520200000_interests_hierarchyinterests_catalog, user_interests with level hierarchy
420260520210000_invite_treeinvite_tree_nodes with ltree-style path + depth
520260520220000_social_circlescircles, circle_members
620260520230000_reputationreputation_events, reputation_snapshots
720260520240000_messagingconversations, conversation_members, messages
820260520250000_ai_assistantassistant_sessions, assistant_turns
920260520260000_notificationsnotifications, notification_preferences
1020260520270000_postsposts, post_reactions, post_bookmarks
1120260521120000_media_assetsmedia_assets with presigned upload pattern
1220260522180000_admin_layeraudit_log, reports, admin-facing columns
1320260523100000_discovery_and_interest_metaconnection_intents, interest accent_color/path
1420260523120000_audit_logAudit log performance indexes
1520260523140000_post_repliespost_replies table
1620260523150000_post_repostquoted_post_id on posts; repost + quote formats
1720260523160000_post_mutespost_mutes table
1820260523170000_message_reactionsmessage_reactions table
1920260523180000_convo_mutemuted_at on conversation_members
2020260523190000_user_mute_and_post_lifecycleuser_mutes, hidden_at/deleted_at on posts
2120260523200000_post_schedule_emit_and_mentionspublish_at, scheduled_emitted_at on posts
2220260523210000_blocks_and_reportsuser_blocks, reports table
2320260523220000_password_resetpassword_resets table
2420260523230000_muted_keywordsmuted_keywords table
2520260524100000_push_tokenspush_tokens table
2620260526000000_audit_perf_indexesComposite indexes on audit_log
2720260526200000_post_reply_kindkind on post_replies (reaction/criticism/contribution)
2820260526210000_circle_invitationscircle_invitations (bidirectional consent)
2920260526220000_reputation_votesreputation_votes (peer ±1 voting)
3020260526260000_feature_flagsfeature_flags with known flag seeds
3120260526270000_personaspersonas (max 5 per user)
3220260526280000_assistant_suggestionsassistant_suggestions + map-interests flow
3320260526290000_emoji_economyemoji_wallets, emoji_payments (EmojiPay)
3420260526300000_post_depthdepth on posts (0..5 content depth)
3520260526310000_post_interestspost_interests junction (multi-interest tagging)
3620260526320000_contribution_scorecontribution_events, contribution_snapshots
3720260526330000_post_boostpost_boosts + boost_score/boost_expires_at
3820260527000000_wikiwiki_entries, wiki_proposals, wiki_votes
3920260527010000_post_viewsviews counter on posts
4020260527020000_user_followsuser_follows (follow graph)
4120260527030000_post_pinnedpinned_at on posts (max 3 per author)
4220260527040000_post_seriespost_series, post_series_items
4320260527050000_post_journalismis_journalism flag on posts + rep gate
4420260527050100_series_followsseries_follows table
4520260527060000_reputation_appealsreputation_appeals + partial unique index
4620260527070000_interest_depth_3Interest level extended to 3 (depth-3 catalog)
4720260527080000_post_co_authorspost_co_authors (co-authorship + mana split)
4820260528000000_wiki_proposal_status_indexComposite (interest_id, status) on wiki_proposals
4920260528173000_post_persona_fkFK posts.persona_id → personas.id
5020260529100000_groupsGroups context (ADR-005): groups, members, join requests
5120260529110000_post_group_idOptional group_id on posts (group-scoped)
5220260529120000_group_invitesgroup_invites (manager-initiated)
5320260529130000_guildsGuilds context (ADR-006): merit-gated communities
5420260529190000_guilds_governanceguild_proposals + guild_votes
5520260529210000_guilds_weighted_votesRep-weighted guild voting
5620260529220000_pgvectorEnable pgvector extension
5720260529230000_posts_search_ginPosts full-text tsvector + GIN index
5820260603000000_events#Events context — gatherings + RSVP
5920260603010000_deliberationDeliberation: #Debates + #Problem
6020260603020000_educationEducation: courses → lessons + enrolment
6120260603030000_marketplaceMarketplace: offerings, market_orders, append-only ledger
6220260603040000_guild_treasuryguild_treasuries + append-only guild_ledger_entries
6320260603050000_post_translationsCached on-demand post translations
6420260604000000_projects#Projects — collaborative creation
6520260604010000_video_visits#VideoVisit — 60s video cards
6620260604020000_user_emblem#Art — symbolic profile emblem on users
6720260604030000_content_removedAdmin removed_at soft-remove for Wave 3–6 content
6820260604040000_flashcards#Education lesson flashcards
6920260604050000_audio_posts#AudioPost — voice/audio notes per interest
7020260606000000_activitypub_v1ActivityPub (ADR-008): user keypairs + remote followers
7120260606010000_activitypub_inboundAP inbound: follow remote actors + cache their posts
7220260606020000_video_socialVideoVisit reactions, reposts, comments
7320260607000000_user_last_seenPresence: last_seen_at for online/last-seen indicator
7420260607020000_pollsSingle-choice poll attached to a post
7520260608000000_reputation_snapshot_interest_indexCovering (interest_id, value) index for the leaderboard (audit)

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 deploy

Never:

  • prisma db push in production (skips migration history).
  • Hand-edit migration SQL after it's been committed.
  • DELETE rows from _prisma_migrations.

Regulus — invite-only social-knowledge platform