Skip to content

Commit

Permalink
Remove deprecated config.db.adapter option (keystonejs#6518)
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie authored and Nikitoring committed Sep 14, 2021
1 parent 1075ac1 commit 655811f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 30 deletions.
5 changes: 5 additions & 0 deletions .changeset/gold-pillows-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-next/keystone': major
---

Removed the deprecated `config.db.adapter` option. Please use `config.db.provider` to indicate the database provider for your system.
2 changes: 1 addition & 1 deletion packages/keystone/src/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const makeVercelIncludeTheSQLiteDB = (
directoryOfFileToBeWritten: string,
config: KeystoneConfig
) => {
if (config.db.adapter === 'prisma_sqlite' || config.db.provider === 'sqlite') {
if (config.db.provider === 'sqlite') {
const sqliteDbAbsolutePath = path.resolve(cwd, config.db.url.replace('file:', ''));

return `import path from 'path';
Expand Down
4 changes: 2 additions & 2 deletions packages/keystone/src/lib/createSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { makeCreateContext } from './context/createContext';
import { initialiseLists } from './core/types-for-lists';

export function getDBProvider(db: KeystoneConfig['db']): DatabaseProvider {
if (db.adapter === 'prisma_postgresql' || db.provider === 'postgresql') {
if (db.provider === 'postgresql') {
return 'postgresql';
} else if (db.adapter === 'prisma_sqlite' || db.provider === 'sqlite') {
} else if (db.provider === 'sqlite') {
return 'sqlite';
} else {
throw new Error(
Expand Down
28 changes: 2 additions & 26 deletions packages/keystone/src/types/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,32 +58,8 @@ export type DatabaseConfig = {
enableLogging?: boolean;
prismaPreviewFeatures?: string[];
idField?: IdFieldConfig;
} & (
| (
| {
/** @deprecated The `adapter` option is deprecated. Please use `{ provider: 'postgresql' }` */
adapter: 'prisma_postgresql';
provider?: undefined;
}
| {
/** @deprecated The `adapter` option is deprecated. Please use `{ provider: 'postgresql' }` */
adapter?: undefined;
provider: 'postgresql';
}
)
| (
| {
/** @deprecated The `adapter` option is deprecated. Please use `{ provider: 'sqlite' }` */
adapter: 'prisma_sqlite';
provider?: undefined;
}
| {
/** @deprecated The `adapter` option is deprecated. Please use `{ provider: 'sqlite' }` */
adapter?: undefined;
provider: 'sqlite';
}
)
);
provider: 'postgresql' | 'sqlite';
};

// config.ui

Expand Down
2 changes: 1 addition & 1 deletion tests/api-tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { KeystoneConfig, DatabaseProvider } from '@keystone-next/keystone/types'
// export it from `@keystone-next/keystone/testing`.
export const apiTestConfig = (
config: Omit<KeystoneConfig, 'db'> & {
db?: Omit<KeystoneConfig['db'], 'provider' | 'url' | 'adapter'>;
db?: Omit<KeystoneConfig['db'], 'provider' | 'url'>;
}
): KeystoneConfig => ({
...config,
Expand Down

0 comments on commit 655811f

Please sign in to comment.