# Databases

Studio works with two kinds of databases:

- A **project** is a folder with a `fakebase.toml` and a `migrations` folder, usually the root of your app's repository. Projects have migrations.
- A **connection** is any PostgreSQL database you add with a connection string. You can browse and edit it, and create a project for it later to add migrations.

Everything starts from the database picker at the top of Studio.

## New project

Creates a project and a local PostgreSQL database for it in Docker.

1. Open the database picker and choose **New project**, or press **⌘P**.
2. Choose the **Project folder**. This is usually the root of your app's repository.
3. Optionally give the project a **Name**.
4. Choose **Create project**.

Studio writes `fakebase.toml` and a `migrations` folder, then starts the database. The first start downloads PostgreSQL, so it can take a minute. If the folder already has a project, Studio opens it instead.

> **Docker**
>
> New projects run PostgreSQL in Docker. Start [Docker
> Desktop](https://www.docker.com/products/docker-desktop/) before you create
> one.

## Open a project folder

Opens a project that already exists, for example one a teammate created.

1. Open the database picker and choose **Open project folder**, or press **⌘E**.
2. Choose the folder with `fakebase.toml`, or any folder inside it.
3. Choose **Open**.

If the project's database isn't set up on this machine yet, Studio asks how to connect it:

- **Local database:** choose **Start database** to create it in Docker, or use a connection you've already saved.
- **External database:** choose the saved connection the project's migrations should apply to.

## Add a connection

Connects to a PostgreSQL database you already have, like one on Supabase, Neon, Railway, or AWS RDS.

1. Open the database picker and choose **Add new connection**, or press **⌘O**.
2. Optionally give it a **Connection name**.
3. Paste the **Connection string**.
4. Choose **Connect**.

[Adding a connection in Fakebase Studio](https://fakebase.studio/docs/4_connect_to_db.mp4)

A connection string looks like this. Copy yours from your provider's dashboard:

```
postgresql://user:password@host:5432/database
```

Connection strings are encrypted and stored only on your machine.

If the connection fails, check that the username, password, host, and port are right, that the database accepts connections from your IP address, and that the SSL settings match what your provider expects.

To add migrations to a connection, open **Migrations** and choose **Create project**.

## Switch databases

Open the database picker and choose a database. Type in **Find connection** to filter the list. The dot next to each one shows whether it can be reached, and a folder icon marks projects.

Every page in Studio works on the database you have selected.

When you're signed in, you can also choose **My Projects** at the bottom of the sidebar to see every database, switch to one, rename it, copy its connection string, or delete it from Studio.

## Rename a database

Choose the gear next to the database picker, then **Rename project**. This changes the name in Studio only, not the database itself.

## Burn a database

Burning clears every table, all data, and the rest of the schema in the selected database, so you can start over. The database stays in Studio.

1. Choose the gear next to the database picker, then **Burn database**.
2. Review what will be removed.
3. Choose whether to also remove the migration files and setup. If you keep them, every migration becomes pending again, so you can apply them to the empty database.
4. Type the database name to confirm, then choose **Burn database**.

![Burning a database in Fakebase Studio](https://fakebase.studio/docs/6c_burn_database_demo.gif)

---

## Next steps

- [Tables](https://fakebase.studio/docs/studio-tables.md): Create, rename, and delete tables, and manage their columns and foreign keys in Fakebase Studio.
- [Migrations](https://fakebase.studio/docs/migrations.md): Keep schema changes as SQL files in your repo, in sync with the database you have open.
