forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
umzug.d.ts
194 lines (150 loc) · 5.43 KB
/
umzug.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
// Type definitions for Umzug v1.8.0
// Project: https://github.com/sequelize/umzug
// Definitions by: Ivan Drinchev <https://github.com/drinchev/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../bluebird/bluebird.d.ts" />
/// <reference path="../sequelize/sequelize.d.ts" />
declare module "umzug" {
import Sequelize = require("sequelize");
module umzug {
interface MigrationOptions {
/*
* The params that gets passed to the migrations.
* Might be an array or a synchronous function which returns an array.
*/
params?: Array<any>;
/** The path to the migrations directory. */
path?: string;
/** The pattern that determines whether or not a file is a migration. */
pattern?: RegExp;
/**
* A function that receives and returns the to be executed function.
* This can be used to modify the function.
*/
wrap?: <T>( fn : T ) => T;
}
interface JSONStorageOptions {
/**
* The path to the json storage.
* Defaults to process.cwd() + '/umzug.json';
*/
path?: string;
}
interface SequelizeStorageOptions {
/**
* The configured instance of Sequelize.
* Optional if `model` is passed.
*/
sequelize?: Sequelize.Sequelize;
/**
* The to be used Sequelize model.
* Must have column name matching `columnName` option
* Optional of `sequelize` is passed.
*/
model?: Sequelize.Model<any, any>;
/**
* The name of the to be used model.
* Defaults to 'SequelizeMeta'
*/
modelName?: string;
/**
* The name of table to create if `model` option is not supplied
* Defaults to `modelName`
*/
tableName?: string;
/**
* The name of table column holding migration name.
* Defaults to 'name'.
*/
columnName: string;
/**
* The type of the column holding migration name.
* Defaults to `Sequelize.STRING`
*/
columnType: Sequelize.DataTypeAbstract;
}
interface ExecuteOptions {
migrations?: Array<string>;
method?: string;
}
interface UmzugOptions {
/**
* The storage.
* Possible values: 'json', 'sequelize', an object
*/
storage?: string;
/**
* The options for the storage.
*/
storageOptions?: JSONStorageOptions | SequelizeStorageOptions | Object;
/**
* The logging function.
* A function that gets executed everytime migrations start and have ended.
*/
logging? : boolean | Function;
/**
* The name of the positive method in migrations.
*/
upName? : string;
/**
* The name of the negative method in migrations.
*/
downName? : string;
/**
* Options for defined migration
*/
migrations? : MigrationOptions;
}
interface UpDownToOptions {
/**
* It is also possible to pass the name of a migration in order to
* just run the migrations from the current state to the passed
* migration name.
*/
to: string;
}
interface UpDownMigrationsOptions {
/**
* Running specific migrations while ignoring the right order, can be
* done like this:
*/
migrations: Array<string>;
}
interface Migration {
path: string;
file: string;
}
interface Umzug {
/**
* The execute method is a general purpose function that runs for
* every specified migrations the respective function.
*/
execute(options? : ExecuteOptions) : Promise<Migration[]>;
/**
* You can get a list of pending/not yet executed migrations like this:
*/
pending() : Promise<Migration[]>;
/**
* You can get a list of already executed migrations like this:
*/
executed() : Promise<Migration[]>;
/**
* The up method can be used to execute all pending migrations.
*/
up(migration?: string) : Promise<Migration[]>;
up(migrations?: string[]) : Promise<Migration[]>;
up(options?: UpDownToOptions | UpDownMigrationsOptions ) : Promise<Migration[]>;
/**
* The down method can be used to revert the last executed migration.
*/
down(migration?: string) : Promise<Migration[]>;
down(migrations?: string[]) : Promise<Migration[]>;
down(options?: UpDownToOptions | UpDownMigrationsOptions ) : Promise<Migration[]>;
}
interface UmzugStatic {
new (options?: UmzugOptions) : Umzug;
}
}
var umzug : umzug.UmzugStatic;
export = umzug;
}