1 |
|
2 | import { TableColumn } from "../schema-builder/table/TableColumn";
|
3 | import { Table } from "../schema-builder/table/Table";
|
4 | import { TableForeignKey } from "../schema-builder/table/TableForeignKey";
|
5 | import { TableIndex } from "../schema-builder/table/TableIndex";
|
6 | import { Connection } from "../connection/Connection";
|
7 | import { ReadStream } from "../platform/PlatformTools";
|
8 | import { EntityManager } from "../entity-manager/EntityManager";
|
9 | import { ObjectLiteral } from "../common/ObjectLiteral";
|
10 | import { SqlInMemory } from "../driver/SqlInMemory";
|
11 | import { TableUnique } from "../schema-builder/table/TableUnique";
|
12 | import { View } from "../schema-builder/view/View";
|
13 | import { Broadcaster } from "../subscriber/Broadcaster";
|
14 | import { TableCheck } from "../schema-builder/table/TableCheck";
|
15 | import { IsolationLevel } from "../driver/types/IsolationLevel";
|
16 | import { TableExclusion } from "../schema-builder/table/TableExclusion";
|
17 |
|
18 |
|
19 |
|
20 | export interface QueryRunner {
|
21 | |
22 |
|
23 |
|
24 | readonly connection: Connection;
|
25 | |
26 |
|
27 |
|
28 | readonly broadcaster: Broadcaster;
|
29 | |
30 |
|
31 |
|
32 | readonly manager: EntityManager;
|
33 | |
34 |
|
35 |
|
36 |
|
37 | readonly isReleased: boolean;
|
38 | |
39 |
|
40 |
|
41 | readonly isTransactionActive: boolean;
|
42 | |
43 |
|
44 |
|
45 |
|
46 | data: ObjectLiteral;
|
47 | |
48 |
|
49 |
|
50 | loadedTables: Table[];
|
51 | |
52 |
|
53 |
|
54 | loadedViews: View[];
|
55 | |
56 |
|
57 |
|
58 |
|
59 | connect(): Promise<any>;
|
60 | |
61 |
|
62 |
|
63 |
|
64 | release(): Promise<void>;
|
65 | |
66 |
|
67 |
|
68 |
|
69 |
|
70 | clearDatabase(database?: string): Promise<void>;
|
71 | |
72 |
|
73 |
|
74 | startTransaction(isolationLevel?: IsolationLevel): Promise<void>;
|
75 | |
76 |
|
77 |
|
78 |
|
79 | commitTransaction(): Promise<void>;
|
80 | |
81 |
|
82 |
|
83 |
|
84 | rollbackTransaction(): Promise<void>;
|
85 | |
86 |
|
87 |
|
88 | query(query: string, parameters?: any[]): Promise<any>;
|
89 | |
90 |
|
91 |
|
92 | stream(query: string, parameters?: any[], onEnd?: Function, onError?: Function): Promise<ReadStream>;
|
93 | |
94 |
|
95 |
|
96 | getDatabases(): Promise<string[]>;
|
97 | |
98 |
|
99 |
|
100 |
|
101 |
|
102 | getSchemas(database?: string): Promise<string[]>;
|
103 | |
104 |
|
105 |
|
106 | getTable(tablePath: string): Promise<Table | undefined>;
|
107 | |
108 |
|
109 |
|
110 |
|
111 |
|
112 | getTables(tablePaths: string[]): Promise<Table[]>;
|
113 | |
114 |
|
115 |
|
116 | getView(viewPath: string): Promise<View | undefined>;
|
117 | |
118 |
|
119 |
|
120 | getViews(viewPaths: string[]): Promise<View[]>;
|
121 | |
122 |
|
123 |
|
124 | hasDatabase(database: string): Promise<boolean>;
|
125 | |
126 |
|
127 |
|
128 | hasSchema(schema: string): Promise<boolean>;
|
129 | |
130 |
|
131 |
|
132 | hasTable(table: Table | string): Promise<boolean>;
|
133 | |
134 |
|
135 |
|
136 | hasColumn(table: Table | string, columnName: string): Promise<boolean>;
|
137 | |
138 |
|
139 |
|
140 | createDatabase(database: string, ifNotExist?: boolean): Promise<void>;
|
141 | |
142 |
|
143 |
|
144 | dropDatabase(database: string, ifExist?: boolean): Promise<void>;
|
145 | |
146 |
|
147 |
|
148 | createSchema(schemaPath: string, ifNotExist?: boolean): Promise<void>;
|
149 | |
150 |
|
151 |
|
152 |
|
153 |
|
154 | dropSchema(schemaPath: string, ifExist?: boolean, isCascade?: boolean): Promise<void>;
|
155 | |
156 |
|
157 |
|
158 | createTable(table: Table, ifNotExist?: boolean, createForeignKeys?: boolean, createIndices?: boolean): Promise<void>;
|
159 | |
160 |
|
161 |
|
162 | dropTable(table: Table | string, ifExist?: boolean, dropForeignKeys?: boolean, dropIndices?: boolean): Promise<void>;
|
163 | |
164 |
|
165 |
|
166 | createView(view: View, oldView?: View): Promise<void>;
|
167 | |
168 |
|
169 |
|
170 | dropView(view: View | string): Promise<void>;
|
171 | |
172 |
|
173 |
|
174 | renameTable(oldTableOrName: Table | string, newTableName: string): Promise<void>;
|
175 | |
176 |
|
177 |
|
178 | addColumn(table: Table | string, column: TableColumn): Promise<void>;
|
179 | |
180 |
|
181 |
|
182 | addColumns(table: Table | string, columns: TableColumn[]): Promise<void>;
|
183 | |
184 |
|
185 |
|
186 | renameColumn(table: Table | string, oldColumnOrName: TableColumn | string, newColumnOrName: TableColumn | string): Promise<void>;
|
187 | |
188 |
|
189 |
|
190 | changeColumn(table: Table | string, oldColumn: TableColumn | string, newColumn: TableColumn): Promise<void>;
|
191 | |
192 |
|
193 |
|
194 | changeColumns(table: Table | string, changedColumns: {
|
195 | oldColumn: TableColumn;
|
196 | newColumn: TableColumn;
|
197 | }[]): Promise<void>;
|
198 | |
199 |
|
200 |
|
201 | dropColumn(table: Table | string, column: TableColumn | string): Promise<void>;
|
202 | |
203 |
|
204 |
|
205 | dropColumns(table: Table | string, columns: TableColumn[]): Promise<void>;
|
206 | |
207 |
|
208 |
|
209 | createPrimaryKey(table: Table | string, columnNames: string[]): Promise<void>;
|
210 | |
211 |
|
212 |
|
213 | updatePrimaryKeys(table: Table | string, columns: TableColumn[]): Promise<void>;
|
214 | |
215 |
|
216 |
|
217 | dropPrimaryKey(table: Table | string): Promise<void>;
|
218 | |
219 |
|
220 |
|
221 | createUniqueConstraint(table: Table | string, uniqueConstraint: TableUnique): Promise<void>;
|
222 | |
223 |
|
224 |
|
225 | createUniqueConstraints(table: Table | string, uniqueConstraints: TableUnique[]): Promise<void>;
|
226 | |
227 |
|
228 |
|
229 | dropUniqueConstraint(table: Table | string, uniqueOrName: TableUnique | string): Promise<void>;
|
230 | |
231 |
|
232 |
|
233 | dropUniqueConstraints(table: Table | string, uniqueConstraints: TableUnique[]): Promise<void>;
|
234 | |
235 |
|
236 |
|
237 | createCheckConstraint(table: Table | string, checkConstraint: TableCheck): Promise<void>;
|
238 | |
239 |
|
240 |
|
241 | createCheckConstraints(table: Table | string, checkConstraints: TableCheck[]): Promise<void>;
|
242 | |
243 |
|
244 |
|
245 | dropCheckConstraint(table: Table | string, checkOrName: TableCheck | string): Promise<void>;
|
246 | |
247 |
|
248 |
|
249 | dropCheckConstraints(table: Table | string, checkConstraints: TableCheck[]): Promise<void>;
|
250 | |
251 |
|
252 |
|
253 | createExclusionConstraint(table: Table | string, exclusionConstraint: TableExclusion): Promise<void>;
|
254 | |
255 |
|
256 |
|
257 | createExclusionConstraints(table: Table | string, exclusionConstraints: TableExclusion[]): Promise<void>;
|
258 | |
259 |
|
260 |
|
261 | dropExclusionConstraint(table: Table | string, exclusionOrName: TableExclusion | string): Promise<void>;
|
262 | |
263 |
|
264 |
|
265 | dropExclusionConstraints(table: Table | string, exclusionConstraints: TableExclusion[]): Promise<void>;
|
266 | |
267 |
|
268 |
|
269 | createForeignKey(table: Table | string, foreignKey: TableForeignKey): Promise<void>;
|
270 | |
271 |
|
272 |
|
273 | createForeignKeys(table: Table | string, foreignKeys: TableForeignKey[]): Promise<void>;
|
274 | |
275 |
|
276 |
|
277 | dropForeignKey(table: Table | string, foreignKeyOrName: TableForeignKey | string): Promise<void>;
|
278 | |
279 |
|
280 |
|
281 | dropForeignKeys(table: Table | string, foreignKeys: TableForeignKey[]): Promise<void>;
|
282 | |
283 |
|
284 |
|
285 | createIndex(table: Table | string, index: TableIndex): Promise<void>;
|
286 | |
287 |
|
288 |
|
289 | createIndices(table: Table | string, indices: TableIndex[]): Promise<void>;
|
290 | |
291 |
|
292 |
|
293 | dropIndex(table: Table | string, index: TableIndex | string): Promise<void>;
|
294 | |
295 |
|
296 |
|
297 | dropIndices(table: Table | string, indices: TableIndex[]): Promise<void>;
|
298 | |
299 |
|
300 |
|
301 |
|
302 | clearTable(tableName: string): Promise<void>;
|
303 | |
304 |
|
305 |
|
306 |
|
307 |
|
308 | enableSqlMemory(): void;
|
309 | |
310 |
|
311 |
|
312 |
|
313 |
|
314 |
|
315 | disableSqlMemory(): void;
|
316 | |
317 |
|
318 |
|
319 | clearSqlMemory(): void;
|
320 | |
321 |
|
322 |
|
323 | getMemorySql(): SqlInMemory;
|
324 | |
325 |
|
326 |
|
327 | executeMemoryUpSql(): Promise<void>;
|
328 | |
329 |
|
330 |
|
331 | executeMemoryDownSql(): Promise<void>;
|
332 | }
|