# Switching Databases

## Using a Different Database

{% hint style="info" %}
Please see [Login Checklist ](/technical/developers/troubleshooting/logging-in.md#login-checklist)for troubleshooting steps if you are experiencing issues with logging into your development installation of Elentra.
{% endhint %}

Often you want to test development code on different datasets (e.g. a fresh Elentra install, or a copy of your staging/production data). You can have multiple datasets in your database at the same time, and switch between them.

* Create a new Elentra ME auth database and import the new auth data into it.
* Create a new Elentra ME database and import the new Elentra ME data into it.
* Create a new Elentra ME clerkship database and import the new clerkship data into it.
* In the `database` section of the array in `config.inc.php`, set the `entrada_database`,`auth_database`, and `clerkship_database` values to the names of the new databases.
* Ensure that the database user (defined in `config.inc.php`) has select/update/create/delete access to all three of the above databases.
* Ensure that there is a user with suitable entries in the `[auth_schema].user_access` linked to an organisation in the `[auth_shema].organisations` table
  * This organisation should also have a corresponding entry in the `[auth_schema].registered_apps` table.&#x20;
  * The ID of this entry should be configured as the `AUTH_APP_ID` in the `settings.inc.php` file.
* Run migrations on the new dataset (in a terminal, go to the root of your installation and type: `php elentra migrate --up`).
* If you are importing old user credentials on top of the new dataset, in order to login you must update the `[auth_schema].user_data` table. You can either import the entire old User row or copy the old fields (`username`, `password`, `salt` and `uuid`) into the new dataset.

{% hint style="info" %}
&#x20;It is not necessary to update the `user_data` table to use Elentra's "Login as" functionality, for all users, only the ones you will login as from the Elentra login page.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.elentra.org/technical/developers/troubleshooting/switching-databases.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
