1 | import emittery from 'emittery';
|
2 | import * as errorCause from 'pony-cause';
|
3 | import type { CommandLineParserOptions } from './cli';
|
4 | import { UmzugCLI } from './cli';
|
5 | import type { MigrateDownOptions, MigrateUpOptions, MigrationMeta, MigrationParams, Resolver, RunnableMigration, UmzugEvents, UmzugOptions } from './types';
|
6 | type MigrationErrorParams = {
|
7 | direction: 'up' | 'down';
|
8 | } & MigrationParams<unknown>;
|
9 | export declare class MigrationError extends errorCause.ErrorWithCause<unknown> {
|
10 | name: string;
|
11 | migration: MigrationErrorParams;
|
12 | jse_cause: unknown;
|
13 | constructor(migration: MigrationErrorParams, original: unknown);
|
14 | get info(): MigrationErrorParams;
|
15 | private static errorString;
|
16 | }
|
17 | export declare class Umzug<Ctx extends object = object> extends emittery<UmzugEvents<Ctx>> {
|
18 | readonly options: UmzugOptions<Ctx>;
|
19 | private readonly storage;
|
20 | readonly migrations: (ctx: Ctx) => Promise<ReadonlyArray<RunnableMigration<Ctx>>>;
|
21 | |
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 | readonly _types: {
|
46 | migration: (params: MigrationParams<Ctx>) => Promise<unknown>;
|
47 | context: Ctx;
|
48 | };
|
49 |
|
50 | constructor(options: UmzugOptions<Ctx>);
|
51 | private logging;
|
52 | static defaultResolver: Resolver<unknown>;
|
53 | /**
|
54 | * Get an UmzugCLI instance. This can be overriden in a subclass to add/remove commands - only use if you really know you need this,
|
55 | * and are OK to learn about/interact with the API of @rushstack/ts-command-line.
|
56 | */
|
57 | protected getCli(options?: CommandLineParserOptions): UmzugCLI;
|
58 | /**
|
59 | * 'Run' an umzug instance as a CLI. This will read `process.argv`, execute commands based on that, and call
|
60 | * `process.exit` after running. If that isn't what you want, stick to the programmatic API.
|
61 | * You probably want to run only if a file is executed as the process's 'main' module with something like:
|
62 | * @example
|
63 | * if (require.main === module) {
|
64 | * myUmzugInstance.runAsCLI()
|
65 | * }
|
66 | */
|
67 | runAsCLI(argv?: string[]): Promise<boolean>;
|
68 |
|
69 | executed(): Promise<MigrationMeta[]>;
|
70 |
|
71 | private _executed;
|
72 |
|
73 | pending(): Promise<MigrationMeta[]>;
|
74 | private _pending;
|
75 | protected runCommand<T>(command: string, cb: (commandParams: {
|
76 | context: Ctx;
|
77 | }) => Promise<T>): Promise<T>;
|
78 | |
79 |
|
80 |
|
81 |
|
82 | up(options?: MigrateUpOptions): Promise<MigrationMeta[]>;
|
83 | |
84 |
|
85 |
|
86 |
|
87 | down(options?: MigrateDownOptions): Promise<MigrationMeta[]>;
|
88 | create(options: {
|
89 | name: string;
|
90 | folder?: string;
|
91 | prefix?: 'TIMESTAMP' | 'DATE' | 'NONE';
|
92 | allowExtension?: string;
|
93 | allowConfusingOrdering?: boolean;
|
94 | skipVerify?: boolean;
|
95 |
|
96 | content?: string;
|
97 | }): Promise<void>;
|
98 | private static defaultCreationTemplate;
|
99 | private findNameIndex;
|
100 | private findMigrations;
|
101 | private getContext;
|
102 |
|
103 | private getMigrationsResolver;
|
104 | }
|
105 | export {};
|