// migrate-mongo-config.js require('dotenv').config(); // In this file you can configure migrate-mongo
const config = { mongodb: { // TODO Change (or review) the url to your MongoDB: url: process.env.NEXT _PUBLIC_DB_URL,
// TODO Change this to your database name: databaseName: process.env.NEXT _PUBLIC_DB_NAME,
options: { // ssl: true, // sslValidate: true, // useNewUrlParser: false, // removes a deprecation warning when connecting // useUnifiedTopology: false, // removes a deprecating warning when connecting // connectTimeoutMS: 3600000, // increase connection timeout to 1 hour // socketTimeoutMS: 3600000, // increase socket timeout to 1 hour } },
// The migrations dir, can be an relative or absolute path. Only edit this when really necessary. migrationsDir: "migrations",
// The mongodb collection where the applied changes are stored. Only edit this when really necessary. changelogCollectionName: "changelog",
// The file extension to create migrations and search for in migration dir migrationFileExtension: ".js",
// Enable the algorithm to create a checksum of the file contents and use that in the comparison to determine // if the file should be run. Requires that scripts are coded to be run multiple times. useFileHash: false,
// Don't change this, unless you know what you're doing moduleSystem: 'commonjs', };
Ошибка - $ migrate-mongo up ERROR: 44330000:error:0A000438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error:c:\ws\deps\openssl\openssl\ssl\record\rec_layer_s3.c:1590:SSL alert number 80 MongoServerSelectionError: 44330000:error:0A000438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error:c:\ws\deps\openssl\openssl\ssl\record\rec_layer_s3.c:1590:SSL alert number 80
at Topology.selectServer (C:\Users\Admin\AppData\Roaming\npm\node_modules\migrate-mongo\node_modules\mongodb\lib\sdam\topology.js:303:38) at async Topology._connect (C:\Users\Admin\AppData\Roaming\npm\node_modules\migrate-mongo\node_modules\mongodb\lib\sdam\topology.js:196:28) at async Topology.connect (C:\Users\Admin\AppData\Roaming\npm\node_modules\migrate-mongo\node_modules\mongodb\lib\sdam\topology.js:158:13) at async topologyConnect (C:\Users\Admin\AppData\Roaming\npm\node_modules\migrate-mongo\node_modules\mongodb\lib\mongo_client.js:204:17) at async MongoClient._connect (C:\Users\Admin\AppData\Roaming\npm\node_modules\migrate-mongo\node_modules\mongodb\lib\mongo_client.js:217:13) at async MongoClient.connect (C:\Users\Admin\AppData\Roaming\npm\node_modules\migrate-mongo\node_modules\mongodb\lib\mongo_client.js:142:13) at async MongoClient.connect (C:\Users\Admin\AppData\Roaming\npm\node_modules\migrate-mongo\node_modules\mongodb\lib\mongo_client.js:295:16) at async Object.connect (C:\Users\Admin\AppData\Roaming\npm\node_modules\migrate-mongo\lib\env\database.js:16:20)
require('dotenv').config();
// In this file you can configure migrate-mongo
const config = {
mongodb: {
// TODO Change (or review) the url to your MongoDB:
url: process.env.NEXT _PUBLIC_DB_URL,
// TODO Change this to your database name:
databaseName: process.env.NEXT _PUBLIC_DB_NAME,
options: {
// ssl: true,
// sslValidate: true,
// useNewUrlParser: false, // removes a deprecation warning when connecting
// useUnifiedTopology: false, // removes a deprecating warning when connecting
// connectTimeoutMS: 3600000, // increase connection timeout to 1 hour
// socketTimeoutMS: 3600000, // increase socket timeout to 1 hour
}
},
// The migrations dir, can be an relative or absolute path. Only edit this when really necessary.
migrationsDir: "migrations",
// The mongodb collection where the applied changes are stored. Only edit this when really necessary.
changelogCollectionName: "changelog",
// The file extension to create migrations and search for in migration dir
migrationFileExtension: ".js",
// Enable the algorithm to create a checksum of the file contents and use that in the comparison to determine
// if the file should be run. Requires that scripts are coded to be run multiple times.
useFileHash: false,
// Don't change this, unless you know what you're doing
moduleSystem: 'commonjs',
};
module.exports = config;
// папка migrations > 20240612103445-cloth.js
const { Faker } = require('@fakerjs/faker');
module.exports = {
async up(db, client) {
return db.collection('cloth').insertMany([{ test: 'test' }]);
},
async down(db) {
return db.collection('cloth').deleteMany({});
},
};
Ошибка -
$ migrate-mongo up
ERROR: 44330000:error:0A000438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error:c:\ws\deps\openssl\openssl\ssl\record\rec_layer_s3.c:1590:SSL alert number 80
MongoServerSelectionError: 44330000:error:0A000438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error:c:\ws\deps\openssl\openssl\ssl\record\rec_layer_s3.c:1590:SSL alert number 80
at Topology.selectServer (C:\Users\Admin\AppData\Roaming\npm\node_modules\migrate-mongo\node_modules\mongodb\lib\sdam\topology.js:303:38)
at async Topology._connect (C:\Users\Admin\AppData\Roaming\npm\node_modules\migrate-mongo\node_modules\mongodb\lib\sdam\topology.js:196:28)
at async Topology.connect (C:\Users\Admin\AppData\Roaming\npm\node_modules\migrate-mongo\node_modules\mongodb\lib\sdam\topology.js:158:13)
at async topologyConnect (C:\Users\Admin\AppData\Roaming\npm\node_modules\migrate-mongo\node_modules\mongodb\lib\mongo_client.js:204:17)
at async MongoClient._connect (C:\Users\Admin\AppData\Roaming\npm\node_modules\migrate-mongo\node_modules\mongodb\lib\mongo_client.js:217:13)
at async MongoClient.connect (C:\Users\Admin\AppData\Roaming\npm\node_modules\migrate-mongo\node_modules\mongodb\lib\mongo_client.js:142:13)
at async MongoClient.connect (C:\Users\Admin\AppData\Roaming\npm\node_modules\migrate-mongo\node_modules\mongodb\lib\mongo_client.js:295:16)
at async Object.connect (C:\Users\Admin\AppData\Roaming\npm\node_modules\migrate-mongo\lib\env\database.js:16:20)