• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

safe-global / safe-client-gateway / 11367733917

16 Oct 2024 02:24PM UTC coverage: 90.591% (-0.6%) from 91.148%
11367733917

Pull #1988

github

PooyaRaki
Refactor unit tests, initializes postgres database on module startup, reverts v1 migration configuration
Pull Request #1988: OrmMigrationAndLogger

2655 of 3258 branches covered (81.49%)

Branch coverage included in aggregate %.

89 of 160 new or added lines in 17 files covered. (55.63%)

8802 of 9389 relevant lines covered (93.75%)

409.57 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

35.29
/src/datasources/db/v2/database-migration.hook.ts
1
import { Inject, Injectable, type OnModuleInit } from '@nestjs/common';
100✔
2
import { IConfigurationService } from '@/config/configuration.service.interface';
100✔
3
import { DatabaseMigrator } from '@/datasources/db/v2/database-migrator.service';
100✔
4
import {
100✔
5
  LoggingService,
6
  type ILoggingService,
7
} from '@/logging/logging.interface';
8
import { PostgresDatabaseService } from '@/datasources/db/v2/postgres-database.service';
100✔
9

10
@Injectable()
11
export class DatabaseMigrationHook implements OnModuleInit {
100✔
12
  private readonly executeMigrations: boolean;
13

14
  public constructor(
15
    @Inject(PostgresDatabaseService)
NEW
16
    private readonly postgresDatabaseService: PostgresDatabaseService,
×
17
    @Inject(DatabaseMigrator)
NEW
18
    private readonly migrationService: DatabaseMigrator,
×
19
    @Inject(IConfigurationService)
NEW
20
    private readonly configurationService: IConfigurationService,
×
21
    @Inject(LoggingService)
NEW
22
    private readonly loggingService: ILoggingService,
×
23
  ) {
NEW
24
    this.executeMigrations = this.configurationService.getOrThrow<boolean>(
×
25
      'db.migrator.executeMigrations',
26
    );
27
  }
28

29
  public async onModuleInit(): Promise<void> {
NEW
30
    if (!this.executeMigrations) {
×
NEW
31
      return this.loggingService.info('TypeOrm migrations are disabled!');
×
32
    }
33

NEW
34
    await this.postgresDatabaseService.initializeDatabaseConnection();
×
NEW
35
    await this.migrationService.migrate();
×
36
  }
37
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc