Skip to main content

Database Schema Analysis

Overview

This document provides a comprehensive analysis of the legacy TorrentPier database schema, identifying all tables organized by functional domain, their relationships, and recommendations for modernization in the Laravel rewrite.

Key Architecture Insight: TorrentPier is a forum-integrated BitTorrent tracker where media content descriptions are stored in forum posts, and the tracker system links directly to forum topics via topic_id. This tight integration means that media metadata should live in the forum content, not the torrent tracking tables.

Table Inventory by Functional Domain

1. Forum System (Core Content)

TablePurposeReplacement
bb_categoriesForum categoriesKeep with improvements
bb_forumsIndividual forums within categoriesKeep with improvements
bb_topicsForum topicsKeep with improvements
bb_postsIndividual posts in topicsKeep with improvements
bb_posts_textPost content storageMerge into posts table

2. BitTorrent Tracker System

TablePurposeReplacement
bb_bt_torrentsCore torrent registryKeep with improvements
bb_bt_trackerActive peer trackingKeep with improvements
bb_bt_usersUser tracker statisticsKeep with improvements
bb_bt_tracker_snapTracker statistics snapshotsReplace with Laravel Queues
bb_bt_dlstatus_snapDownload status snapshotsReplace with Laravel Queues
bb_bt_dlstatusDownload status trackingMerge into torrent statistics per user
bb_bt_torstatTorrent statistics per userKeep with improvements
bb_bt_tor_dl_statTorrent download statisticsMerge into torrent statistics per user
bb_bt_last_torstatLast torrent statisticsReplace with Laravel Queues
bb_bt_last_userstatLast user statisticsReplace with Laravel Queues
bb_bt_torhelpTorrent help systemReplace with Laravel Queues
bb_bt_user_settingsUser tracker preferencesMerge into user settings

3. Attachment System

TablePurposeReplacement
bb_attachmentsLinks attachments to postsKeep with improvements
bb_attachments_descAttachment metadataKeep with improvements
bb_extensionsFile extension validationRemove
bb_extension_groupsExtension categories (Images, Archives, etc.)Remove
bb_attachments_configComplex attachment configurationReplace with Laravel Config
bb_attach_quotaUser/group attachment quotasRemove
bb_quota_limitsQuota limit definitionsRemove

Current Complexity: Supports multiple file type categories with complex permissions, quotas, and download modes

Modern Approach: Only support .torrent files and basic archives (.zip, .rar, .7z)

4. User Management

TablePurposeReplacement
bb_usersUser accountsKeep with improvements
bb_groupsUser groupsKeep with role-based permissions
bb_user_groupUser groups membershipsKeep with improvements
bb_ranksUser ranks/titlesKeep with improvements
bb_auth_accessGroup forum permissionsModernize with Laravel policies
bb_auth_access_snapUser permission snapshotsRemove

5. System Management

TablePurposeReplacement
bb_configApplication configurationReplace with Laravel Config
bb_sessionsUser sessionsReplace with Laravel Sessions
bb_cronScheduled task managementReplace with Laravel Queues
bb_logAction loggingKeep with improvements

6. Messaging System

TablePurposeReplacement
bb_privmsgsPrivate messagesKeep with improvements
bb_privmsgs_textPrivate message contentMerge into private messages table

7. Search & Caching

TablePurposeReplacement
bb_posts_searchSearch index for postsReplace with Laravel Scout
bb_posts_htmlCached HTML postsReplace with Laravel Cache
bb_search_resultsSearch result cacheReplace with Laravel Scout
bb_search_rebuildSearch rebuild statusReplace with Laravel Scout

8. Content Management

TablePurposeReplacement
bb_smiliesEmoticonsKeep with improvements
bb_wordsWord censoringKeep with improvements
bb_banlistUser bansKeep with improvements
bb_disallowDisallowed usernamesReplace with word censoring

9. Community Features

TablePurposeReplacement
bb_poll_votesPoll voting optionsKeep with improvements
bb_poll_usersPoll participationKeep with improvements
bb_topics_watchTopic watching/subscriptionsKeep with improvements
bb_topic_tplTopic templatesRemove
bb_thxThanks/voting systemKeep with improvements

10. Buffer/Temporary Tables

TablePurposeReplacement
buf_topic_viewTopic view counting bufferReplace with Laravel Queues
buf_last_seederLast seeder bufferReplace with Laravel Queues
Various snapshot tablesStatistical buffersRemove

Major Simplifications for Modern Laravel App

1. Attachment System Redesign

Current: 7 tables supporting multiple file types with complex quotas

Modern: 1-2 tables supporting only torrents and archives

2. Remove Buffer/Snapshot Tables

Current: 5+ buffer tables for performance optimization

Modern: Use Laravel Queues, events, and background jobs

3. Modernize Configuration

Current: Database-stored configuration in bb_config

Modern: Laravel config files and environment variables

4. Simplify Authentication/Authorization

Current: Complex custom permission system

Modern: Laravel Sanctum + Policies + Role-based permissions

Current: Custom search indexing and caching

Modern: Laravel Scout with Meilisearch

Proposed Modern Schema Reduction

Major Eliminations:

  • Buffer/snapshot tables
  • Complex attachment system
  • Custom configuration system (replaced by Laravel)
  • Custom search system (replaced by Scout)
  • Legacy features (topic templates, complex quotas)

Conclusion

The legacy schema contains significant complexity that was necessary for a custom PHP application but can be greatly simplified using modern Laravel features. The core forum-tracker integration should be preserved while modernizing the implementation approach.