db

command module
v0.0.0-...-e463b4a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

README

db

Purpose

This repository hold the database design and migration scripts of TrackMyFish

Running DB migrations

  • Add database connection details to local.env
  • Run migrations with go run main.go
migrate-cli

NOTE: This should only be used for local development purposes.

  • Get current version - migrate -path migrations -database "postgres://trackmyfish:supersecretpassword@localhost:5432/trackmyfish?sslmode=disable" version
  • Apply one down migration (e.g. from version 8 -> 7): migrate -path migrations -database "postgres://trackmyfish:supersecretpassword@localhost:5432/trackmyfish?sslmode=disable" down 1

Logging into the postgres container

Sometimes it's useful to log into the Postgres container, for testing purposes. This can be done with the docker exec -it trackmyfish_db_test psql -U trackmyfish -W trackmyfish command, followed by the specified password (supersecretpassword by default).

It can also be done in one command: docker exec -it trackmyfish_db_test psql postgresql://trackmyfish:supersecretpassword@localhost:5432/trackmyfish

NOTE: This MUST only be done in the development/testing environment only.

Running the Dockerfile

Build the image

docker build -f ./Dockerfile -t trackmyfish_migrations .

Run the image

docker run -e DATABASE_HOST=localhost -e DATABASE_PORT=5432 -e DATABASE_USERNAME=trackmyfish -e DATABASE_PASSWORD=supersecretpassword -e DATABASE_NAME=trackmyfish trackmyfish_migrations

Publish the docker image

docker login

docker tag trackmyfish_migrations simondrake/trackmyfish_migrations:v1alpha1

docker push simondrake/trackmyfish_migrations:v1alpha1

Development

A docker-compose.yaml file has been provided as a convenience, which can be used to run migrations against.

ToDo

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL