twentyhq / twenty

Building a modern alternative to Salesforce, powered by the community.
https://twenty.com
GNU Affero General Public License v3.0
15.03k stars 1.48k forks source link

Migrations get stuck due to a confirmation prompt #5976

Open moltar opened 2 weeks ago

moltar commented 2 weeks ago

Here, the script runs npx ts-node.

On newer npm CLIs, this requires a --yes flag, otherwise the following prompt is generated:

Running database setup and migrations...
Need to install the following packages:
  ts-node@10.9.2

This probably only happens in the interactive mode, I imagine, but it's still an annoyance.

Also, I think ts-node should be a dependency anyways, and perhaps baked into the image.

Or better yet, use tsx (https://www.npmjs.com/package/tsx)

https://github.com/twentyhq/twenty/blob/9228667a57b93843df5cbe0bcccffc6facf1ab90/packages/twenty-docker/twenty/entrypoint.sh#L8

greptile-apps[bot] commented 2 weeks ago

To resolve the issue with the confirmation prompt during migrations, follow these steps:

  1. Modify /packages/twenty-docker/twenty/entrypoint.sh to use tsx instead of npx ts-node:
#!/bin/sh

# Check if the initialization has already been done and that we enabled automatic migration
if [ "${ENABLE_DB_MIGRATIONS}" = "true" ] && [ ! -f /app/docker-data/db_status ]; then
    echo "Running database setup and migrations..."

    # Run setup and migration scripts
    npx tsx ./scripts/setup-db.ts
    yarn database:migrate:prod

    # Mark initialization as done
    echo "Successfuly migrated DB!"
    touch /app/docker-data/db_status
fi

# Continue with the original Docker command
exec "$@"
  1. Add tsx as a dependency in package.json:
"dependencies": {
  "tsx": "^3.8.0"
}

This will ensure that the script runs without prompting for confirmation.

References

/packages/twenty-docker/twenty/entrypoint.sh /packages/twenty-docker/twenty

Ask Greptile