Example of managing PostgreSQL in a VSCode project.
- This project is to show you how to run a local development environment across teams that leverage PostgreSQL as the database. While developing and testing software you will need to ensure that databases share a common schema, and can require data to be loaded so that other developers can test software correctly.
- This is a container based solution that allows you not add additional dependancies on a developers machine.
- This example comes with pgAdmin so that engineers can view the database and the data for understanding and debugging.
-
./.devcontainer/
.env
: File that has the configuration for the docker containersdevcontainer.json
: VSCode devcontainer json file which sets up the environment, you will find the docker-compose file, a post startup command which does the 'liquibase update' and the ports that are exposeddocker-compose.yml
: The Docker compose file that loads up all required containers.
-
./.db/
liquibase.properties
: Contains the credentials that liquibase uses to update the schemamydatabase.xml
: controls the revision list, and order to apply schema changeschangelog-***.xml
: change log files that manage individual revisions to the database schemadefault-insert-for-admin_config.sql
: Data file that is loaded in change-log-5.0.xml; which is related to that specific change
-
./Dockerfile
: Container that VSCode runs in, this is the terminal with liquibase as a tool.
- Open VSCode
- Open project in container
- dialog box should show in bottom right corner
- Or View > Command Palette... > Dev Containers: Reopen in Container
- pgAdmin: to view the data in the database.
- Username:
dude@secret.io
- Password:
supersecret
- Username:
- pgAdmin register database:
- Host Name:
postgres
- Database:
mydatabase
- Username:
nottheadmin
- Password:
metadata
- Host Name:
- liquibase VSCode terminal: to update database schema via Liquibase
- Credentials:
./.devcontainer/.env
- Liquibase Properties:
./db/liquibase.properties
(credentials must match.env
)
If you change credentials and they aren't working:
docker volume rm $[docker volume ls -q --filter dangling=true]