mirror of
https://github.com/kou029w/_.git
synced 2025-01-30 13:58:08 +00:00
create postgres migration
This commit is contained in:
parent
966a3a2ec6
commit
8e62760d69
3 changed files with 55 additions and 0 deletions
2
postgres-migration/.env
Normal file
2
postgres-migration/.env
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# touch .env && chmod 600 .env && echo POSTGRES_PASSWORD=$(openssl rand -hex 32) >> .env
|
||||||
|
POSTGRES_PASSWORD=18bc0402c8e8a7d95ed49c2d9b93a4cae9d5970c9fc6c6f328977b93f77bb48a
|
40
postgres-migration/compose.yml
Normal file
40
postgres-migration/compose.yml
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
services:
|
||||||
|
pgadmin:
|
||||||
|
image: dpage/pgadmin4
|
||||||
|
ports:
|
||||||
|
- "8080:80"
|
||||||
|
environment:
|
||||||
|
PGADMIN_DEFAULT_EMAIL: postgres@db.host.docker.internal
|
||||||
|
PGADMIN_DEFAULT_PASSWORD: ${POSTGRES_PASSWORD:?}
|
||||||
|
volumes:
|
||||||
|
- ./servers.json:/pgadmin4/servers.json:ro
|
||||||
|
db:
|
||||||
|
image: postgres:16-alpine
|
||||||
|
environment:
|
||||||
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?}
|
||||||
|
volumes:
|
||||||
|
- postgres_data_v16:/var/lib/postgresql/data
|
||||||
|
# - postgres_data_v17:/var/lib/postgresql/data
|
||||||
|
old_db:
|
||||||
|
profiles:
|
||||||
|
- migration
|
||||||
|
image: postgres:16-alpine
|
||||||
|
# image: postgres:16-alpine
|
||||||
|
environment:
|
||||||
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?}
|
||||||
|
volumes:
|
||||||
|
- postgres_data_v16:/var/lib/postgresql/data
|
||||||
|
volumes:
|
||||||
|
postgres_data_v16:
|
||||||
|
# postgres_data_v17:
|
||||||
|
# docker compose down
|
||||||
|
# editor compose.yml
|
||||||
|
# add new version volume
|
||||||
|
# replace old_db.image new → old version
|
||||||
|
# replace db.volumes old → new version
|
||||||
|
# docker compose --profile=migration up -d old_db db
|
||||||
|
# docker compose exec old_db pg_dumpall --clean -U postgres | docker compose exec -T db psql -U postgres
|
||||||
|
# docker compose up -d
|
||||||
|
# docker compose --profile=migration down old_db
|
||||||
|
# editor compose.yml
|
||||||
|
# remove volume
|
13
postgres-migration/servers.json
Normal file
13
postgres-migration/servers.json
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"Servers": {
|
||||||
|
"1": {
|
||||||
|
"Name": "postgres@db",
|
||||||
|
"Group": "docker",
|
||||||
|
"Port": 5432,
|
||||||
|
"Username": "postgres",
|
||||||
|
"Host": "db",
|
||||||
|
"SSLMode": "prefer",
|
||||||
|
"MaintenanceDB": "postgres"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue