I have created a new serverpod project and launched the docker containers for the database and redis. But when I launch the server it self I get the following error:
Failed to connect to the database. Retrying in 10 seconds. PostgreSQLSeverity.error 42P01: relation "serverpod_runtime_settings" does not exist
I have tried following the get started steps here: https://docs.serverpod.dev/ but still running into this issue.
2
Answers
The documentation is not clear on this, but serverpod comes with a set of database tables that needs to be initialized before you can run the server.
From your server project run:
<container_name> is normally
your_project_server-postgres
but you can find the exact name by running$ docker ps
assuming the container is running. If not start it first with$ docker-compose up --build --detach
.<db_name> is normally the same as
project_name
but for the development server the name is defined inside this file:your_project/your_project_server/config/development.yaml
What is going on here? You need create the database tables and the code for this comes with serverpod already and all you need to do is run it on your database!
You can find the sql code in this path:
your_project/your_project_server/generated/tables-serverpod.pgsql
The command above will first copy the pgsql file into the docker container that is running and then with the second command you are executing the sql code on the database! Meaning you will create all the tables that are needed. As an FYI you can use this same method when setting up any serverpod modules such as severpod_auth as they also come with a set of database tables see documentation on this here: https://docs.serverpod.dev/concepts/modules.
It is also possible to use a gui tool such as https://www.pgadmin.org/ or https://eggerapps.at/postico2/. To then connect to the db you can find the username and password inside these files:
your_project/your_project_server/config/development.yaml
andyour_project/your_project_server/config/passwords.yaml
using localhost:8090 as the address (this is the default). Then copy paste the code from the pgsql file into a window where you can execute sql code and then execute it.I have done the same creating flutter serverpod project. when I run my project on other Mac(not the host one). it used to give me error like you mentioned above. but then I generate the basic serverpod settings as suggested by above answer. the problem now is I had also created the USER table in the host Mac with 3-4 records of users. now I don’t see the user table at all when using the project on other Mac. so basically how do I run the whole flutter serverpod project with records and everything remotely via different mac’s.