Skip to content

Commit

Permalink
docs: add idType to sqlite args
Browse files Browse the repository at this point in the history
  • Loading branch information
rilrom committed Oct 30, 2024
1 parent df4661a commit a515fac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion docs/database/sqlite.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default buildConfig({
| `client` \* | [Client connection options](https://orm.drizzle.team/docs/get-started-sqlite#turso) that will be passed to `createClient` from `@libsql/client`. |
| `push` | Disable Drizzle's [`db push`](https://orm.drizzle.team/kit-docs/overview#prototyping-with-db-push) in development mode. By default, `push` is enabled for development mode only. |
| `migrationDir` | Customize the directory that migrations are stored. |
| `idType` | A string of 'serial', or 'uuid' that is used for the data type given to id columns. |
| `logger` | The instance of the logger to be passed to drizzle. By default Payload's will be used. |
| `transactionOptions` | A SQLiteTransactionConfig object for transactions, or set to `false` to disable using transactions. [More details](https://orm.drizzle.team/docs/transactions) |
| `localesSuffix` | A string appended to the end of table names for storing localized fields. Default is '_locales'. |
Expand Down Expand Up @@ -157,7 +158,7 @@ sqliteAdapter({
})
```

Make sure Payload doesn't overlap table names with its collections. For example, if you already have a collection with slug "users", you should either change the slug or `dbName` to change the table name for this collection.
Make sure Payload doesn't overlap table names with its collections. For example, if you already have a collection with slug "users", you should either change the slug or `dbName` to change the table name for this collection.


### afterSchemaInit
Expand Down
6 changes: 3 additions & 3 deletions packages/db-sqlite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export type { MigrateDownArgs, MigrateUpArgs } from './types.js'
export { sql } from 'drizzle-orm'

export function sqliteAdapter(args: Args): DatabaseAdapterObj<SQLiteAdapter> {
const postgresIDType = args.idType || 'serial'
const payloadIDType = postgresIDType === 'serial' ? 'number' : 'text'
const sqliteIDType = args.idType || 'serial'
const payloadIDType = sqliteIDType === 'serial' ? 'number' : 'text'

function adapter({ payload }: { payload: Payload }) {
const migrationDir = findMigrationDir(args.migrationDir)
Expand Down Expand Up @@ -90,7 +90,7 @@ export function sqliteAdapter(args: Args): DatabaseAdapterObj<SQLiteAdapter> {
},
fieldConstraints: {},
getMigrationTemplate,
idType: postgresIDType,
idType: sqliteIDType,
initializing,
localesSuffix: args.localesSuffix || '_locales',
logger: args.logger,
Expand Down

0 comments on commit a515fac

Please sign in to comment.