commit | 2dd4be5f74beb684932fa9bcb6e612f9b9b99b5d | [log] [tgz] |
---|---|---|
author | Rob Findley <rfindley@google.com> | Tue May 14 16:24:39 2019 -0400 |
committer | Julie Qiu <julie@golang.org> | Fri Mar 27 16:46:37 2020 -0400 |
tree | 196214b3a1f38288ec8ffa00bd808e2d4fb573b3 | |
parent | 84d44616b222ca191afb5af3d286a4db8e6ddbd6 [diff] |
internal/proxy,internal/postgres: overwrite versions on fetch This CL modifies postgres.InsertVersion overwrite version data, rather than defaulting to ON CONFLICT DO NOTHING. This is achieved by first deleting any existing version within the transaction, which will cascade to all version data. Testing this was a bit difficult due to the way the fake proxy is implemented. In order to make this easier and facilitate easier testing down the road, the fake proxy was modified to dynamically generate its endpoints based on version information, allowing for the serving of purely in-memory versions. Since some common patterns are emerging in our tests, add an internal/testhelper package. Fixes b/132710180 Change-Id: I91137335d58c133d9de06ffe88e66b1f7846aa44 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/466417 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.