fix(db): improve database initialization script and docker setup
- Rename init.sh to 00_init.sh for better ordering - Format docker-compose command for better readability - Add comprehensive database initialization script with backup restoration - Implement proper migration handling with schema_migrations table
This commit is contained in:
@@ -101,21 +101,26 @@ services:
|
|||||||
target: /docker-entrypoint-initdb.d/migrations
|
target: /docker-entrypoint-initdb.d/migrations
|
||||||
consistency: cached
|
consistency: cached
|
||||||
- type: bind
|
- type: bind
|
||||||
source: ./worklenz-backend/database/init.sh
|
source: ./worklenz-backend/database/00_init.sh
|
||||||
target: /docker-entrypoint-initdb.d/00_init.sh
|
target: /docker-entrypoint-initdb.d/00_init.sh
|
||||||
consistency: cached
|
consistency: cached
|
||||||
- type: bind
|
- type: bind
|
||||||
source: ./pg_backups
|
source: ./pg_backups
|
||||||
target: /docker-entrypoint-initdb.d/pg_backups
|
target: /docker-entrypoint-initdb.d/pg_backups
|
||||||
command: >
|
command: >
|
||||||
bash -c ' if command -v apt-get >/dev/null 2>&1; then
|
bash -c '
|
||||||
apt-get update && apt-get install -y dos2unix
|
if command -v apt-get >/dev/null 2>&1; then
|
||||||
elif command -v apk >/dev/null 2>&1; then
|
apt-get update && apt-get install -y dos2unix
|
||||||
apk add --no-cache dos2unix
|
elif command -v apk >/dev/null 2>&1; then
|
||||||
fi && find /docker-entrypoint-initdb.d -type f -name "*.sh" -exec sh -c '\''
|
apk add --no-cache dos2unix
|
||||||
dos2unix "{}" 2>/dev/null || true
|
fi
|
||||||
chmod +x "{}"
|
find /docker-entrypoint-initdb.d -type f -name "*.sh" -exec sh -c '\''
|
||||||
'\'' \; && exec docker-entrypoint.sh postgres '
|
dos2unix "{}" 2>/dev/null || true
|
||||||
|
chmod +x "{}"
|
||||||
|
'\'' \;
|
||||||
|
exec docker-entrypoint.sh postgres
|
||||||
|
'
|
||||||
|
|
||||||
db-backup:
|
db-backup:
|
||||||
image: postgres:15
|
image: postgres:15
|
||||||
container_name: worklenz_db_backup
|
container_name: worklenz_db_backup
|
||||||
|
|||||||
Reference in New Issue
Block a user