Skip to content

Commit

Permalink
print db schema
Browse files Browse the repository at this point in the history
  • Loading branch information
calufa committed Feb 10, 2022
1 parent 3d2e20a commit 76f790e
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 277 deletions.
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

0 comments on commit 76f790e

Please sign in to comment.