[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.
This commit is contained in:
Earlopain 2023-03-01 20:31:49 +01:00
parent fd28503e03
commit 6776704560
No known key found for this signature in database
GPG Key ID: 6CFB948E15246897
4 changed files with 9 additions and 10 deletions

View File

@ -1,6 +1,6 @@
FROM ruby:3.1.3-alpine3.17 as ruby-builder 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 ./ COPY Gemfile Gemfile.lock ./
RUN gem i bundler:2.3.12 foreman && BUNDLE_IGNORE_CONFIG=true bundle install -j$(nproc) \ 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 FROM ruby:3.1.3-alpine3.17
RUN apk --no-cache add ffmpeg vips \ RUN apk --no-cache add ffmpeg vips \
postgresql12-client \ postgresql15-client \
git jemalloc tzdata git jemalloc tzdata
WORKDIR /app WORKDIR /app

View File

@ -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. `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 ## Production Setup

View File

@ -1,18 +1,17 @@
default: &default default: &default
adapter: postgresql adapter: postgresql
timeout: 5000 timeout: 5000
username: e621
development: development:
<<: *default <<: *default
database: danbooru2 database: e621_development
username: danbooru
host: postgres host: postgres
pool: 5 pool: 5
test: test:
<<: *default <<: *default
database: danbooru2_test database: e621_test
username: danbooru
host: postgres host: postgres
pool: 5 pool: 5
@ -20,7 +19,6 @@ test:
production: production:
<<: *default <<: *default
database: e621 database: e621
username: e621
password: <%= ENV.fetch("DB_PASSWORD") %> password: <%= ENV.fetch("DB_PASSWORD") %>
host: <%= ENV.fetch("DB_HOST") %> host: <%= ENV.fetch("DB_HOST") %>
pool: <%= Sidekiq.server? ? ENV.fetch("DB_WORKER_POOL_SIZE") : ENV.fetch("DB_POOL_SIZE") %> pool: <%= Sidekiq.server? ? ENV.fetch("DB_WORKER_POOL_SIZE") : ENV.fetch("DB_POOL_SIZE") %>

View File

@ -58,9 +58,10 @@ services:
- "3000:3000" - "3000:3000"
postgres: postgres:
image: postgres:12-alpine image: postgres:15-alpine
environment: environment:
- POSTGRES_USER=danbooru - POSTGRES_USER=e621
- POSTGRES_DB=e621_development
- POSTGRES_HOST_AUTH_METHOD=trust - POSTGRES_HOST_AUTH_METHOD=trust
volumes: volumes:
- db_data:/var/lib/postgresql/data - db_data:/var/lib/postgresql/data