From 67767045600f7867399cdae259d00d9a2d1a7a88 Mon Sep 17 00:00:00 2001 From: Earlopain Date: Wed, 1 Mar 2023 20:31:49 +0100 Subject: [PATCH] [DB] Upgrade to postgres 15 Execute the following commands, before pulling: docker-compose up -d docker-compose exec postgres pg_dump danbooru2 -U danbooru > backup.sql docker-compose down docker volume rm e621ng_db_data Execute the following commands, after pulling: docker-compose up -d docker-compose exec -T postgres psql -d e621_development -U e621 < backup.sql This also changes the name of the database and role. Now seems like a nice opportunity to do so. --- Dockerfile | 4 ++-- README.md | 2 +- config/database.yml | 8 +++----- docker-compose.yml | 5 +++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index e3c4a67cd..5b8b085d6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM ruby:3.1.3-alpine3.17 as ruby-builder -RUN apk --no-cache add build-base git glib-dev postgresql12-dev +RUN apk --no-cache add build-base git glib-dev postgresql15-dev COPY Gemfile Gemfile.lock ./ RUN gem i bundler:2.3.12 foreman && BUNDLE_IGNORE_CONFIG=true bundle install -j$(nproc) \ @@ -22,7 +22,7 @@ RUN corepack enable && corepack prepare --activate && yarn install FROM ruby:3.1.3-alpine3.17 RUN apk --no-cache add ffmpeg vips \ - postgresql12-client \ + postgresql15-client \ git jemalloc tzdata WORKDIR /app diff --git a/README.md b/README.md index f926126f9..f5f75a3b6 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Try this: `docker compose run --rm rubocop` to run the linter. You will see a truckload of violations but CI will ignore these. -The postgres server accepts outside connections which you can use to access it with a local client. Use `localhost:34517` to connect to a database named `danbooru2` with the user `danbooru`. Leave the password blank, anything will work. +The postgres server accepts outside connections which you can use to access it with a local client. Use `localhost:34517` to connect to a database named `e621_development` with the user `e621`. Leave the password blank, anything will work. ## Production Setup diff --git a/config/database.yml b/config/database.yml index 37fbc54a9..f4f796966 100755 --- a/config/database.yml +++ b/config/database.yml @@ -1,18 +1,17 @@ default: &default adapter: postgresql timeout: 5000 + username: e621 development: <<: *default - database: danbooru2 - username: danbooru + database: e621_development host: postgres pool: 5 test: <<: *default - database: danbooru2_test - username: danbooru + database: e621_test host: postgres pool: 5 @@ -20,7 +19,6 @@ test: production: <<: *default database: e621 - username: e621 password: <%= ENV.fetch("DB_PASSWORD") %> host: <%= ENV.fetch("DB_HOST") %> pool: <%= Sidekiq.server? ? ENV.fetch("DB_WORKER_POOL_SIZE") : ENV.fetch("DB_POOL_SIZE") %> diff --git a/docker-compose.yml b/docker-compose.yml index f98ad8faa..1268793da 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -58,9 +58,10 @@ services: - "3000:3000" postgres: - image: postgres:12-alpine + image: postgres:15-alpine environment: - - POSTGRES_USER=danbooru + - POSTGRES_USER=e621 + - POSTGRES_DB=e621_development - POSTGRES_HOST_AUTH_METHOD=trust volumes: - db_data:/var/lib/postgresql/data