Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run migrations only by the job server #135

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,7 @@ class Config {

const config = new Config(process.env);

export const isGraphQlMode = config.get('GRAPHQL_MODE') === 'true';
export const isJobMode = config.get('JOB_MODE') === 'true';

export default config;
3 changes: 2 additions & 1 deletion src/orm.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DataSource } from 'typeorm';
import { PostgresConnectionCredentialsOptions } from 'typeorm/driver/postgres/PostgresConnectionCredentialsOptions';
import config from './config';
import config, { isJobMode } from './config';
import { CronJob } from './entities/CronJob';
import { getEntities } from './entities/entities';
import { redisConfig } from './redis';
Expand Down Expand Up @@ -57,6 +57,7 @@ export class AppDataSource {
},
},
poolSize,
migrationsRun: isJobMode,
extra: {
maxWaitingClients: 10,
evictionRunIntervalMillis: 500,
Expand Down
5 changes: 1 addition & 4 deletions src/server/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import bodyParser from 'body-parser';
import graphqlUploadExpress from 'graphql-upload/graphqlUploadExpress.js';
import { ApolloServerPluginLandingPageDisabled } from '@apollo/server/plugin/disabled';
import { ApolloServerErrorCode } from '@apollo/server/errors';
import config from '../config';
import config, { isGraphQlMode, isJobMode } from '../config';
import { handleStripeWebhook } from '../utils/stripe';
import createSchema from './createSchema';
import SentryLogger from '../sentryLogger';
Expand Down Expand Up @@ -83,9 +83,6 @@ export async function bootstrap() {
try {
logger.debug('bootstrap() has been called', new Date());

const isGraphQlMode = config.get('GRAPHQL_MODE') === 'true';
const isJobMode = config.get('JOB_MODE') === 'true';

logger.info('isGraphQlMode: ', isGraphQlMode);
logger.info('isJobMode: ', isJobMode);

Expand Down
Loading