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

GEWIS / sudosos-backend / 25753937432

12 May 2026 09:17AM UTC coverage: 88.117% (-1.0%) from 89.089%
25753937432

push

github

web-flow
chore(deps): fix missing dependencies for running docs:dev (#911)

3925 of 4574 branches covered (85.81%)

Branch coverage included in aggregate %.

20093 of 22683 relevant lines covered (88.58%)

1125.83 hits per line

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

0.0
/src/database/migrate.ts
1
/**
×
2
 *  SudoSOS back-end API service.
3
 *  Copyright (C) 2026 Study association GEWIS
4
 *
5
 *  This program is free software: you can redistribute it and/or modify
6
 *  it under the terms of the GNU Affero General Public License as published
7
 *  by the Free Software Foundation, either version 3 of the License, or
8
 *  (at your option) any later version.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU Affero General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU Affero General Public License
16
 *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
17
 *
18
 *  @license
19
 */
×
20

21
/**
×
22
 * This is the module page of migrate.
23
 *
24
 * @module internal/migrations
25
 * @mergeTarget
26
 */
×
27

28
import { Application } from '../index';
29
import log4js from 'log4js';
30
import Database from './database';
31
import Config from '../config';
32
import { applyConfiguredLogLevel } from '../helpers/logging';
33

34
export default async function migrate() {
×
35
  const application = new Application();
×
36
  application.logger = log4js.getLogger('Migration');
×
37
  applyConfiguredLogLevel(application.logger);
×
38
  application.logger.info('Starting Migrator');
×
39

40
  application.connection = await Database.initialize();
×
41

42
  // Silent in-dependency logs unless really wanted by the environment.
×
43
  const logger = log4js.getLogger('Console');
×
44
  applyConfiguredLogLevel(logger);
×
45
  console.log = (message: any, ...additional: any[]) => logger.debug(message, ...additional);
×
46

47
  try {
×
48
    application.logger.log('Starting migrations.');
×
49
    await application.connection.runMigrations({ transaction: 'all' });
×
50
    await application.connection.destroy();
×
51
    application.logger.log('Finished migrations.');
×
52
  } catch (e) {
×
53
    application.logger.error('Error migrating db', e);
×
54
  }
×
55
}
×
56

57
if (require.main === module) {
×
58
  // Only execute the application directly if this is the main execution file.
×
59
  if (Config.get().database.isSqlite) console.warn('Migrations in sqlite most likely have no effect.');
×
60
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
×
61
  migrate();
×
62
}
×
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