The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Stop parsing the PG_DATABASE_URL, use it directly (#15310)
Eli Ribble238be843363a
diff --git a/packages/twenty-docker/docker-compose.yml b/packages/twenty-docker/docker-compose.ymlindex e95fde62faf..910990413f9 100644--- a/packages/twenty-docker/docker-compose.yml+++ b/packages/twenty-docker/docker-compose.yml@@ -109,8 +109,9 @@ services:volumes:- db-data:/var/lib/postgresql/dataenvironment:- POSTGRES_USER: ${PG_DATABASE_USER:-postgres}+ POSTGRES_DB: ${PG_DATABASE_NAME:-default}POSTGRES_PASSWORD: ${PG_DATABASE_PASSWORD:-postgres}+ POSTGRES_USER: ${PG_DATABASE_USER:-postgres}healthcheck:test: pg_isready -U ${PG_DATABASE_USER:-postgres} -h localhost -d postgresinterval: 5sdiff --git a/packages/twenty-docker/twenty/entrypoint.sh b/packages/twenty-docker/twenty/entrypoint.shindex 0175a0a4f16..70d804ea168 100755--- a/packages/twenty-docker/twenty/entrypoint.sh+++ b/packages/twenty-docker/twenty/entrypoint.sh@@ -8,27 +8,15 @@ setup_and_migrate_db() {fiecho "Running database setup and migrations..."- PGUSER=$(echo $PG_DATABASE_URL | awk -F '//' '{print $2}' | awk -F ':' '{print $1}')- PGPASS=$(echo $PG_DATABASE_URL | awk -F ':' '{print $3}' | awk -F '@' '{print $1}')- PGHOST=$(echo $PG_DATABASE_URL | awk -F '@' '{print $2}' | awk -F ':' '{print $1}')- PGPORT=$(echo $PG_DATABASE_URL | awk -F ':' '{print $4}' | awk -F '/' '{print $1}')- PGDATABASE=$(echo $PG_DATABASE_URL | awk -F '/' '{print $NF}' | cut -d'?' -f1)-- # Creating the database if it doesn't exist- db_count=$(PGPASSWORD=${PGPASS} psql -h ${PGHOST} -p ${PGPORT} -U ${PGUSER} -d postgres -tAc "SELECT COUNT(*) FROM pg_database WHERE datname = '${PGDATABASE}'")- if [ "$db_count" = "0" ]; then- echo "Database ${PGDATABASE} does not exist, creating..."- PGPASSWORD=${PGPASS} psql -h ${PGHOST} -p ${PGPORT} -U ${PGUSER} -d postgres -c "CREATE DATABASE \"${PGDATABASE}\""- fi# Run setup and migration scripts- has_schema=$(PGPASSWORD=${PGPASS} psql -h ${PGHOST} -p ${PGPORT} -U ${PGUSER} -d ${PGDATABASE} -tAc "SELECT EXISTS (SELECT 1 FROM information_schema.schemata WHERE schema_name = 'core')")+ has_schema=$(psql -tAc "SELECT EXISTS (SELECT 1 FROM information_schema.schemata WHERE schema_name = 'core')" ${PG_DATABASE_URL})if [ "$has_schema" = "f" ]; thenecho "Database appears to be empty, running migrations."NODE_OPTIONS="--max-old-space-size=1500" tsx ./scripts/setup-db.tsyarn database:migrate:prodfi-+yarn command:prod upgradeecho "Successfully migrated DB!"}@@ -38,7 +26,7 @@ register_background_jobs() {echo "Cron job registration is disabled, skipping..."returnfi-+echo "Registering background sync jobs..."if yarn command:prod cron:register:all; thenecho "Successfully registered all background sync jobs!"