3 months ago
Description: The #1 Open-Source CRM Modern, powerful, affordable.
Category: Other
6 Replies
2 months ago
Hey the postgres is empty when it deploys. getting a relational error. any idea how to fix it?
speenoo
Hey the postgres is empty when it deploys. getting a relational error. any idea how to fix it?
2 months ago
Hi, @speenoo! Thanks for reaching out.
I've just deployed the template and I wasn't able to reproduce the error. Postgres is provided using the default Railway template and not the default Postgres image by TwentyCRM. I would suggest try to deploy it again later or maybe creating a new database after deploying the template, just rename it as the default Postgres container and verify that env is pointing to it.
If the issue still persists please share maybe a SS or Logs to investigate more :)
a month ago
The postgres database is empty when deploying and re-creating a database doesnt work. Everything else works though just cant login.
macromillion
The postgres database is empty when deploying and re-creating a database doesnt work. Everything else works though just cant login.
a month ago
Hi @macromillion! Thanks for the info.
I have checked and indeed the migrations were not running (that's why you can login). I'm currently investigating this, since I don't know why the entry point is not running. But meanwhile there's an updated template with a temporary fix (running migrations as a pre-deploy command), now it runs!
Also I've updated removed the latest tag. I must now update after checking each new version since they are a good team and they move fast and sometimes it's hard to keep up with them!
roicort
Hi @macromillion! Thanks for the info.I have checked and indeed the migrations were not running (that's why you can login). I'm currently investigating this, since I don't know why the entry point is not running. But meanwhile there's an updated template with a temporary fix (running migrations as a pre-deploy command), now it runs!Also I've updated removed the latest tag. I must now update after checking each new version since they are a good team and they move fast and sometimes it's hard to keep up with them!
a month ago
Another option is to connect to the container with Railway's new feature, SSH! and run the entry point to create the database and run them or if its already created just "yarn database:migrate:prod && yarn command:prod upgrade". This is also very useful for updating TwentyCRM when there's a new major version (always remember tu dump your DB, just in case). Twenty is currently in v0.
Entry point in question.
sh -c "set -e; if [ \"\$DISABLE_DB_MIGRATIONS\" != \"true\" ] && [ ! -f /app/db_status ]; then echo '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 \$4}' | awk -F '/' '{print \$2}'); PGPASSWORD=\$PGPASS psql -h \$PGHOST -p \$PGPORT -U \$PGUSER -d postgres -tc \"SELECT 1 FROM pg_database WHERE datname = '\$PGDATABASE'\" | grep -q 1 || PGPASSWORD=\$PGPASS psql -h \$PGHOST -p \$PGPORT -U \$PGUSER -d postgres -c \"CREATE DATABASE \\\"\$PGDATABASE\\\"\"; NODE_OPTIONS='--max-old-space-size=1500' tsx ./scripts/setup-db.ts; yarn database:migrate:prod; yarn command:prod upgrade; echo 'Successfully migrated DB!'; touch /app/db_status; fi; exec \"\$@\""