Skip to content
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

Print DB schema #83

Open
wants to merge 1 commit into
base: feature/add-unit-test-suite
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ For tests written in `go`, you can add the name of the test that you want to run
./test.sh scribble TestCreateUserReturnsSuccess
```

### Printing the DB schema

For convenience, we include a script that prints the DB schema.

To print the DB schema, run `./db-schema.sh` in your terminal. Once executed, you should see the table schemas printed on your screen.

### Testing inside Kubernetes

Make sure you have KIND installed.
Expand Down
11 changes: 11 additions & 0 deletions db-schema.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FILE_PATH="system/db-schema.yaml"

function cleanup {
docker-compose -f ${FILE_PATH} down --remove-orphans
}

trap cleanup EXIT
cleanup

docker-compose -f ${FILE_PATH} build main
docker-compose -f ${FILE_PATH} run main
277 changes: 0 additions & 277 deletions devops/all.sql

This file was deleted.

30 changes: 30 additions & 0 deletions system/db-schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: '3'

services:
main:
image: cockroachdb/cockroach:v20.1.4
depends_on:
- cockroachdb
entrypoint: |
sh -c '
/tools/wait-for-it.sh cockroachdb:26257 -t 60
cat /migrations/* > /tmp/merged-latest.sql
cat /tmp/merged-latest.sql | ./cockroach sql --insecure --host cockroachdb
./cockroach dump chatroach --insecure --host cockroachdb --dump-mode=schema
'
volumes:
- ../devops:/tools
- ../devops/sql:/migrations
networks:
- fly
cockroachdb:
image: cockroachdb/cockroach:v20.1.4
command: start --insecure
ports:
- 26257:26257
networks:
- fly

networks:
fly:
driver: bridge