feat(db-sqlite): add autoIncrement option (#9427)

### What?
Exposes ability to enable
[AUTOINCREMENT](https://www.sqlite.org/autoinc.html) for Primary Keys
which ensures that the same ID cannot be reused from previously deleted
rows.

```ts
sqliteAdapter({
  autoIncrement: true
})
```

### Why?
This may be essential for some systems. Enabled `autoIncrement: true`
also for the SQLite Adapter in our tests, which can be useful when
testing whether the doc was deleted or not when you also have other
create operations.

### How?
Uses Drizzle's `autoIncrement` option.

WARNING:
This cannot be enabled in an existing project without a custom
migration, as it completely changes how primary keys are stored in the
database.
This commit is contained in:
Sasha
2024-12-20 22:13:28 +02:00
committed by GitHub
parent 99481cbc7d
commit 4e953530df
10 changed files with 72 additions and 31 deletions

View File

@@ -52,6 +52,7 @@ export const allDatabaseAdapters = {
client: {
url: process.env.SQLITE_URL || 'file:./payloadtests.db',
},
autoIncrement: true
})`,
'sqlite-uuid': `
import { sqliteAdapter } from '@payloadcms/db-sqlite'