diff --git a/.changeset/lovely-days-smile.md b/.changeset/lovely-days-smile.md new file mode 100644 index 00000000000..48060d4feb5 --- /dev/null +++ b/.changeset/lovely-days-smile.md @@ -0,0 +1,7 @@ +--- +'@keystone-next/adapter-prisma-legacy': minor +'@keystone-next/types': minor +'@keystone-next/keystone': minor +--- + +Added `none-skip-client-generation` migrationMode diff --git a/packages-next/keystone/src/scripts/run/start.ts b/packages-next/keystone/src/scripts/run/start.ts index cc8ac9a432b..b26a014837a 100644 --- a/packages-next/keystone/src/scripts/run/start.ts +++ b/packages-next/keystone/src/scripts/run/start.ts @@ -15,7 +15,11 @@ export const start = async ({ dotKeystonePath, projectAdminPath }: StaticPaths) throw new Error('keystone-next build must be run before running keystone-next start'); } const config = initConfig(require(apiFile).config); - const { keystone, graphQLSchema, createContext } = createSystem(config, dotKeystonePath, 'none'); + const { keystone, graphQLSchema, createContext } = createSystem( + config, + dotKeystonePath, + 'none-skip-client-generation' + ); console.log('✨ Connecting to the database'); await keystone.connect({ context: createContext().sudo() }); diff --git a/packages-next/types/src/core.ts b/packages-next/types/src/core.ts index 14715df0477..f1175f5bd0b 100644 --- a/packages-next/types/src/core.ts +++ b/packages-next/types/src/core.ts @@ -66,4 +66,9 @@ export function getGqlNames({ }; } -export type MigrationMode = 'none' | 'createOnly' | 'dev' | 'prototype'; +export type MigrationMode = + | 'none-skip-client-generation' + | 'none' + | 'createOnly' + | 'dev' + | 'prototype'; diff --git a/packages/adapter-prisma/src/adapter-prisma.js b/packages/adapter-prisma/src/adapter-prisma.js index 2623e3ab752..6d99b0a1c80 100644 --- a/packages/adapter-prisma/src/adapter-prisma.js +++ b/packages/adapter-prisma/src/adapter-prisma.js @@ -88,21 +88,17 @@ class PrismaAdapter extends BaseKeystoneAdapter { } async _generateClient(rels) { - // 1. Generate a formatted schema + // Generate a formatted schema + // note that we currently still need to call _prepareSchema even during + // a `keystone-next start` because it has various side effects const { prismaSchema } = await this._prepareSchema(rels); - // 2. Check for existing schema - // 2a1. If they're the same, we're golden - // 2a2. If they're different, generate and run a migration - // 2b. If it doesn't exist, generate and run a migration + if (this.migrationMode !== 'none-skip-client-generation') { + this._writePrismaSchema({ prismaSchema }); - // If any of our critical directories are missing, or if the schema has changed, then - // we've got things to do. - - this._writePrismaSchema({ prismaSchema }); - - // Generate prisma client and run prisma migrations - await Promise.all([this._generatePrismaClient(), this._runMigrations({ prismaSchema })]); + // Generate prisma client and run prisma migrations + await Promise.all([this._generatePrismaClient(), this._runMigrations({ prismaSchema })]); + } } async _runMigrations({ prismaSchema }) {