Skip to content

Commit 421140f

Browse files
committed
No implicit neo4j writes on app boot locally when the instance is not local
Hopefully, this will help prevent side effects when stupidly pointing to other env instances.
1 parent 3b97014 commit 421140f

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/components/admin/admin.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ export class AdminService implements OnApplicationBootstrap {
2020
) {}
2121

2222
async onApplicationBootstrap(): Promise<void> {
23+
if (!this.config.dbRootObjectsSync) {
24+
return;
25+
}
26+
2327
const finishing = this.repo.finishing(() => this.setupRootObjects());
2428
// Wait for root object setup when running tests, else just let it run in
2529
// the background and allow webserver to start.

src/core/config/config.service.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,22 @@ export const makeConfig = (env: EnvironmentService) =>
176176
: database,
177177
ephemeral: this.jest,
178178
driverConfig,
179+
isLocal: parsed.hostname === 'localhost',
179180
};
180181
})();
181182

182183
// Control which database is prioritized, while we migrate.
183184
databaseEngine = env.string('DATABASE').optional('neo4j').toLowerCase();
184185

185-
dbIndexesCreate = env.boolean('DB_CREATE_INDEXES').optional(true);
186+
dbIndexesCreate = env
187+
.boolean('DB_CREATE_INDEXES')
188+
.optional(isDev ? this.neo4j.isLocal : true);
186189
dbAutoMigrate = env
187190
.boolean('DB_AUTO_MIGRATE')
188-
.optional(process.env.NODE_ENV !== 'production' && !this.jest);
191+
.optional(isDev && this.neo4j.isLocal && !this.jest);
192+
dbRootObjectsSync = env
193+
.boolean('DB_ROOT_OBJECTS_SYNC')
194+
.optional(isDev ? this.neo4j.isLocal : true);
189195

190196
files = (() => {
191197
const legacyBucket = env.string('FILES_S3_BUCKET').optional();

0 commit comments

Comments
 (0)