-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Development Database | ||
|
||
If you are running the Django development server or the unit tests then you will need to run a database. | ||
|
||
## Prerequisites for running this database | ||
|
||
1. Install Docker | ||
2. Install Docker-compose | ||
|
||
## How about I just install postgres on my operating system? | ||
|
||
You can do that if you really want to BUT then you are on your own when you break it. | ||
|
||
Docker is nice because absolutely everything you need to run a properly configured database is in this directory. And if you break it or want a clean system then resetting the db is trivial. | ||
|
||
## Commands | ||
|
||
To run the db: | ||
|
||
``` | ||
docker-compose up | ||
``` | ||
|
||
To reset your development databases so that they are fresh and clean: | ||
|
||
``` | ||
./cleanup_devdb.sh | ||
docker-compose up | ||
``` | ||
|
||
## Interacting with the databases via django | ||
|
||
Once your composition is up and running: | ||
|
||
``` | ||
python manage.py [any command that interacts with the database] | ||
``` | ||
|
||
This just works. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
docker exec -it dev_db_dbs_1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
|
||
docker kill dev_db_dbs_1 | ||
docker rm dev_db_dbs_1 | ||
sudo rm -r ./gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
services: | ||
postgres: | ||
image: postgres:12 | ||
environment: | ||
- POSTGRES_USER=pguser | ||
- POSTGRES_PASSWORD=password | ||
- POSTGRES_DB=db | ||
volumes: | ||
- ./gitignore/postgresql:/var/lib/postgresql/data | ||
- ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d | ||
ports: | ||
- "6543:5432" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CREATE DATABASE test_db; | ||
grant all privileges on database test_db to pguser; | ||
-- ALTER USER user WITH SUPERUSER; |