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:
kithmina1999
2025-06-06 15:12:06 +05:30
parent 11694de4e6
commit dc22d1e6cb
2 changed files with 14 additions and 9 deletions

View File

@@ -101,21 +101,26 @@ services:
target: /docker-entrypoint-initdb.d/migrations
consistency: cached
- type: bind
source: ./worklenz-backend/database/init.sh
source: ./worklenz-backend/database/00_init.sh
target: /docker-entrypoint-initdb.d/00_init.sh
consistency: cached
- type: bind
source: ./pg_backups
target: /docker-entrypoint-initdb.d/pg_backups
command: >
bash -c ' if command -v apt-get >/dev/null 2>&1; then
bash -c '
if command -v apt-get >/dev/null 2>&1; then
apt-get update && apt-get install -y dos2unix
elif command -v apk >/dev/null 2>&1; then
apk add --no-cache dos2unix
fi && find /docker-entrypoint-initdb.d -type f -name "*.sh" -exec sh -c '\''
fi
find /docker-entrypoint-initdb.d -type f -name "*.sh" -exec sh -c '\''
dos2unix "{}" 2>/dev/null || true
chmod +x "{}"
'\'' \; && exec docker-entrypoint.sh postgres '
'\'' \;
exec docker-entrypoint.sh postgres
'
db-backup:
image: postgres:15
container_name: worklenz_db_backup