Hello, I just wanted to understand the concept of "Project". Is a Database a "Project" in Directus API context ?
Lets say I have already an API instance running as a Docker container (Which contains ENV variables about the DB). I have the localhost:7000 endpoint exposed. The API works like expected on the default project ( localhost:7000/_/ ), collections, fileds, etc. All Good.
According to the Documentation, there is a way to create new projects using the API ?
https://docs.directus.io/api/reference.html#create-project
But when I POST the project data I get: Invalid database connection in return.
Is this API Instance supposed to create the Database, Credentials and config file of a new project automatically ? Is this posible in the Docker API Instance ? (Since the docker-compose.yml, already has a DB Info )
My main goal is to use a SINGLE instance of the docker API to manage SEVERAL databases (Projects).
Thanks in advance
Hey @juanitoddd!
Is this API Instance supposed to create the Database, Credentials and config file of a new project automatically ?
Kinda. This endpoint will generate a config file and put the required tables, columns, and initial rows in the provided database for you. You will have to create the database and user/pw yourself.
Also — yes, a project is essentially the Directus term used for database... but also includes the storage adapter.
https://docs.directus.io/getting-started/concepts.html#project
Thanks @rijkvanzanten @benhaynes for the explanation !
Following this train of thought, one can conclude that to create a new Project using the API:
(1). The Database and Database credentials have to be created first.
(2). Using the [POST] /projects endpoint of the API, Directus will create the everything else with the POST'ed data.
I was assuming Directus had a "create if does not exists" policy in this regard.
I was assuming Directus had a "create if does not exists" policy in this regard.
The problem there is that Directus would need some sort of database access before it can create a new user. We might be able to dynamically create the database if it doesn't exist using the database user credentials provided, but that would only work if the provided user has permissions to create new databases on the mysql server. It would only work under very specific conditions.
We could always change the order of the installer... first asking if they want to install a new database or use an existing one.
New — We get the DB user first, could check if they have permission to create databases, create the DB, and continue as normal. If the user does _not_ have CREATE DB access, then we could warn the user and offer to install on an existing DB (see below).
Existing — We keep things as they are now, warning if there are already Directus tables in the chosen DB.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
To achieve better clarity/visibility, we are now tracking feature requests within the Feature Request project board.
This issue being closed does not mean it's not being considered.
@benhaynes Hi Ben.
I'm using the directus/docker single api example. I've the following scenario:
I've done the post to /projects in order to create it, and it worked fine. Also, I put the environment variables in the api service in the docker-compose. In the app UI, I see the dropdown to switch between them, but when I try to go to the prod environment, I get redirected to the login page, and when I put the user (I use the same for both), I keep seeing the UI as if I was in the DEV project.
What I am doing wrong?
BR
Hey @lluishi93 — the docker install/setup is all very specific to Docker. I would maybe ask @WoLfulus about this over on the directus/docker repo. He's working on some big updates that should be ready in the next few days.
Also keep in mind that the versions on the current docker image might be out of date on fresh installs.