twenty
twenty copied to clipboard
error: schema "core" does not exist
Error on docker-compose instalation : query failed: SELECT "KeyValuePair"."id" AS "KeyValuePair_id",
I run yarn database:migrate:prod manualy and get the error : " schema "core" does not exist "
The correct esoteric incantation you need to start the app is:
yarn database:init:prod
clickhouse:migrate:prod
node dist/src/main
This first runs packages\twenty-server\scripts\setup-db.ts, which ensures the required schemas exist, then it runs the migrations.
What incantations should be done for docker compose setups?
I think I solved that, in my case, I was running server and worker containers using database name "postgres", which is automatically created by postgres container.
While TwentyCRM wants to have their own db, which is in the current docker compose setup called "default", and it expects to create it on the first start.
In that case, it run the migration scripts for core schema and other stuff.
But if the db exists, it silently expects everything to have already been run.
This issue may be related to #12936
I was having the same error pointed here.
As @huksley pointed out (thank you for finding this), issue is with an existing database. I was using the "postgres" image, and that creates an empty database on startup (checked via psql inside the pod).
From the chart db configuration:
containers:
- name: postgres
image: {{ .Values.db.image }} # postgres:16
env:
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-app-secrets
key: PG_USER
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-app-secrets
key: PG_PASSWORD
The server pod starts the "migration", but fails trying to get env variables saved in the database, since the tables do not exist in that database.
Quick fix I did was running only the database pod, drop the created table from the database and then scale back the server pod, to create the new database using the setup script.
yarn database:init:prod
This did the trick for me. this appears to be a key step that should be added to the documentation for the docker compose setup.
Closing as solved!
Closing as solved!
What's the solution? Is the previously mentioned yarn command still required?