Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions migrate-mongo-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require('dotenv').config();

const {
MONGO_USERNAME,
MONGO_PASSWORD,
MONGO_HOST,
MONGO_PORT,
MONGO_DB_NAME
} = process.env;

const url = `mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@${MONGO_HOST}:${MONGO_PORT}/?replicaSet=rs0`;

const config = {
mongodb: {
url: url,
databaseName: MONGO_DB_NAME,
options: {
}
},
migrationsDir: "src/database/migrations",
Comment thread
CapoMK25 marked this conversation as resolved.
Outdated
changelogCollectionName: "migrations_changelog",
migrationFileExtension: ".js",
useFileHash: false,
moduleSystem: 'esm',
};

module.exports = config;
15 changes: 15 additions & 0 deletions migration-template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* @param db {import('mongodb').Db}
* @param client {import('mongodb').MongoClient}
*/
export const up = async (db, client) => {
// TODO: Write your migration logic here when applicable
};

/**
* @param db {import('mongodb').Db}
* @param client {import('mongodb').MongoClient}
*/
export const down = async (db, client) => {
// TODO: Write your rollback logic here when applicable
};
62 changes: 54 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
"test:watch": "jest --watch",
"test:quiet": "DOTENV_CONFIG_QUIET=true jest",
"sonar:analize": "docker compose -f sonar_docker-compose.yml up -d && sonar-scanner \\\n -Dsonar.projectKey=AltzoneLocal \\\n -Dsonar.sources=. \\\n -Dsonar.host.url=http://localhost:9000 \\\n -Dsonar.login=sqp_d0d523f9a2cf5e1e8f7587e0da315df0adc86568 \\\n && echo \"Remember to stop the sonar server with: \\n docker compose -f sonar_docker-compose.yml down\"\n",
"prepare": "husky"
"prepare": "husky",
"migrate:create": "migrate-mongo create",
"migrate:up": "migrate-mongo up",
"migrate:down": "migrate-mongo down",
"migrate:status": "migrate-mongo status"
},
"keywords": [],
"author": "",
Expand Down Expand Up @@ -47,6 +51,7 @@
"ioredis": "5.8.2",
"jsonwebtoken": "^9.0.2",
"lodash": "4.17.21",
"migrate-mongo": "^14.0.7",
"mongodb": "6.20.0",
"mongoose": "8.19.4",
"mqtt": "5.14.1",
Expand Down Expand Up @@ -81,4 +86,4 @@
"typescript": "5.9.3",
"typescript-eslint": "8.46.4"
}
}
}
1 change: 1 addition & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const authGuardClassToUse = isTestingSession() ? BoxAuthGuard : AuthGuard;
return {
uri: mongoString,
dbName,
autoIndex: false,
Comment thread
CapoMK25 marked this conversation as resolved.
Outdated
};
},
}),
Expand Down
Empty file.