commit | 16b593b496eac556b7b38c81a631f18b8012dbbc | [log] [tgz] |
---|---|---|
author | Rob Findley <rfindley@google.com> | Tue Apr 16 17:40:24 2019 -0400 |
committer | Julie Qiu <julie@golang.org> | Fri Mar 27 16:46:35 2020 -0400 |
tree | 3c1f059d28c7ef025f86a4559efed541b320eaef | |
parent | 701b01e3fa3e636370f1f4c168d133dbbbd7ab36 [diff] |
internal/postgres: replace grpc.Status usage with derrors package Eliminate usage of grpc.Status (which was just being used to communicate InvalidArgument), by replacing it with the newly added derrors package. Tests that were relying on grpc status codes for error assertions had to be updated as well. I went through a few iterations of how to do this, and settled on a simple enumeration of errors to be used for testing only (in test_helper.go). Also add documentation for postgres.DB and postgres.Open to make golint happy. Fixes b/128540225 Change-Id: Ie0b90211ae8d7d45daf980c1cc2701aabd4b9019 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/450158 Reviewed-by: Julie Qiu <julieqiu@google.com>
Migrations are managed with the golang-migrate/migrate CLI tool.
To run all the migrations:
migrate -source file:migrations -database "postgres://localhost:5432/discovery-database?sslmode=disable" up
To create a new migration:
migrate create -ext sql -dir migrations -seq <title>
This creates two empty files in /migrations
:
{version}_{title}.up.sql {version}_{title}.down.sql
The two migration files are used to migrate “up” to the specified version from the previous version, and to migrate “down” to the previous version. See golang-migrate/migrate/MIGRATIONS.md for details.