Skip to content

Commit 7a4837d

Browse files
author
Josh Calder
committed
remove useMigrations
1 parent 2c77187 commit 7a4837d

File tree

8 files changed

+12
-25
lines changed

8 files changed

+12
-25
lines changed

examples/document-field-customisation/keystone-server/keystone.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import { Context, TypeInfo } from '.keystone/types';
66

77
const db: KeystoneConfig<TypeInfo>['db'] = {
88
provider: 'sqlite',
9-
// You should use migrations in production environments
10-
useMigrations: false,
119
url: process.env.DATABASE_URL || 'file:./database.db',
1210
async onConnect(context: Context) {
1311
if (process.argv.includes('--seed-database')) {

examples/e2e-boilerplate/keystone-server/keystone.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import { Context, TypeInfo } from '.keystone/types';
66

77
const db: KeystoneConfig<TypeInfo>['db'] = {
88
provider: 'sqlite',
9-
// You should use migrations in production environments
10-
useMigrations: false,
119
url: process.env.DATABASE_URL || 'file:./database.db',
1210
async onConnect(context: Context) {
1311
if (process.argv.includes('--seed-database')) {

examples/feature-boilerplate/keystone.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import { Context, TypeInfo } from '.keystone/types';
66

77
const db: KeystoneConfig<TypeInfo>['db'] = {
88
provider: 'sqlite',
9-
// You should use migrations in production environments
10-
useMigrations: false,
119
url: process.env.DATABASE_URL || 'file:./database.db',
1210
async onConnect(context: Context) {
1311
if (process.argv.includes('--seed-database')) {

packages/core/src/scripts/run/dev.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import fs from 'fs-extra';
88
import chalk from 'chalk';
99
import esbuild, { BuildFailure, BuildResult } from 'esbuild';
1010
import { generateAdminUI } from '../../admin-ui/system';
11-
import { devMigrations, pushPrismaSchemaToDatabase } from '../../lib/migrations';
11+
import { pushPrismaSchemaToDatabase } from '../../lib/migrations';
1212
import { createSystem } from '../../lib/createSystem';
1313
import { getEsbuildConfig, loadBuiltConfig } from '../../lib/config/loadConfig';
1414
import { defaults } from '../../lib/config/defaults';
@@ -66,7 +66,7 @@ export function setSkipWatching() {
6666
shouldWatch = false;
6767
}
6868

69-
export const dev = async (cwd: string, shouldDropDatabase: boolean) => {
69+
export const dev = async (cwd: string, shouldDropDatabase: boolean, pushDb: boolean) => {
7070
console.log('✨ Starting Keystone');
7171
const app = express();
7272
let expressServer: express.Express | null = null;
@@ -122,7 +122,7 @@ export const dev = async (cwd: string, shouldDropDatabase: boolean) => {
122122
apolloServer,
123123
prismaClientModule,
124124
...rest
125-
} = await setupInitialKeystone(config, cwd, shouldDropDatabase);
125+
} = await setupInitialKeystone(config, cwd, shouldDropDatabase, pushDb);
126126

127127
if (configWithHTTP?.server?.extendHttpServer) {
128128
configWithHTTP.server.extendHttpServer(httpServer, context, graphQLSchema);
@@ -176,8 +176,7 @@ export const dev = async (cwd: string, shouldDropDatabase: boolean) => {
176176
// and aren't written into the prisma schema since we check whether the prisma schema has changed above
177177
if (
178178
newConfig.db.enableLogging !== config.db.enableLogging ||
179-
newConfig.db.url !== config.db.url ||
180-
newConfig.db.useMigrations !== config.db.useMigrations
179+
newConfig.db.url !== config.db.url
181180
) {
182181
console.log('Your db config has changed, please restart Keystone');
183182
process.exit(1);
@@ -344,7 +343,8 @@ export const dev = async (cwd: string, shouldDropDatabase: boolean) => {
344343
async function setupInitialKeystone(
345344
config: KeystoneConfig,
346345
cwd: string,
347-
shouldDropDatabase: boolean
346+
shouldDropDatabase: boolean,
347+
pushDb: boolean
348348
) {
349349
const { graphQLSchema, adminMeta, getKeystone } = createSystem(config);
350350

@@ -357,22 +357,19 @@ async function setupInitialKeystone(
357357
let migrationPromise: Promise<void>;
358358

359359
// Set up the Database
360-
if (config.db.useMigrations) {
361-
migrationPromise = devMigrations(
362-
config.db.url,
363-
config.db.shadowDatabaseUrl,
364-
prismaSchema,
365-
getSchemaPaths(cwd).prisma,
366-
shouldDropDatabase
367-
);
368-
} else {
360+
if (pushDb) {
369361
migrationPromise = pushPrismaSchemaToDatabase(
370362
config.db.url,
371363
config.db.shadowDatabaseUrl,
372364
prismaSchema,
373365
getSchemaPaths(cwd).prisma,
374366
shouldDropDatabase
375367
);
368+
} else {
369+
const skipDBPush = async () => {
370+
console.log('⚠️ Skipping database schema push');
371+
};
372+
migrationPromise = skipDBPush();
376373
}
377374

378375
await Promise.all([prismaClientGenerationPromise, migrationPromise]);

packages/core/src/scripts/tests/fixtures/no-fields-with-migrations.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export default config({
55
db: {
66
provider: 'sqlite',
77
url: 'file:./app.db',
8-
useMigrations: true,
98
},
109
ui: { isDisabled: true },
1110
lists: {

packages/core/src/scripts/tests/fixtures/one-field-with-migrations.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export default config({
66
db: {
77
provider: 'sqlite',
88
url: 'file:./app.db',
9-
useMigrations: true,
109
},
1110
ui: { isDisabled: true },
1211
lists: {

packages/core/src/scripts/tests/fixtures/two-fields-with-migrations.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export default config({
66
db: {
77
provider: 'sqlite',
88
url: 'file:./app.db',
9-
useMigrations: true,
109
},
1110
ui: { isDisabled: true },
1211
lists: {

packages/core/src/types/config/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ export type DatabaseConfig<TypeInfo extends BaseKeystoneTypeInfo> = {
118118
url: string;
119119
shadowDatabaseUrl?: string;
120120
onConnect?: (args: KeystoneContext<TypeInfo>) => Promise<void>;
121-
useMigrations?: boolean;
122121
enableLogging?: boolean;
123122
idField?: IdFieldConfig;
124123
provider: DatabaseProvider;

0 commit comments

Comments
 (0)