# Initialize/Update D1 Database

## Create Database

Open the Cloudflare console, select `Storage & Databases` -> `D1 SQL Database` -> `Create Database`, and click to create the database.

![d1](/ui_install/d1.png)

After creation, we can see the D1 database in the Cloudflare console.

## Initialize Database

::: warning Note
You can also skip initializing the database and after deployment is complete, go to the admin page's `Quick Setup` -> `Database` section and click the `Initialize Database` button to initialize the database.
:::

Open the `Console` tab, enter the content from the [db/schema.sql](https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/db/schema.sql) file in the repository, and click `Execute` to run it.

![d1](/ui_install/d1-exec.png)

## Update Database Schema

For `schema` updates, please confirm the version you previously deployed.

Check the [Changelog](https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/CHANGELOG.md)

Find the `patch` file that needs to be executed, for example: `db/2024-01-13-patch.sql`

Open the `Console` tab, enter the content of the `patch` file, and click `Execute` to run it.

![d1](/ui_install/d1-exec.png)
