mirror of
https://github.com/immich-app/immich.git
synced 2025-12-21 01:11:16 +03:00
feat(server): env variable to skip migrations on startup (#9069)
* env variable to skip migrations * update docs * update env doc
This commit is contained in:
@@ -28,6 +28,7 @@ export const immichAppConfig: ConfigModuleOptions = {
|
||||
DB_DATABASE_NAME: WHEN_DB_URL_SET,
|
||||
DB_URL: Joi.string().optional(),
|
||||
DB_VECTOR_EXTENSION: Joi.string().optional().valid('pgvector', 'pgvecto.rs').default('pgvecto.rs'),
|
||||
DB_SKIP_MIGRATIONS: Joi.boolean().optional().default(false),
|
||||
|
||||
MACHINE_LEARNING_PORT: Joi.number().optional(),
|
||||
MICROSERVICES_PORT: Joi.number().optional(),
|
||||
|
||||
@@ -12,6 +12,7 @@ describe(DatabaseService.name, () => {
|
||||
let loggerMock: Mocked<ILoggerRepository>;
|
||||
|
||||
beforeEach(() => {
|
||||
delete process.env.DB_SKIP_MIGRATIONS;
|
||||
databaseMock = newDatabaseRepositoryMock();
|
||||
loggerMock = newLoggerRepositoryMock();
|
||||
sut = new DatabaseService(databaseMock, loggerMock);
|
||||
@@ -210,5 +211,13 @@ describe(DatabaseService.name, () => {
|
||||
expect(loggerMock.fatal).not.toHaveBeenCalled();
|
||||
},
|
||||
);
|
||||
|
||||
it('should skip migrations if DB_SKIP_MIGRATIONS=true', async () => {
|
||||
process.env.DB_SKIP_MIGRATIONS = 'true';
|
||||
|
||||
await expect(sut.init()).resolves.toBeUndefined();
|
||||
|
||||
expect(databaseMock.runMigrations).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -49,7 +49,9 @@ export class DatabaseService {
|
||||
throw error;
|
||||
}
|
||||
|
||||
await this.databaseRepository.runMigrations();
|
||||
if (process.env.DB_SKIP_MIGRATIONS !== 'true') {
|
||||
await this.databaseRepository.runMigrations();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user