OpenRegister supports both PostgreSQL (recommended) and MariaDB/MySQL for maximum flexibility. This document explains how to test both database backends.
PostgreSQL is the recommended database for production use, offering advanced features like vector search (pgvector) and full-text search (pg_trgm).
# Start with PostgreSQL (default)
docker-compose up -d
# Check status
docker-compose ps
# View logs
docker-compose logs -f nextcloudMariaDB/MySQL support is maintained for backward compatibility and environments where PostgreSQL is not available.
# Start with MariaDB
docker-compose --profile mariadb up -d
# Check status
docker-compose --profile mariadb ps
# View logs
docker-compose --profile mariadb logs -f nextcloud-mariadb# Stop and remove all containers
docker-compose down
# Remove volumes (WARNING: This deletes all data!)
docker volume rm openregister_db openregister_nextcloud openregister_config
# Start with MariaDB
docker-compose --profile mariadb up -d# Stop and remove all containers
docker-compose --profile mariadb down
# Remove volumes (WARNING: This deletes all data!)
docker volume rm openregister_db openregister_nextcloud openregister_config
# Start with PostgreSQL
docker-compose up -d# Start PostgreSQL stack
docker-compose up -d
# Wait for Nextcloud to be ready
docker-compose logs -f nextcloud
# Run Newman integration tests
docker exec -u 33 nextcloud newman run \
/var/www/html/custom_apps/openregister/tests/integration/openregister-crud.postman_collection.json \
--env-var "base_url=http://localhost" \
--env-var "admin_user=admin" \
--env-var "admin_password=admin" \
--reporters cli# Start MariaDB stack
docker-compose --profile mariadb up -d
# Wait for Nextcloud to be ready
docker-compose --profile mariadb logs -f nextcloud-mariadb
# Run Newman integration tests
docker exec -u 33 nextcloud newman run \
/var/www/html/custom_apps/openregister/tests/integration/openregister-crud.postman_collection.json \
--env-var "base_url=http://localhost" \
--env-var "admin_user=admin" \
--env-var "admin_password=admin" \
--reporters cli# Access PostgreSQL CLI
docker exec -it openregister-postgres psql -U nextcloud -d nextcloud
# Example queries
\dt # List tables
\d oc_openregister_objects # Describe table
SELECT version(); # PostgreSQL version# Access MariaDB CLI
docker exec -it openregister-mariadb mysql -u nextcloud -p'!ChangeMe!' nextcloud
# Example queries
SHOW TABLES; # List tables
DESCRIBE oc_openregister_objects; # Describe table
SELECT VERSION(); # MariaDB version- Image: pgvector/pgvector:pg16
- Extensions: pg_trgm, vector, btree_gin, btree_gist, uuid-ossp
- Auto-Install: Extensions are automatically installed via
init-extensions.sql - Preload Libraries:
shared_preload_libraries='pg_trgm,vector' - Features: Vector search, full-text search, JSON operations
- Optimizations: Configured for high concurrency and performance
Connection String:
postgresql://nextcloud:!ChangeMe!@localhost:5432/nextcloud
Automatic Extension Setup: The PostgreSQL container automatically installs and enables all required extensions on first startup:
- Extensions are created via
/docker-entrypoint-initdb.d/01-init-extensions.sql - Helper functions are created (
vector_cosine_distance,text_similarity_score) - Database parameters are optimized (similarity threshold, work_mem)
- Preload libraries are configured in docker-compose command section
- Image: mariadb:11.2
- Character Set: utf8mb4_unicode_ci
- Features: Standard SQL, JSON support (basic)
- Optimizations: InnoDB tuning for performance
Connection String:
mysql://nextcloud:!ChangeMe!@localhost:3306/nextcloud
| Feature | PostgreSQL | MariaDB |
|---|---|---|
| Vector Search (pgvector) | ✅ Yes | ❌ No |
| Full-Text Search (native) | ✅ pg_trgm | |
| JSON Operations | ✅ Advanced | |
| Performance | ✅ Excellent | ✅ Good |
| Type Strictness | ✅ Strict (safer) | |
| Production Ready | ✅ Recommended | ✅ Supported |
For CI/CD pipelines, you can test both databases sequentially:
#!/bin/bash
# test-both-databases.sh
echo "=== Testing PostgreSQL ==="
docker-compose up -d
sleep 30 # Wait for initialization
# Run tests...
docker-compose down -v
echo "=== Testing MariaDB ==="
docker-compose --profile mariadb up -d
sleep 30 # Wait for initialization
# Run tests...
docker-compose --profile mariadb down -v# Check PostgreSQL logs
docker logs openregister-postgres
# Check if extensions are loaded
docker exec openregister-postgres psql -U nextcloud -d nextcloud -c "SELECT * FROM pg_extension;"
# Reset PostgreSQL data
docker-compose down
docker volume rm openregister_db
docker-compose up -d# Check MariaDB logs
docker logs openregister-mariadb
# Check character set
docker exec openregister-mariadb mysql -u nextcloud -p'!ChangeMe!' -e "SHOW VARIABLES LIKE 'character_set%';"
# Reset MariaDB data
docker-compose --profile mariadb down
docker volume rm openregister_db
docker-compose --profile mariadb up -dPostgreSQL:
- Strict type checking (strings ≠ integers)
- Explicit casting required for type mismatches
- JSON columns have specific operators
MariaDB:
- Permissive type coercion (strings can be compared to integers)
- Implicit type conversion in most cases
- JSON stored as TEXT internally
PostgreSQL:
TO_CHAR(date, format)for formattingDATE_TRUNC()for truncation- Timezone-aware types
MariaDB:
DATE_FORMAT(date, format)for formattingDATE(),MONTH(), etc. for extraction- Timezone support limited
PostgreSQL:
- Native boolean type
- TRUE/FALSE literals
MariaDB:
- Stored as TINYINT(1)
- 1/0 values
- Always test with PostgreSQL in development - It catches more type errors early
- Run integration tests on both databases before releases
- Use database-agnostic code - Check platform and use appropriate SQL
- Document database-specific features - If using pgvector, document MariaDB limitations
- Monitor query performance on both platforms - Optimize for the most restrictive