mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 01:01:39 -05:00
Fix database creation on startup
This commit is contained in:
parent
67fb5a0563
commit
a104bb083f
4 changed files with 15 additions and 10 deletions
|
|
@ -1 +1 @@
|
|||
0.25.7
|
||||
0.25.8
|
||||
|
|
|
|||
10
CHANGELOG.md
10
CHANGELOG.md
|
|
@ -5,6 +5,16 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
|||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
|
||||
# 0.25.8 - 2025-04-24
|
||||
|
||||
## Fixed
|
||||
|
||||
- Database was not being created if it didn't exist. #1076
|
||||
|
||||
## Removed
|
||||
|
||||
- `RAILS_MASTER_KEY` environment variable is no longer being set. You can safely remove it from your environment variables.
|
||||
|
||||
# 0.25.7 - 2025-04-24
|
||||
|
||||
## Fixed
|
||||
|
|
|
|||
|
|
@ -70,7 +70,6 @@ services:
|
|||
PROMETHEUS_EXPORTER_HOST: 0.0.0.0
|
||||
PROMETHEUS_EXPORTER_PORT: 9394
|
||||
SELF_HOSTED: "true"
|
||||
RAILS_MASTER_KEY: ${RAILS_MASTER_KEY}
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
|
|
@ -123,7 +122,6 @@ services:
|
|||
PROMETHEUS_EXPORTER_HOST: dawarich_app
|
||||
PROMETHEUS_EXPORTER_PORT: 9394
|
||||
SELF_HOSTED: "true"
|
||||
RAILS_MASTER_KEY: ${RAILS_MASTER_KEY}
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
|
|
|
|||
|
|
@ -27,20 +27,17 @@ fi
|
|||
# Remove pre-existing puma/passenger server.pid
|
||||
rm -f $APP_PATH/tmp/pids/server.pid
|
||||
|
||||
echo "Attempting to create database $DATABASE_NAME if it doesn't exist..."
|
||||
PGPASSWORD=$DATABASE_PASSWORD createdb -h "$DATABASE_HOST" -p "$DATABASE_PORT" -U "$DATABASE_USERNAME" "$DATABASE_NAME" 2>/dev/null || echo "Note: Database may already exist or couldn't be created now"
|
||||
|
||||
# Wait for the database to become available
|
||||
echo "⏳ Waiting for database to be ready..."
|
||||
until PGPASSWORD=$DATABASE_PASSWORD psql -h "$DATABASE_HOST" -p "$DATABASE_PORT" -U "$DATABASE_USERNAME" -d "$DATABASE_NAME" -c '\q'; do
|
||||
until PGPASSWORD=$DATABASE_PASSWORD psql -h "$DATABASE_HOST" -p "$DATABASE_PORT" -U "$DATABASE_USERNAME" -d "$DATABASE_NAME" -c '\q' 2>/dev/null; do
|
||||
>&2 echo "Postgres is unavailable - retrying..."
|
||||
sleep 2
|
||||
done
|
||||
echo "✅ PostgreSQL is ready!"
|
||||
|
||||
# Create database if it doesn't exist
|
||||
if ! PGPASSWORD=$DATABASE_PASSWORD psql -h "$DATABASE_HOST" -p "$DATABASE_PORT" -U "$DATABASE_USERNAME" -d "$DATABASE_NAME" -c "SELECT 1 FROM pg_database WHERE datname='$DATABASE_NAME'" | grep -q 1; then
|
||||
echo "Creating database $DATABASE_NAME..."
|
||||
PGPASSWORD=$DATABASE_PASSWORD createdb -h "$DATABASE_HOST" -p "$DATABASE_PORT" -U "$DATABASE_USERNAME" "$DATABASE_NAME"
|
||||
fi
|
||||
|
||||
# Run database migrations
|
||||
echo "PostgreSQL is ready. Running database migrations..."
|
||||
bundle exec rails db:migrate
|
||||
|
|
|
|||
Loading…
Reference in a new issue