Storage System
Storage System
Flatboard 5 supports two storage systems: JSON (file-based) and SQLite (database). This guide explains both systems and how to choose between them.
Storage Overview
JSON Storage
- Available in: Community and Pro Editions
- Type: File-based storage
- Format: JSON files in
/stockage/json/ - Best for: Small to medium communities
- Pros: Simple, no database, easy backups
- Cons: Slower for very large datasets
SQLite Storage
- Available in: Pro Edition only
- Type: Database storage
- Format: SQLite database file
- Best for: Medium to large communities
- Pros: Better performance, SQL queries, transactions
- Cons: Requires
pdo_sqliteextension
JSON Storage
Structure
JSON storage uses organized file structure:
stockage/json/
âââ config.json # Configuration
âââ users/ # User data
â âââ user_123.json
â âââ user_456.json
âââ categories/ # Categories
â âââ category_1.json
â âââ category_2.json
âââ discussions/ # Discussions
â âââ discussion_1.json
â âââ discussion_2.json
âââ posts/ # Posts
âââ post_1.json
âââ post_2.jsonFile Format
Example user file (users/user_123.json):
{
"id": "123",
"username": "john_doe",
"email": "[email protected]",
"password_hash": "$2y$10$...",
"created_at": "2025-12-25T10:00:00Z",
"group_id": "member",
"reputation": 100
}Advantages
- No Database Required - Works without database setup
- Easy Backups - Simple file copy
- Human Readable - JSON files are readable
- Portable - Easy to move between servers
- Version Control - Can use Git for versioning
Limitations
- Performance - Slower for large datasets
- Concurrent Access - File locking required
- No SQL Queries - Limited query capabilities
- File System - Depends on file system performance
SQLite Storage (Pro Edition)
Database Structure
SQLite uses standard relational database:
-- Users table
CREATE TABLE users (
id TEXT PRIMARY KEY,
username TEXT UNIQUE NOT NULL,
email TEXT UNIQUE NOT NULL,
password_hash TEXT NOT NULL,
created_at TEXT NOT NULL,
group_id TEXT NOT NULL,
reputation INTEGER DEFAULT 0
);
-- Discussions table
CREATE TABLE discussions (
id TEXT PRIMARY KEY,
title TEXT NOT NULL,
content TEXT NOT NULL,
category_id TEXT NOT NULL,
author_id TEXT NOT NULL,
created_at TEXT NOT NULL,
reply_count INTEGER DEFAULT 0,
view_count INTEGER DEFAULT 0
);Advantages
- Performance - Faster for large datasets
- SQL Queries - Full SQL query support
- Transactions - ACID transactions
- Indexes - Database indexes for speed
- Concurrent Access - Better concurrency
Limitations
- Pro Edition Only - Requires Pro Edition
- Extension Required - Needs
pdo_sqlite - Backup Complexity - Database backup required
- Less Portable - Database file management
Choosing Storage Type
Use JSON When:
- Small to medium community (< 10,000 users)
- Simple setup preferred
- Easy backups needed
- No database experience
- Community Edition
Use SQLite When:
- Medium to large community (> 10,000 users)
- Better performance needed
- Complex queries required
- Pro Edition available
- Database experience
Migration Between Storage Types
Using StorageMigrator Plugin
- Install StorageMigrator plugin
- Go to Admin Panel > Storage Migrator
- Select target storage type
- Review migration preview
- Start migration
- Verify data after migration
Always backup your data before migrating between storage types. Migration cannot be undone.
Manual Migration
For advanced users:
- Backup Current Data - Full backup
- Export Data - Export from current storage
- Import Data - Import to new storage
- Verify - Check all data migrated
- Update Config - Change storage type in config
Storage Optimization
JSON Optimization
- Regular Cleanup - Remove old/unused files
- Archive Old Data - Move old content to archive
- Organize Files - Keep structure organized
- File Permissions - Set correct permissions
SQLite Optimization
-- Vacuum database
VACUUM;
-- Analyze tables
ANALYZE;
-- Reindex
REINDEX;
-- Optimize
PRAGMA optimize;Via Admin Panel:
- Admin Panel > Tools > Database > Optimize
Backup and Restore
JSON Backup
# Backup JSON storage
tar -czf backup-json-$(date +%Y%m%d).tar.gz stockage/json/
# Restore JSON storage
tar -xzf backup-json-20251225.tar.gzSQLite Backup
# Backup SQLite database
sqlite3 stockage/sqlite/flatboard.db ".backup backup.db"
# Restore SQLite database
sqlite3 stockage/sqlite/flatboard.db < backup.sqlAutomated Backups
Set up automated backups:
#!/bin/bash
# Backup script
DATE=$(date +%Y%m%d)
BACKUP_DIR="/backups"
# JSON backup
tar -czf $BACKUP_DIR/json-$DATE.tar.gz stockage/json/
# SQLite backup (if Pro)
if [ -f "stockage/sqlite/flatboard.db" ]; then
sqlite3 stockage/sqlite/flatboard.db ".backup $BACKUP_DIR/sqlite-$DATE.db"
fiStorage Maintenance
Regular Maintenance
- Clean Old Data - Remove old/unused content
- Optimize Storage - Run optimization commands
- Check Disk Space - Monitor available space
- Verify Integrity - Check data integrity
Cleanup Commands
# Clean old cache
php app/Cli/console.php cleanup:cache
# Clean empty discussions
php app/Cli/console.php cleanup:empty-discussions
# Clean old storage
php app/Cli/console.php cleanup:storageTroubleshooting
Storage Issues
JSON:
- Check file permissions
- Verify disk space
- Check for file locks
- Review error logs
SQLite:
- Check database file permissions
- Verify
pdo_sqliteextension - Check database integrity
- Review error logs
Performance Issues
JSON:
- Consider migrating to SQLite
- Optimize file structure
- Archive old data
- Increase server resources
SQLite:
- Add indexes
- Optimize queries
- Vacuum database
- Consider JSON for small sites
Best Practices
General
- Regular Backups - Backup storage regularly
- Monitor Space - Watch disk usage
- Optimize Regularly - Run optimization
- Test Restores - Test backup restoration
JSON Specific
- Organize Files - Keep structure clean
- Archive Old Data - Move old content
- Set Permissions - Correct file permissions
- Monitor Performance - Watch for slowdowns
SQLite Specific
- Regular VACUUM - Vacuum database regularly
- Use Indexes - Add indexes for queries
- Optimize Queries - Write efficient queries
- Monitor Size - Watch database growth
Resources
- Configuration Guide - Storage configuration
- Performance Guide - Storage optimization
- Backup Guide - Backup and restore
- Troubleshooting - Storage issues
Last updated: February 23, 2026