To run anis need at least two databases:
- One database to store the configuration (metamodel database)
- At least one database containing datasets
Here we will explain how the metamodel database works.
Purpose of the database
Anis needs a database to store all the configuration :
- The available business database(s) that should contain the shared datasets.
- The different scientific projects.
- The shared datasets and their attributes.
- The access rights on datasets (groups_datasets).
By default anis-server is configured to connect to a PostgreSQL database created during the first launch of docker-compose.
The docker compose integrates a PostgreSQL database server named
You can find the
docker-compose.yml file at the root of the anis-server project.
The database settings connection are given in the environment variables of the server container.
Here is the list of options concerning the metamodel database :
DATABASE_DEV_MODE: Default to
1in development mode and to
0in production mode
DATABASE_CO_DRIVER: Doctrine pdo driver used to connect to the database
DATABASE_CO_HOST: Database server host
DATABASE_CO_PORT: Database server listening port
DATABASE_CO_DBNAME: Name of the anis-server metamodel database
DATABASE_CO_USER: User name used to connect to the anis-server metamodel database
DATABASE_CO_PASSWORD: Password used to connect to the anis-server metamodel database
You are free to change this configuration to connect to another database.
Anis server uses a tool called doctrine to generate the database from the code. You can find more information on the official website: https://www.doctrine-project.org.
Anis server stores the different doctrine entities in the
server/src/Entity folder and each file corresponds to a table in the metamodel database.
If you want to change the structure of the database you must edit or add entities. But be careful for each change you will have to re-generate the database and the doctrine proxies.
Doctrine command-line tool
You can use the doctrine command-line tool to perform most of the operations.
To run the tool you must have launched anis-server with the
docker-compose.yml file (see installation).
You must be at the root of the anis directory. And you can then enter into the server container by typing the following command:
$ make shell_server
Once in the container you can type the following command to execute doctrine-cli:
What you see are the different operations you can perform.
If you have performed operations on entities you must ensure that the database schema remains valid. Doctrine then proposes a command to perform that:
$ ./vendor/bin/doctrine orm:validate-schema
If the tables of your database are not yet generated you must ask doctrine to create them with the following command:
$ ./vendor/bin/doctrine orm:schema-tool:create
If the tables of your database are already generated but you want to start from a blank database you can type the following command:
$ ./vendor/bin/doctrine orm:schema-tool:drop
If you have made changes to your entities you must update the database with the following command:
$ ./vendor/bin/doctrine orm:schema-tool:update
If you have made changes to your entities you must also update the doctrine entities proxies. The doctrine entities proxies are used to improve the performance of requests. To regenerate them type the following command:
$ ./vendor/bin/doctrine orm:generate-proxies