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

safe-global / safe-client-gateway / 11340871916

15 Oct 2024 06:58AM UTC coverage: 46.83% (-45.0%) from 91.836%
11340871916

push

github

web-flow
Bump typescript from 5.6.2 to 5.6.3 (#2015)

Bumps [typescript](https://github.com/microsoft/TypeScript) from 5.6.2 to 5.6.3.
- [Release notes](https://github.com/microsoft/TypeScript/releases)
- [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml)
- [Commits](https://github.com/microsoft/TypeScript/compare/v5.6.2...v5.6.3)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

500 of 3096 branches covered (16.15%)

Branch coverage included in aggregate %.

5092 of 8845 relevant lines covered (57.57%)

12.16 hits per line

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

29.63
/src/datasources/db/postgres-database.migration.hook.ts
1
import { Inject, Injectable, OnModuleInit } from '@nestjs/common';
16✔
2
import { ILoggingService, LoggingService } from '@/logging/logging.interface';
16✔
3
import postgres from 'postgres';
16✔
4
import { PostgresDatabaseMigrator } from '@/datasources/db/postgres-database.migrator';
16✔
5
import { IConfigurationService } from '@/config/configuration.service.interface';
16✔
6
import { asError } from '@/logging/utils';
16✔
7

8
/**
9
 * The {@link PostgresDatabaseMigrationHook} is a Module Init hook meaning
10
 * that it will be executed once the dependencies are resolved.
11
 *
12
 * This happens before the Application Bootstraps, so route listeners are not
13
 * initiated and potentially generating queries.
14
 */
15
@Injectable({})
16
export class PostgresDatabaseMigrationHook implements OnModuleInit {
16✔
17
  private static LOCK_MAGIC_NUMBER = 132;
16✔
18
  private readonly runMigrations: boolean;
19

20
  constructor(
21
    @Inject('DB_INSTANCE') private readonly sql: postgres.Sql,
×
22
    @Inject(PostgresDatabaseMigrator)
23
    private readonly migrator: PostgresDatabaseMigrator,
×
24
    @Inject(LoggingService) private readonly loggingService: ILoggingService,
×
25
    @Inject(IConfigurationService)
26
    private readonly configurationService: IConfigurationService,
×
27
  ) {
28
    this.runMigrations = this.configurationService.getOrThrow<boolean>(
×
29
      'application.runMigrations',
30
    );
31
  }
32

33
  /**
34
   * Function executed when the module is initialized.
35
   *
36
   * This function will check if the migrations are enabled and if so, it will
37
   * acquire a lock to perform a migration. If the lock is not acquired, then
38
   * a migration is being executed by another instance.
39
   *
40
   * If the lock is acquired, the migration will be executed and the lock will
41
   * be released.
42
   */
43
  async onModuleInit(): Promise<void> {
44
    if (!this.runMigrations) {
×
45
      return this.loggingService.info('Database migrations are disabled');
×
46
    }
47

48
    try {
×
49
      this.loggingService.info('Checking migrations');
×
50
      await this.acquireLock();
×
51
      const executed = await this.migrator.migrate();
×
52
      await this.releaseLock();
×
53
      this.loggingService.info(
×
54
        `Pending migrations executed: [${executed.map((m) => m.name).join(', ')}]`,
×
55
      );
56
    } catch (e) {
57
      this.loggingService.error(`Error running migrations: ${asError(e)}`);
×
58
    }
59
  }
60

61
  private async acquireLock(): Promise<void> {
62
    await this
×
63
      .sql`SELECT pg_advisory_lock(${PostgresDatabaseMigrationHook.LOCK_MAGIC_NUMBER})`;
64
  }
65

66
  private async releaseLock(): Promise<void> {
67
    await this
×
68
      .sql`SELECT pg_advisory_unlock(${PostgresDatabaseMigrationHook.LOCK_MAGIC_NUMBER})`;
69
  }
70
}
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

© 2026 Coveralls, Inc