Repository navigation
Database
eldor edited this page Nov 17, 2025
·
3 revisions
Guide to managing the ChestLockLite SQLite database.
plugins/ChestLockLite/locks.db
Stores all container lock information.
| Column | Type | Description |
|---|---|---|
| id | INTEGER | Primary key |
| world | TEXT | World name |
| x | INTEGER | X coordinate |
| y | INTEGER | Y coordinate |
| z | INTEGER | Z coordinate |
| owner_uuid | TEXT | Owner UUID |
| owner_name | TEXT | Owner name |
| password | TEXT | Password hash (salt:hash) |
| hopper_enabled | INTEGER | Hopper access enabled (1) or disabled (0) - v1.1.0+ |
| created_at | TIMESTAMP | Lock creation time |
Note: The hopper_enabled column was added in v1.1.0. Existing databases are automatically migrated on upgrade.
Stores trusted player relationships.
| Column | Type | Description |
|---|---|---|
| id | INTEGER | Primary key |
| world | TEXT | World name |
| x | INTEGER | X coordinate |
| y | INTEGER | Y coordinate |
| z | INTEGER | Z coordinate |
| trusted_uuid | TEXT | Trusted player UUID |
| trusted_name | TEXT | Trusted player name |
| created_at | TIMESTAMP | Trust creation time |
-
idx_locks_locationonchest_locks(world, x, y, z) -
idx_trusted_locationontrusted_players(world, x, y, z)
Configure in config.yml:
database:
backup-interval: 24 # hoursBackups are stored as:
plugins/ChestLockLite/backups/locks_YYYY-MM-DD_HH-MM-SS.db
- Stop your server
- Copy
locks.dbto a safe location - Restore by replacing the file and restarting
Use SQLite browser tools:
- DB Browser for SQLite (free)
- SQLiteStudio (free)
- Command line:
sqlite3 locks.db
-- All locks
SELECT * FROM chest_locks;
-- Locks by player
SELECT * FROM chest_locks WHERE owner_name = 'PlayerName';
-- Locks in world
SELECT * FROM chest_locks WHERE world = 'world';-- All trusted relationships
SELECT * FROM trusted_players;
-- Trusted players for a chest
SELECT * FROM trusted_players
WHERE world = 'world' AND x = 100 AND y = 64 AND z = 200;To optimize database size:
VACUUM;To rebuild indexes:
REINDEX;To update query planner statistics:
ANALYZE;Locks that reference non-existent chests (manual cleanup):
-- This requires custom verification - be careful!
-- Verify chests exist before deletingSELECT world, x, y, z, COUNT(*)
FROM chest_locks
GROUP BY world, x, y, z
HAVING COUNT(*) > 1;SELECT owner_name, COUNT(*) as lock_count
FROM chest_locks
GROUP BY owner_name
ORDER BY lock_count DESC;-
Regular Vacuum: Run
VACUUMmonthly - Index Usage: Indexes are auto-created and maintained
- Query Efficiency: Use indexed columns (world, x, y, z) in WHERE clauses
- Backup Strategy: Regular backups prevent data loss
- Typical lock record: ~200 bytes
- Typical trusted record: ~150 bytes
- 10,000 locks ≈ 2MB database size
- Efficient for thousands of locks
- Database file > 50MB
- Slow query performance
- After bulk deletions
- Monthly maintenance
The database schema is versioned and auto-migrates on plugin startup. Always backup before upgrading.
When upgrading to v1.1.0:
- The
hopper_enabledcolumn is automatically added tochest_lockstable - All existing locks default to
hopper_enabled = 1(enabled) - Migration runs automatically on plugin startup
- Check console for migration confirmation messages
# Export to SQL
sqlite3 locks.db .dump > backup.sql
# Export to CSV
sqlite3 -header -csv locks.db "SELECT * FROM chest_locks;" > locks.csv# Import from SQL
sqlite3 locks.db < backup.sqlDatabase locked error?
- Make sure server is stopped
- Close all SQLite browsers/tools
- Check for .db-shm and .db-wal files (SQLite WAL mode)
Corrupted database?
- Restore from backup
- Use SQLite's integrity check:
PRAGMA integrity_check; - May need to export data and recreate database
Performance issues?
- Run
VACUUM - Check index usage with
EXPLAIN QUERY PLAN - Verify indexes exist:
.indexes
Missing locks?
- Check database file exists
- Verify file permissions
- Check server logs for errors
- Restore from backup if needed
- Set appropriate file permissions on database file
- Restrict access to server admins only
- Protect backup files as well
- Passwords are hashed (SHA-256 + salt)
- Cannot be recovered from database
- Salt prevents rainbow table attacks
- Encrypt backups if sensitive
- Store backups securely
- Regular backup rotation
The database uses standard SQLite format. You can write custom queries for:
- Analytics
- Reporting
- Bulk operations
- Data export
Database can be accessed by:
- Other plugins (via API)
- External tools
- Reporting systems
- Backup systems