Skip to content

Commit

Permalink
chore: code review findings
Browse files Browse the repository at this point in the history
  • Loading branch information
timonmasberg committed Apr 14, 2023
1 parent b7f42af commit a36ef5e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions tools/db/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ running on your maschine.

### Test Data

The data for the test database is within the `data` folder. If you want to
create a new collection, use the `template.ts` as a starter for your file. The
naming of the file should be `<collection name>.data.ts`.
The data for the test database is within the [`data`](./data/) folder. If you
want to create a new collection, use the `template.ts` as a starter for your
file. The naming of the file should be `<collection name>.data.ts`.
Please adjust the test data in your branch if you introduce migrations!

### Start

Every script checks whether you have a MongoDB container up and running. If not
it will pull and start the mongo image at port `27017`.
it will pull and start the Mongo image at port `27017`.

**Starting a local dev database for development or for testing/e2es:**
`./kordis-db.sh init <database name>`
This will bootstrap the a database with the given name and the test data. Make
This will bootstrap the database with the given name and the test data. Make
sure that the database does not exist, otherwise it will just push the data into
the existing database! A MongoDB connection uri will be emitted by the script.
You can use it for local development.
Expand All @@ -35,6 +35,6 @@ uri will be emitted by the script. You can use it for local development.
If necessary, you can introduce migration scripts that will directly modify the
database. We use the Node Package
[Mongo Migrate](https://www.npmjs.com/package/mongo-migrate-ts). You can create
new migrations scripts by running
new migration scripts by running
`./kordis-db.sh new-migration <optional name of migration>`, keep in mind to
only introduce a single migration script per change request into `main`.
4 changes: 2 additions & 2 deletions tools/db/kordis-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ensure_clean_db() {
db_exists=$(docker exec $MONGO_CONTAINER_NAME mongo --quiet --eval "db.getMongo().getDBNames().indexOf('$db_name') > -1")

if [[ $db_exists == "true" ]]; then
read -p "A Database with that Name already exists. If you don't delete the DB, the data will simple be inserted on top of existing data! Do you want to delete the database '$db_name'? (y/n): " confirmation
read -p "A Database with that Name already exists. If you don't delete the DB, the data will simply be inserted on top of existing data! Do you want to delete the database '$db_name'? (y/n): " confirmation

if [[ $confirmation == "y" || $confirmation == "Y" ]]; then
docker exec $MONGO_CONTAINER_NAME mongo --quiet --eval "db.getSiblingDB('$db_name').dropDatabase()"
Expand Down Expand Up @@ -67,7 +67,7 @@ from_remote() {
fi

if [ -z "$2" ]; then
echo "Error: You have to provide the connection uri for the remote dev db!"
echo "Error: You have to provide a DB name!"
exit 1
fi

Expand Down

0 comments on commit a36ef5e

Please sign in to comment.