SciCatProject / SciCatProject/backend

Migrations: script uses dotenv which does not pick up environment variables

Open
#724 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
27
Forks
37
Avg merge
17h 32m
Merged PRs (30d)
38

Description

The migrations script uses the dotenv package to pickup the MONGODB_URI. It turns out that this package cannot handle the case where there is no .env file. The equivilent python package will go to actual environment variables and if one is over-ridden by a value in a .env, that will be used.

https://github.com/SciCatProject/scicat-backend-next/blob/c6b2407bddf31fa501057006b4ed4fd343767fb5/migrate-mongo-config.js#L4

This comes up because I'm trying to do a migration right within my container, which defines MONGODB_URI as an environment variable and has no .env file. It would be nice to update this script to look at system environment for this variable too.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with migrate-mongo-config.js at the linked dotenv usage and check how MONGODB_URI is loaded when no .env file exists. Verify the migration script in a container with MONGODB_URI set only as an environment variable; done means that value is used while a .env value can still override it.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mongodb
Domain
databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.