From 0ec166dd5c674918bebb8d9c2992662803df0681 Mon Sep 17 00:00:00 2001 From: Luis Borjas Reyes Date: Sat, 30 Jan 2021 17:28:28 -0500 Subject: [PATCH] update dockerfile to include migrations dir Also, mention it in the README --- Dockerfile | 1 + README.md | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/Dockerfile b/Dockerfile index 16a1d0e..3958380 100644 --- a/Dockerfile +++ b/Dockerfile @@ -70,6 +70,7 @@ RUN apt-get update && apt-get install -y libpq-dev postgresql-client-12 RUN adduser geocode-city-api USER geocode-city-api +COPY --from=build /opt/geocode-city-api/migrations /opt/geocode-city-api/migrations COPY --from=build /opt/geocode-city-api/bin /opt/geocode-city-api WORKDIR /opt/geocode-city-api diff --git a/README.md b/README.md index ff57b2d..d9961e1 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,31 @@ is that for the hyperloglog entries to "fall off" as we reach max memory, I'm us heroku redis:maxmemory REDIS-NAME --policy allkeys-lru -a geocode-city ``` +#### Database migrations (Heroku specific) + +I _should_ set up a [`release` phase](https://devcenter.heroku.com/articles/container-registry-and-runtime#release-phase) to [run migrations automatically](https://devcenter.heroku.com/articles/release-phase). However, I'd rather not have that overhead for something that +happens somewhat seldom, so I instead use a [one-off dyno](https://devcenter.heroku.com/articles/container-registry-and-runtime#one-off-dynos): + +```sh +> heroku run bash -a geocode-city +Running bash on ⬢ geocode-city... up, run.7528 (Hobby) +~ $ pwd +/opt/geocode-city-api +~ $ ls +geocode-city-api-exe migrations +~ $ ./geocode-city-api-exe --migrate +Initializing schema +NOTICE: relation "schema_migrations" already exists, skipping +Ok: 202101182025_geonames_raw.sql +Ok: 202101182130_non_city_tables.sql +Ok: 202101182140_city_table.sql +Ok: 202101182150_ft_and_indexes.sql +Ok: 202101191900_api_keys_table.sql +Ok: 202101201800_materialize_autocomplete.sql +Ok: 202101231600_api_quotas.sql +Execute: 202101301530_full_text_autocomplete.sql +All migrations ran. +``` ## Development