-
Notifications
You must be signed in to change notification settings - Fork 2
Configured migrate-mongo as the DB migrations tool #786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
c0796b9
f7e1f07
8a5f374
1e758b4
01b6fb1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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", | ||
| changelogCollectionName: "migrations_changelog", | ||
| migrationFileExtension: ".js", | ||
| useFileHash: false, | ||
| moduleSystem: 'esm', | ||
| }; | ||
|
|
||
| module.exports = config; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those arrow functions were not accomplished?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The arrow functions here were meant to be just initial placeholders. I wrote/generated custom template tests on these previously when testing out the migration in practice, but decided to leave the template file as-is for this actual PR since the migrations would very rarely be applicable to a "one-size fits all" approach, and would need to be adjusted during each migration here on this template. But like I said, this is just a placeholder template for now and the final approach is still up for debate of course. |
| 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 | ||
| }; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The migration files could be in
/databaseinstead ofsrc/as @hoan301298 pointed out.