This document describes the MongoDB version management system that automatically detects MongoDB server versions and switches to the appropriate binary and Node.js driver.
The system provides:
/snap/wekan/current/migratemongo/bin/
/snap/wekan/current/bin/
mongodb3legacy
mongodb4legacy
mongodb5legacy
mongodb6legacy
mongodb7legacy
mongodb8legacy
The system attempts to connect to MongoDB using the latest available binary (MongoDB 7.x) and analyzes the response:
Based on the detected version, the system switches to the appropriate MongoDB server binary:
# MongoDB 3.x
export PATH="/snap/wekan/current/migratemongo/bin:$PATH"
export LD_LIBRARY_PATH="/snap/wekan/current/migratemongo/lib:$LD_LIBRARY_PATH"
# MongoDB 7.x (default)
export PATH="/snap/wekan/current/bin:$PATH"
export LD_LIBRARY_PATH="/snap/wekan/current/usr/lib:$LD_LIBRARY_PATH"
The Node.js application automatically selects the appropriate MongoDB driver based on the detected version using the mongodbDriverManager
system.
snap-src/bin/mongodb-migrate
- Removedsnap-src/bin/mongodb-migration-web
- Removedsnap-src/bin/mongodb-migration-status
- Removedsnap-src/bin/mongodb-control
- Completely rewritten with version detectionsnap-src/bin/mongodb-version-manager
- New utility for managing versionsmodels/lib/mongodbDriverManager.js
- Manages multiple MongoDB driversmodels/lib/mongodbConnectionManager.js
- Handles connections with version detectionmodels/lib/meteorMongoIntegration.js
- Integrates with Meteor's Mongo.Collectionserver/mongodb-driver-startup.js
- Initializes the driver systemTo add MongoDB versions 4, 5, 6, and 8 to the snap package, you need to:
Download the appropriate MongoDB server binaries for each version:
# MongoDB 4.4.28
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.4.28.tgz
# MongoDB 5.0.28
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-5.0.28.tgz
# MongoDB 6.0.15
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-6.0.15.tgz
# MongoDB 8.0.4
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-8.0.4.tgz
Extract each version to the appropriate directory in the snap package:
# Extract MongoDB 4.x
tar -xzf mongodb-linux-x86_64-4.4.28.tgz
mkdir -p /snap/wekan/current/mongodb4/bin
cp mongodb-linux-x86_64-4.4.28/bin/* /snap/wekan/current/mongodb4/bin/
# Extract MongoDB 5.x
tar -xzf mongodb-linux-x86_64-5.0.28.tgz
mkdir -p /snap/wekan/current/mongodb5/bin
cp mongodb-linux-x86_64-5.0.28/bin/* /snap/wekan/current/mongodb5/bin/
# Extract MongoDB 6.x
tar -xzf mongodb-linux-x86_64-6.0.15.tgz
mkdir -p /snap/wekan/current/mongodb6/bin
cp mongodb-linux-x86_64-6.0.15/bin/* /snap/wekan/current/mongodb6/bin/
# Extract MongoDB 8.x
tar -xzf mongodb-linux-x86_64-8.0.4.tgz
mkdir -p /snap/wekan/current/mongodb8/bin
cp mongodb-linux-x86_64-8.0.4/bin/* /snap/wekan/current/mongodb8/bin/
Modify the snap package build process to include these binaries in the final package.
$SNAP/bin/mongodb-version-manager versions
$SNAP/bin/mongodb-version-manager active
$SNAP/bin/mongodb-version-manager detect
$SNAP/bin/mongodb-version-manager log
MONGO_URL
- MongoDB connection URL (default: mongodb://127.0.0.1:27017/wekan
)SNAP_COMMON
- Snap common directory for logs and version files${SNAP_COMMON}/mongodb-active-version
- Caches the currently active version${SNAP_COMMON}/mongodb-version-detection.log
- Logs version detection events$SNAP/bin/mongodb-version-manager log
$SNAP/bin/mongodb-version-manager detect
rm ${SNAP_COMMON}/mongodb-active-version