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

typeorm / typeorm / 19549987525

20 Nov 2025 08:11PM UTC coverage: 80.769% (+4.3%) from 76.433%
19549987525

push

github

web-flow
ci: run tests on commits to master and next (#11783)

Co-authored-by: Oleg "OSA413" Sokolov <OSA413@users.noreply.github.com>

26500 of 32174 branches covered (82.36%)

Branch coverage included in aggregate %.

91252 of 113615 relevant lines covered (80.32%)

88980.79 hits per line

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

20.88
/src/commands/MigrationRunCommand.ts
1
import path from "path"
26✔
2
import * as process from "process"
26✔
3
import * as yargs from "yargs"
26✔
4
import { PlatformTools } from "../platform/PlatformTools"
26✔
5
import { DataSource } from "../data-source"
26✔
6
import { CommandUtils } from "./CommandUtils"
26✔
7

26✔
8
/**
26✔
9
 * Runs migration command.
26✔
10
 */
26✔
11
export class MigrationRunCommand implements yargs.CommandModule {
208✔
12
    command = "migration:run"
208✔
13
    describe = "Runs all pending migrations."
208✔
14

208✔
15
    builder(args: yargs.Argv) {
208✔
16
        return args
×
17
            .option("dataSource", {
×
18
                alias: "d",
×
19
                describe:
×
20
                    "Path to the file where your DataSource instance is defined.",
×
21
                demandOption: true,
×
22
            })
×
23
            .option("transaction", {
×
24
                alias: "t",
×
25
                default: "default",
×
26
                describe:
×
27
                    "Indicates if transaction should be used or not for migration run. Enabled by default.",
×
28
            })
×
29
            .option("fake", {
×
30
                alias: "f",
×
31
                type: "boolean",
×
32
                default: false,
×
33
                describe:
×
34
                    "Fakes running the migrations if table schema has already been changed manually or externally " +
×
35
                    "(e.g. through another project)",
×
36
            })
×
37
    }
×
38

208✔
39
    async handler(args: yargs.Arguments) {
208✔
40
        let dataSource: DataSource | undefined = undefined
×
41
        try {
×
42
            dataSource = await CommandUtils.loadDataSource(
×
43
                path.resolve(process.cwd(), args.dataSource as string),
×
44
            )
×
45
            dataSource.setOptions({
×
46
                subscribers: [],
×
47
                synchronize: false,
×
48
                migrationsRun: false,
×
49
                dropSchema: false,
×
50
                logging: ["query", "error", "schema"],
×
51
            })
×
52
            await dataSource.initialize()
×
53

×
54
            const options = {
×
55
                transaction:
×
56
                    dataSource.options.migrationsTransactionMode ??
×
57
                    ("all" as "all" | "none" | "each"),
×
58
                fake: !!args.f,
×
59
            }
×
60

×
61
            switch (args.t) {
×
62
                case "all":
×
63
                    options.transaction = "all"
×
64
                    break
×
65
                case "none":
×
66
                case "false":
×
67
                    options.transaction = "none"
×
68
                    break
×
69
                case "each":
×
70
                    options.transaction = "each"
×
71
                    break
×
72
                default:
×
73
                // noop
×
74
            }
×
75

×
76
            await dataSource.runMigrations(options)
×
77
            await dataSource.destroy()
×
78

×
79
            // exit process if no errors
×
80
            process.exit(0)
×
81
        } catch (err) {
×
82
            PlatformTools.logCmdErr("Error during migration run:", err)
×
83

×
84
            if (dataSource && dataSource.isInitialized)
×
85
                await dataSource.destroy()
×
86

×
87
            process.exit(1)
×
88
        }
×
89
    }
×
90
}
208✔
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