Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrations get stuck due to a confirmation prompt #5976

Open
moltar opened this issue Jun 20, 2024 · 1 comment
Open

Migrations get stuck due to a confirmation prompt #5976

moltar opened this issue Jun 20, 2024 · 1 comment

Comments

@moltar
Copy link

moltar commented Jun 20, 2024

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:
  [email protected]

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)

npx ts-node ./scripts/setup-db.ts

Copy link

greptile-apps bot commented Jun 20, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
Development

No branches or pull requests

1 participant