brew install modd
go get
We use go-migrate
to create and run migrations.
modd
to run the main.go and run gin server
To create a new migration, run:
migrate create -ext sql -dir db/migrations -seq create_users_table
export CONNECTION_STRING="-source file://db/migrations -database 'postgres://localhost:5432/lantern-go?sslmode=disable'"
alias mu="migrate $CONNECTION_STRING up"
alias md="migrate $CONNECTION_STRING down"
alias mdd="migrate $CONNECTION_STRING drop -f"
- Queries must be run in order, since most tables "hang off" the
People
table - To alter the amount of records, go into the corresponding
_test.go
file inseed/
and alter theModelCount
variable before running below.
go test -run TestSeedPeople ./seed
go test -run TestSeedNotes ./seed
go test -run TestSeedPressurePoints ./seed
- Duplicate the .env.example file and create a database with the corresponding values in postgres
- Ensure that environment variable
LANTERN_ENV
is configured asdevelopment
for dev andproduction
for production.- For local dev, you can do this via a
.zshrc
export:export LANTERN_ENV=production
- For DigitalOcean Apps, through the Web UI
- For local dev, you can do this via a
lantern-go
will loadLANTERN_ENV
and:- if
development
, will load using.env
- if
production
, will load using standard os.Getenv without an.env
- if
This is a big to-do, but for now: we will not need to run multiple migrations - just go onto the DigitalOcean Web UI to get the PostgreSQL's component's login information - connect manually or using TablePlus/similar, and run the SQL.up migration SQL file that we have in db/migrations
.