brew install moddgo 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_tableexport 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
Peopletable - To alter the amount of records, go into the corresponding
_test.gofile inseed/and alter theModelCountvariable 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_ENVis configured asdevelopmentfor dev andproductionfor production.- For local dev, you can do this via a
.zshrcexport:export LANTERN_ENV=production - For DigitalOcean Apps, through the Web UI
- For local dev, you can do this via a
lantern-gowill loadLANTERN_ENVand:- 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.