238be84336
Addresses https://github.com/twentyhq/twenty/issues/15274 There's no need to parse the URL, since psql is happy to use it directly. If you are going to parse the URL, you should parse it correctly - the logic removed here make a number of assumptions about the URL that are inaccurate and reject many types of valid URIs. This does drop the ability to create the database which may be handy for people that don't do database administration. For people that do, this is an anti-feature.
43 lines
1.2 KiB
Bash
Executable File
43 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
|
set -e
|
|
|
|
setup_and_migrate_db() {
|
|
if [ "${DISABLE_DB_MIGRATIONS}" = "true" ]; then
|
|
echo "Database setup and migrations are disabled, skipping..."
|
|
return
|
|
fi
|
|
|
|
echo "Running database setup and migrations..."
|
|
|
|
# Run setup and migration scripts
|
|
has_schema=$(psql -tAc "SELECT EXISTS (SELECT 1 FROM information_schema.schemata WHERE schema_name = 'core')" ${PG_DATABASE_URL})
|
|
if [ "$has_schema" = "f" ]; then
|
|
echo "Database appears to be empty, running migrations."
|
|
NODE_OPTIONS="--max-old-space-size=1500" tsx ./scripts/setup-db.ts
|
|
yarn database:migrate:prod
|
|
fi
|
|
|
|
yarn command:prod upgrade
|
|
echo "Successfully migrated DB!"
|
|
}
|
|
|
|
register_background_jobs() {
|
|
if [ "${DISABLE_CRON_JOBS_REGISTRATION}" = "true" ]; then
|
|
echo "Cron job registration is disabled, skipping..."
|
|
return
|
|
fi
|
|
|
|
echo "Registering background sync jobs..."
|
|
if yarn command:prod cron:register:all; then
|
|
echo "Successfully registered all background sync jobs!"
|
|
else
|
|
echo "Warning: Failed to register background jobs, but continuing startup..."
|
|
fi
|
|
}
|
|
|
|
setup_and_migrate_db
|
|
register_background_jobs
|
|
|
|
# Continue with the original Docker command
|
|
exec "$@"
|