# Upgrade the Schema (https://s3.dimah.dev/docs/db/upgrade)

`@dimah-s3/db` 2.0 beta reads and writes schema `2.1.0`, and that schema is
the only one in the package. It does not upgrade a 1.x database or a
database created at schema `2.0.0`. For the code changes in every package,
see [Upgrade to 2.0 beta](https://s3.dimah.dev/docs/migration-2-0).

## A new database [#a-new-database]

Create the tables from [Setup](https://s3.dimah.dev/docs/db/setup): the SQL file, the Drizzle
tables, the Prisma schema, or `migrate(client)` with Kysely. Point those
tools at a new database. An ORM diff against an older database can drop
columns.

A database from an earlier 2.0 beta, including one already at `2.0.0`, is
not migrated. Create schema `2.1.0` on a new database. Folders are rows
with ids: an object stores `folderId`, and renaming or moving a folder
rewrites cached paths without rewriting object rows.

## Check [#check]

Call `checkSchema` at startup. It throws unless the database is at
`2.1.0`:

```ts
await s3.db.checkSchema();
```

A database at any other version throws on the first query too.
