rake-db 2.3.30 → 2.3.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +10 -22
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -22
- package/.env +0 -1
- package/.env.local +0 -2
- package/.turbo/turbo-check.log +0 -23
- package/.turbo/turbo-test.log +0 -22
- package/.turbo/turbo-test:ci.log +0 -22
- package/CHANGELOG.md +0 -395
- package/app/dbScript.ts +0 -33
- package/app/migrations/20221017181504_createUser.ts +0 -14
- package/app/migrations/20221017200111_createProfile.ts +0 -10
- package/app/migrations/20221017200252_createChat.ts +0 -9
- package/app/migrations/20221017200326_createChatUser.ts +0 -10
- package/app/migrations/20221017200900_createMessage.ts +0 -12
- package/app/migrations/20221017201235_createGeoSchema.ts +0 -5
- package/app/migrations/20221017210011_createCountry.ts +0 -8
- package/app/migrations/20221017210133_createCity.ts +0 -9
- package/app/migrations/20221105202843_createUniqueTable.ts +0 -12
- package/jest-setup.ts +0 -3
- package/rollup.config.js +0 -3
- package/src/ast.ts +0 -130
- package/src/commands/createOrDrop.test.ts +0 -214
- package/src/commands/createOrDrop.ts +0 -151
- package/src/commands/generate.test.ts +0 -136
- package/src/commands/generate.ts +0 -93
- package/src/commands/migrateOrRollback.test.ts +0 -267
- package/src/commands/migrateOrRollback.ts +0 -190
- package/src/common.test.ts +0 -295
- package/src/common.ts +0 -353
- package/src/errors.ts +0 -3
- package/src/index.ts +0 -8
- package/src/migration/change.test.ts +0 -16
- package/src/migration/change.ts +0 -15
- package/src/migration/changeTable.test.ts +0 -897
- package/src/migration/changeTable.ts +0 -566
- package/src/migration/createTable.test.ts +0 -384
- package/src/migration/createTable.ts +0 -193
- package/src/migration/migration.test.ts +0 -430
- package/src/migration/migration.ts +0 -518
- package/src/migration/migrationUtils.ts +0 -307
- package/src/migration/tableMethods.ts +0 -8
- package/src/pull/astToMigration.test.ts +0 -275
- package/src/pull/astToMigration.ts +0 -173
- package/src/pull/dbStructure.test.ts +0 -180
- package/src/pull/dbStructure.ts +0 -413
- package/src/pull/pull.test.ts +0 -115
- package/src/pull/pull.ts +0 -22
- package/src/pull/structureToAst.test.ts +0 -841
- package/src/pull/structureToAst.ts +0 -372
- package/src/rakeDb.test.ts +0 -131
- package/src/rakeDb.ts +0 -84
- package/src/test-utils.ts +0 -64
- package/tsconfig.json +0 -12
|
@@ -1,897 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
asMock,
|
|
3
|
-
expectSql,
|
|
4
|
-
getDb,
|
|
5
|
-
queryMock,
|
|
6
|
-
resetDb,
|
|
7
|
-
setDbDown,
|
|
8
|
-
toLine,
|
|
9
|
-
} from '../test-utils';
|
|
10
|
-
|
|
11
|
-
const db = getDb();
|
|
12
|
-
|
|
13
|
-
describe('changeTable', () => {
|
|
14
|
-
beforeEach(resetDb);
|
|
15
|
-
|
|
16
|
-
it('should call appCodeUpdater', async () => {
|
|
17
|
-
await db.changeTable('name', () => ({}));
|
|
18
|
-
|
|
19
|
-
expect(db.options.appCodeUpdater).toHaveBeenCalled();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('should work for table with schema', async () => {
|
|
23
|
-
const fn = () => {
|
|
24
|
-
return db.changeTable('schema.table', (t) => ({
|
|
25
|
-
column: t.add(t.text()),
|
|
26
|
-
}));
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
await fn();
|
|
30
|
-
expectSql(
|
|
31
|
-
`ALTER TABLE "schema"."table"\nADD COLUMN "column" text NOT NULL`,
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
setDbDown();
|
|
35
|
-
await fn();
|
|
36
|
-
expectSql(`ALTER TABLE "schema"."table"\nDROP COLUMN "column"`);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('should set comment', async () => {
|
|
40
|
-
const fn = () => {
|
|
41
|
-
return db.changeTable('table', { comment: 'comment' });
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
await fn();
|
|
45
|
-
expectSql(`COMMENT ON TABLE "table" IS 'comment'`);
|
|
46
|
-
|
|
47
|
-
setDbDown();
|
|
48
|
-
await fn();
|
|
49
|
-
expectSql(`COMMENT ON TABLE "table" IS NULL`);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('should change comment', async () => {
|
|
53
|
-
const fn = () => {
|
|
54
|
-
return db.changeTable('table', { comment: ['old', 'new'] });
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
await fn();
|
|
58
|
-
expectSql(`COMMENT ON TABLE "table" IS 'new'`);
|
|
59
|
-
|
|
60
|
-
setDbDown();
|
|
61
|
-
await fn();
|
|
62
|
-
expectSql(`COMMENT ON TABLE "table" IS 'old'`);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
(['add', 'drop'] as const).forEach((action) => {
|
|
66
|
-
it(`should ${action} columns ${
|
|
67
|
-
action === 'add' ? 'to' : 'from'
|
|
68
|
-
} table`, async () => {
|
|
69
|
-
const fn = () => {
|
|
70
|
-
return db.changeTable('table', (t) => ({
|
|
71
|
-
id: t[action](t.serial().primaryKey()),
|
|
72
|
-
dropCascade: t[action](t.text(), { dropMode: 'CASCADE' }),
|
|
73
|
-
nullable: t[action](t.text().nullable()),
|
|
74
|
-
nonNullable: t[action](t.text()),
|
|
75
|
-
withDefault: t[action](t.boolean().default(false)),
|
|
76
|
-
withDefaultRaw: t[action](t.date().default(t.raw(`now()`))),
|
|
77
|
-
varcharWithLength: t[action](t.varchar(20)),
|
|
78
|
-
decimalWithPrecisionAndScale: t[action](t.decimal(10, 5)),
|
|
79
|
-
columnWithCompression: t[action](t.text().compression('compression')),
|
|
80
|
-
columnWithCollate: t[action](t.text().collate('utf-8')),
|
|
81
|
-
columnWithForeignKey: t[action](
|
|
82
|
-
t.integer().foreignKey('table', 'column', {
|
|
83
|
-
name: 'fkeyConstraint',
|
|
84
|
-
match: 'FULL',
|
|
85
|
-
onUpdate: 'CASCADE',
|
|
86
|
-
onDelete: 'CASCADE',
|
|
87
|
-
}),
|
|
88
|
-
),
|
|
89
|
-
...t[action](t.timestamps()),
|
|
90
|
-
}));
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const expectAddColumns = () => {
|
|
94
|
-
expectSql([
|
|
95
|
-
`
|
|
96
|
-
ALTER TABLE "table"
|
|
97
|
-
ADD COLUMN "id" serial PRIMARY KEY,
|
|
98
|
-
ADD COLUMN "dropCascade" text NOT NULL,
|
|
99
|
-
ADD COLUMN "nullable" text,
|
|
100
|
-
ADD COLUMN "nonNullable" text NOT NULL,
|
|
101
|
-
ADD COLUMN "withDefault" boolean NOT NULL DEFAULT false,
|
|
102
|
-
ADD COLUMN "withDefaultRaw" date NOT NULL DEFAULT now(),
|
|
103
|
-
ADD COLUMN "varcharWithLength" varchar(20) NOT NULL,
|
|
104
|
-
ADD COLUMN "decimalWithPrecisionAndScale" decimal(10, 5) NOT NULL,
|
|
105
|
-
ADD COLUMN "columnWithCompression" text COMPRESSION compression NOT NULL,
|
|
106
|
-
ADD COLUMN "columnWithCollate" text COLLATE 'utf-8' NOT NULL,
|
|
107
|
-
ADD COLUMN "columnWithForeignKey" integer NOT NULL CONSTRAINT "fkeyConstraint" REFERENCES "table"("column") MATCH FULL ON DELETE CASCADE ON UPDATE CASCADE,
|
|
108
|
-
ADD COLUMN "createdAt" timestamp NOT NULL DEFAULT now(),
|
|
109
|
-
ADD COLUMN "updatedAt" timestamp NOT NULL DEFAULT now()
|
|
110
|
-
`,
|
|
111
|
-
]);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const expectRemoveColumns = () => {
|
|
115
|
-
expectSql([
|
|
116
|
-
`
|
|
117
|
-
ALTER TABLE "table"
|
|
118
|
-
DROP COLUMN "id",
|
|
119
|
-
DROP COLUMN "dropCascade" CASCADE,
|
|
120
|
-
DROP COLUMN "nullable",
|
|
121
|
-
DROP COLUMN "nonNullable",
|
|
122
|
-
DROP COLUMN "withDefault",
|
|
123
|
-
DROP COLUMN "withDefaultRaw",
|
|
124
|
-
DROP COLUMN "varcharWithLength",
|
|
125
|
-
DROP COLUMN "decimalWithPrecisionAndScale",
|
|
126
|
-
DROP COLUMN "columnWithCompression",
|
|
127
|
-
DROP COLUMN "columnWithCollate",
|
|
128
|
-
DROP COLUMN "columnWithForeignKey",
|
|
129
|
-
DROP COLUMN "createdAt",
|
|
130
|
-
DROP COLUMN "updatedAt"
|
|
131
|
-
`,
|
|
132
|
-
]);
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
asMock(queryMock).mockResolvedValue({ rows: [['one'], ['two']] });
|
|
136
|
-
|
|
137
|
-
await fn();
|
|
138
|
-
(action === 'add' ? expectAddColumns : expectRemoveColumns)();
|
|
139
|
-
|
|
140
|
-
queryMock.mockClear();
|
|
141
|
-
db.up = false;
|
|
142
|
-
|
|
143
|
-
await fn();
|
|
144
|
-
|
|
145
|
-
(action === 'add' ? expectRemoveColumns : expectAddColumns)();
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it(`should ${action} index`, async () => {
|
|
149
|
-
const fn = () => {
|
|
150
|
-
return db.changeTable('table', (t) => ({
|
|
151
|
-
withIndex: t[action](
|
|
152
|
-
t.text().index({
|
|
153
|
-
name: 'indexName',
|
|
154
|
-
unique: true,
|
|
155
|
-
using: 'gin',
|
|
156
|
-
collate: 'utf-8',
|
|
157
|
-
opclass: 'opclass',
|
|
158
|
-
order: 'ASC',
|
|
159
|
-
include: 'id',
|
|
160
|
-
with: 'fillfactor = 70',
|
|
161
|
-
tablespace: 'tablespace',
|
|
162
|
-
where: 'column = 123',
|
|
163
|
-
}),
|
|
164
|
-
),
|
|
165
|
-
}));
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
const expectAdd = () => {
|
|
169
|
-
expectSql([
|
|
170
|
-
`ALTER TABLE "table"
|
|
171
|
-
ADD COLUMN "withIndex" text NOT NULL`,
|
|
172
|
-
toLine(`
|
|
173
|
-
CREATE UNIQUE INDEX "indexName"
|
|
174
|
-
ON "table"
|
|
175
|
-
USING gin
|
|
176
|
-
("withIndex" COLLATE 'utf-8' opclass ASC)
|
|
177
|
-
INCLUDE ("id")
|
|
178
|
-
WITH (fillfactor = 70)
|
|
179
|
-
TABLESPACE tablespace
|
|
180
|
-
WHERE column = 123
|
|
181
|
-
`),
|
|
182
|
-
]);
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
const expectRemove = () => {
|
|
186
|
-
expectSql([
|
|
187
|
-
`ALTER TABLE "table"
|
|
188
|
-
DROP COLUMN "withIndex"`,
|
|
189
|
-
toLine(`DROP INDEX "indexName"`),
|
|
190
|
-
]);
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
asMock(queryMock).mockResolvedValue({ rows: [['one'], ['two']] });
|
|
194
|
-
|
|
195
|
-
await fn();
|
|
196
|
-
(action === 'add' ? expectAdd : expectRemove)();
|
|
197
|
-
|
|
198
|
-
queryMock.mockClear();
|
|
199
|
-
db.up = false;
|
|
200
|
-
|
|
201
|
-
await fn();
|
|
202
|
-
|
|
203
|
-
(action === 'add' ? expectRemove : expectAdd)();
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
it(`should ${action} unique index`, async () => {
|
|
207
|
-
const fn = () => {
|
|
208
|
-
return db.changeTable('table', (t) => ({
|
|
209
|
-
uniqueColumn: t[action](t.text().unique({ dropMode: 'CASCADE' })),
|
|
210
|
-
}));
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
const expectAdd = () => {
|
|
214
|
-
expectSql([
|
|
215
|
-
`ALTER TABLE "table"
|
|
216
|
-
ADD COLUMN "uniqueColumn" text NOT NULL`,
|
|
217
|
-
toLine(`
|
|
218
|
-
CREATE UNIQUE INDEX "table_uniqueColumn_idx"
|
|
219
|
-
ON "table"
|
|
220
|
-
("uniqueColumn")
|
|
221
|
-
`),
|
|
222
|
-
]);
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
const expectRemove = () => {
|
|
226
|
-
expectSql([
|
|
227
|
-
`ALTER TABLE "table"
|
|
228
|
-
DROP COLUMN "uniqueColumn"`,
|
|
229
|
-
toLine(`DROP INDEX "table_uniqueColumn_idx" CASCADE`),
|
|
230
|
-
]);
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
asMock(queryMock).mockResolvedValue({ rows: [['one'], ['two']] });
|
|
234
|
-
|
|
235
|
-
await fn();
|
|
236
|
-
(action === 'add' ? expectAdd : expectRemove)();
|
|
237
|
-
|
|
238
|
-
queryMock.mockClear();
|
|
239
|
-
db.up = false;
|
|
240
|
-
|
|
241
|
-
await fn();
|
|
242
|
-
|
|
243
|
-
(action === 'add' ? expectRemove : expectAdd)();
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
it(`should ${action} column comment`, async () => {
|
|
247
|
-
const fn = () => {
|
|
248
|
-
return db.changeTable('table', (t) => ({
|
|
249
|
-
columnWithComment: t[action](
|
|
250
|
-
t.text().comment('this is a column comment'),
|
|
251
|
-
),
|
|
252
|
-
}));
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
const expectAdd = () => {
|
|
256
|
-
expectSql([
|
|
257
|
-
`ALTER TABLE "table"
|
|
258
|
-
ADD COLUMN "columnWithComment" text NOT NULL`,
|
|
259
|
-
`COMMENT ON COLUMN "table"."columnWithComment" IS 'this is a column comment'`,
|
|
260
|
-
]);
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
const expectRemove = () => {
|
|
264
|
-
expectSql(
|
|
265
|
-
`ALTER TABLE "table"
|
|
266
|
-
DROP COLUMN "columnWithComment"`,
|
|
267
|
-
);
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
asMock(queryMock).mockResolvedValue({ rows: [['one'], ['two']] });
|
|
271
|
-
|
|
272
|
-
await fn();
|
|
273
|
-
(action === 'add' ? expectAdd : expectRemove)();
|
|
274
|
-
|
|
275
|
-
queryMock.mockClear();
|
|
276
|
-
db.up = false;
|
|
277
|
-
|
|
278
|
-
await fn();
|
|
279
|
-
|
|
280
|
-
(action === 'add' ? expectRemove : expectAdd)();
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
it(`should ${action} enum`, async () => {
|
|
284
|
-
const fn = () => {
|
|
285
|
-
return db.changeTable('table', (t) => ({
|
|
286
|
-
enum: t[action](t.enum('mood')),
|
|
287
|
-
}));
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
const expectAdd = () => {
|
|
291
|
-
expectSql([
|
|
292
|
-
'SELECT unnest(enum_range(NULL::"mood"))::text',
|
|
293
|
-
`
|
|
294
|
-
ALTER TABLE "table"
|
|
295
|
-
ADD COLUMN "enum" "mood" NOT NULL
|
|
296
|
-
`,
|
|
297
|
-
]);
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
const expectRemove = () => {
|
|
301
|
-
expectSql([
|
|
302
|
-
'SELECT unnest(enum_range(NULL::"mood"))::text',
|
|
303
|
-
`
|
|
304
|
-
ALTER TABLE "table"
|
|
305
|
-
DROP COLUMN "enum"
|
|
306
|
-
`,
|
|
307
|
-
]);
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
asMock(queryMock).mockResolvedValue({ rows: [['one'], ['two']] });
|
|
311
|
-
|
|
312
|
-
await fn();
|
|
313
|
-
|
|
314
|
-
(action === 'add' ? expectAdd : expectRemove)();
|
|
315
|
-
|
|
316
|
-
const [{ ast: ast1 }] = asMock(db.options.appCodeUpdater).mock.calls[0];
|
|
317
|
-
expect(ast1.shape.enum.item.options).toEqual(['one', 'two']);
|
|
318
|
-
|
|
319
|
-
queryMock.mockClear();
|
|
320
|
-
asMock(db.options.appCodeUpdater).mockClear();
|
|
321
|
-
db.up = false;
|
|
322
|
-
|
|
323
|
-
await fn();
|
|
324
|
-
|
|
325
|
-
(action === 'add' ? expectRemove : expectAdd)();
|
|
326
|
-
|
|
327
|
-
const [{ ast: ast2 }] = asMock(db.options.appCodeUpdater).mock.calls[0];
|
|
328
|
-
expect(ast2.shape.enum.item.options).toEqual(['one', 'two']);
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
it(`should ${action} columns with a primary key`, async () => {
|
|
332
|
-
const fn = () => {
|
|
333
|
-
return db.changeTable('table', (t) => ({
|
|
334
|
-
id: t[action](t.integer().primaryKey()),
|
|
335
|
-
text: t[action](t.text().primaryKey()),
|
|
336
|
-
active: t[action](t.boolean().primaryKey()),
|
|
337
|
-
}));
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
const expectAddColumns = () => {
|
|
341
|
-
expectSql([
|
|
342
|
-
`
|
|
343
|
-
ALTER TABLE "table"
|
|
344
|
-
ADD COLUMN "id" integer NOT NULL,
|
|
345
|
-
ADD COLUMN "text" text NOT NULL,
|
|
346
|
-
ADD COLUMN "active" boolean NOT NULL,
|
|
347
|
-
ADD PRIMARY KEY ("id", "text", "active")
|
|
348
|
-
`,
|
|
349
|
-
]);
|
|
350
|
-
};
|
|
351
|
-
|
|
352
|
-
const expectRemoveColumns = () => {
|
|
353
|
-
expectSql(`
|
|
354
|
-
ALTER TABLE "table"
|
|
355
|
-
DROP CONSTRAINT "table_pkey",
|
|
356
|
-
DROP COLUMN "id",
|
|
357
|
-
DROP COLUMN "text",
|
|
358
|
-
DROP COLUMN "active"
|
|
359
|
-
`);
|
|
360
|
-
};
|
|
361
|
-
|
|
362
|
-
await fn();
|
|
363
|
-
(action === 'add' ? expectAddColumns : expectRemoveColumns)();
|
|
364
|
-
|
|
365
|
-
queryMock.mockClear();
|
|
366
|
-
db.up = false;
|
|
367
|
-
await fn();
|
|
368
|
-
(action === 'add' ? expectRemoveColumns : expectAddColumns)();
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
it(`should ${action} composite primary key`, async () => {
|
|
372
|
-
const fn = () => {
|
|
373
|
-
return db.changeTable('table', (t) => ({
|
|
374
|
-
...t[action](t.primaryKey(['id', 'name'])),
|
|
375
|
-
}));
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
const expectAddPrimaryKey = () => {
|
|
379
|
-
expectSql(`
|
|
380
|
-
ALTER TABLE "table"
|
|
381
|
-
ADD PRIMARY KEY ("id", "name")
|
|
382
|
-
`);
|
|
383
|
-
};
|
|
384
|
-
|
|
385
|
-
const expectDropPrimaryKey = () => {
|
|
386
|
-
expectSql(`
|
|
387
|
-
ALTER TABLE "table"
|
|
388
|
-
DROP CONSTRAINT "table_pkey"
|
|
389
|
-
`);
|
|
390
|
-
};
|
|
391
|
-
|
|
392
|
-
await fn();
|
|
393
|
-
(action === 'add' ? expectAddPrimaryKey : expectDropPrimaryKey)();
|
|
394
|
-
|
|
395
|
-
db.up = false;
|
|
396
|
-
queryMock.mockClear();
|
|
397
|
-
await fn();
|
|
398
|
-
(action === 'add' ? expectDropPrimaryKey : expectAddPrimaryKey)();
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
it(`should ${action} composite primary key with constraint name`, async () => {
|
|
402
|
-
const fn = () => {
|
|
403
|
-
return db.changeTable('table', (t) => ({
|
|
404
|
-
...t[action](
|
|
405
|
-
t.primaryKey(['id', 'name'], { name: 'primaryKeyName' }),
|
|
406
|
-
),
|
|
407
|
-
}));
|
|
408
|
-
};
|
|
409
|
-
|
|
410
|
-
const expectAddPrimaryKey = () => {
|
|
411
|
-
expectSql(`
|
|
412
|
-
ALTER TABLE "table"
|
|
413
|
-
ADD CONSTRAINT "primaryKeyName" PRIMARY KEY ("id", "name")
|
|
414
|
-
`);
|
|
415
|
-
};
|
|
416
|
-
|
|
417
|
-
const expectDropPrimaryKey = () => {
|
|
418
|
-
expectSql(`
|
|
419
|
-
ALTER TABLE "table"
|
|
420
|
-
DROP CONSTRAINT "primaryKeyName"
|
|
421
|
-
`);
|
|
422
|
-
};
|
|
423
|
-
|
|
424
|
-
await fn();
|
|
425
|
-
(action === 'add' ? expectAddPrimaryKey : expectDropPrimaryKey)();
|
|
426
|
-
|
|
427
|
-
db.up = false;
|
|
428
|
-
queryMock.mockClear();
|
|
429
|
-
await fn();
|
|
430
|
-
(action === 'add' ? expectDropPrimaryKey : expectAddPrimaryKey)();
|
|
431
|
-
});
|
|
432
|
-
|
|
433
|
-
it(`should ${action} composite index`, async () => {
|
|
434
|
-
const fn = () => {
|
|
435
|
-
return db.changeTable('table', (t) => ({
|
|
436
|
-
...t[action](
|
|
437
|
-
t.index(['id', { column: 'name', order: 'DESC' }], {
|
|
438
|
-
name: 'compositeIndexOnTable',
|
|
439
|
-
dropMode: 'CASCADE',
|
|
440
|
-
}),
|
|
441
|
-
),
|
|
442
|
-
}));
|
|
443
|
-
};
|
|
444
|
-
|
|
445
|
-
const expectCreateIndex = () => {
|
|
446
|
-
expectSql(`
|
|
447
|
-
CREATE INDEX "compositeIndexOnTable" ON "table" ("id", "name" DESC)
|
|
448
|
-
`);
|
|
449
|
-
};
|
|
450
|
-
|
|
451
|
-
const expectDropIndex = () => {
|
|
452
|
-
expectSql(`
|
|
453
|
-
DROP INDEX "compositeIndexOnTable" CASCADE
|
|
454
|
-
`);
|
|
455
|
-
};
|
|
456
|
-
|
|
457
|
-
await fn();
|
|
458
|
-
(action === 'add' ? expectCreateIndex : expectDropIndex)();
|
|
459
|
-
|
|
460
|
-
db.up = false;
|
|
461
|
-
queryMock.mockClear();
|
|
462
|
-
await fn();
|
|
463
|
-
(action === 'add' ? expectDropIndex : expectCreateIndex)();
|
|
464
|
-
});
|
|
465
|
-
|
|
466
|
-
it(`should ${action} composite unique index`, async () => {
|
|
467
|
-
const fn = () => {
|
|
468
|
-
return db.changeTable('table', (t) => ({
|
|
469
|
-
...t[action](
|
|
470
|
-
t.unique(['id', { column: 'name', order: 'DESC' }], {
|
|
471
|
-
name: 'compositeIndexOnTable',
|
|
472
|
-
dropMode: 'CASCADE',
|
|
473
|
-
}),
|
|
474
|
-
),
|
|
475
|
-
}));
|
|
476
|
-
};
|
|
477
|
-
|
|
478
|
-
const expectCreateIndex = () => {
|
|
479
|
-
expectSql(`
|
|
480
|
-
CREATE UNIQUE INDEX "compositeIndexOnTable" ON "table" ("id", "name" DESC)
|
|
481
|
-
`);
|
|
482
|
-
};
|
|
483
|
-
|
|
484
|
-
const expectDropIndex = () => {
|
|
485
|
-
expectSql(`
|
|
486
|
-
DROP INDEX "compositeIndexOnTable" CASCADE
|
|
487
|
-
`);
|
|
488
|
-
};
|
|
489
|
-
|
|
490
|
-
await fn();
|
|
491
|
-
(action === 'add' ? expectCreateIndex : expectDropIndex)();
|
|
492
|
-
|
|
493
|
-
db.up = false;
|
|
494
|
-
queryMock.mockClear();
|
|
495
|
-
await fn();
|
|
496
|
-
(action === 'add' ? expectDropIndex : expectCreateIndex)();
|
|
497
|
-
});
|
|
498
|
-
|
|
499
|
-
it(`should ${action} composite foreign key`, async () => {
|
|
500
|
-
const fn = () => {
|
|
501
|
-
return db.changeTable('table', (t) => ({
|
|
502
|
-
...t[action](
|
|
503
|
-
t.foreignKey(
|
|
504
|
-
['id', 'name'],
|
|
505
|
-
'otherTable',
|
|
506
|
-
['foreignId', 'foreignName'],
|
|
507
|
-
{
|
|
508
|
-
name: 'constraintName',
|
|
509
|
-
match: 'FULL',
|
|
510
|
-
onUpdate: 'CASCADE',
|
|
511
|
-
onDelete: 'CASCADE',
|
|
512
|
-
dropMode: 'CASCADE',
|
|
513
|
-
},
|
|
514
|
-
),
|
|
515
|
-
),
|
|
516
|
-
}));
|
|
517
|
-
};
|
|
518
|
-
|
|
519
|
-
const expectedConstraint = toLine(`
|
|
520
|
-
ADD CONSTRAINT "constraintName"
|
|
521
|
-
FOREIGN KEY ("id", "name")
|
|
522
|
-
REFERENCES "otherTable"("foreignId", "foreignName")
|
|
523
|
-
MATCH FULL
|
|
524
|
-
ON DELETE CASCADE
|
|
525
|
-
ON UPDATE CASCADE
|
|
526
|
-
`);
|
|
527
|
-
|
|
528
|
-
const expectAddConstraint = () => {
|
|
529
|
-
expectSql(`
|
|
530
|
-
ALTER TABLE "table"
|
|
531
|
-
${expectedConstraint}
|
|
532
|
-
`);
|
|
533
|
-
};
|
|
534
|
-
|
|
535
|
-
const expectDropConstraint = () => {
|
|
536
|
-
expectSql(`
|
|
537
|
-
ALTER TABLE "table"
|
|
538
|
-
DROP CONSTRAINT "constraintName" CASCADE
|
|
539
|
-
`);
|
|
540
|
-
};
|
|
541
|
-
|
|
542
|
-
await fn();
|
|
543
|
-
(action === 'add' ? expectAddConstraint : expectDropConstraint)();
|
|
544
|
-
|
|
545
|
-
db.up = false;
|
|
546
|
-
queryMock.mockClear();
|
|
547
|
-
await fn();
|
|
548
|
-
(action === 'add' ? expectDropConstraint : expectAddConstraint)();
|
|
549
|
-
});
|
|
550
|
-
});
|
|
551
|
-
|
|
552
|
-
describe('column change', () => {
|
|
553
|
-
const fn = () => {
|
|
554
|
-
return db.changeTable('table', (t) => ({
|
|
555
|
-
changeType: t.change(t.integer(), t.text()),
|
|
556
|
-
changeEnum: t.change(t.enum('one'), t.enum('two')),
|
|
557
|
-
changeTypeUsing: t.change(t.integer(), t.text(), {
|
|
558
|
-
usingUp: t.raw('b::text'),
|
|
559
|
-
usingDown: t.raw('b::int'),
|
|
560
|
-
}),
|
|
561
|
-
changeCollate: t.change(
|
|
562
|
-
t.text().collate('de_DE'),
|
|
563
|
-
t.text().collate('fr_FR'),
|
|
564
|
-
),
|
|
565
|
-
changeDefault: t.change(t.default('from'), t.default(t.raw("'to'"))),
|
|
566
|
-
changeNull: t.change(t.nonNullable(), t.nullable()),
|
|
567
|
-
changeComment: t.change(t.comment('comment 1'), t.comment('comment 2')),
|
|
568
|
-
changeCompression: t.change(t.text(), t.text().compression('value')),
|
|
569
|
-
}));
|
|
570
|
-
};
|
|
571
|
-
|
|
572
|
-
const enumOne = ['one', 'two'];
|
|
573
|
-
const enumTwo = ['three', 'four'];
|
|
574
|
-
|
|
575
|
-
it('should change column up', async () => {
|
|
576
|
-
asMock(queryMock).mockResolvedValueOnce({
|
|
577
|
-
rows: enumOne.map((value) => [value]),
|
|
578
|
-
});
|
|
579
|
-
asMock(queryMock).mockResolvedValueOnce({
|
|
580
|
-
rows: enumTwo.map((value) => [value]),
|
|
581
|
-
});
|
|
582
|
-
|
|
583
|
-
await fn();
|
|
584
|
-
|
|
585
|
-
expectSql([
|
|
586
|
-
'SELECT unnest(enum_range(NULL::"one"))::text',
|
|
587
|
-
'SELECT unnest(enum_range(NULL::"two"))::text',
|
|
588
|
-
`
|
|
589
|
-
ALTER TABLE "table"
|
|
590
|
-
ALTER COLUMN "changeType" TYPE text,
|
|
591
|
-
ALTER COLUMN "changeEnum" TYPE "two",
|
|
592
|
-
ALTER COLUMN "changeTypeUsing" TYPE text USING b::text,
|
|
593
|
-
ALTER COLUMN "changeCollate" TYPE text COLLATE 'fr_FR',
|
|
594
|
-
ALTER COLUMN "changeDefault" SET DEFAULT 'to',
|
|
595
|
-
ALTER COLUMN "changeNull" DROP NOT NULL,
|
|
596
|
-
ALTER COLUMN "changeCompression" SET COMPRESSION value
|
|
597
|
-
`,
|
|
598
|
-
`COMMENT ON COLUMN "table"."changeComment" IS 'comment 2'`,
|
|
599
|
-
]);
|
|
600
|
-
|
|
601
|
-
const [{ ast }] = asMock(db.options.appCodeUpdater).mock.calls[0];
|
|
602
|
-
expect(ast.shape.changeEnum.from.column.options).toEqual(enumOne);
|
|
603
|
-
expect(ast.shape.changeEnum.to.column.options).toEqual(enumTwo);
|
|
604
|
-
});
|
|
605
|
-
|
|
606
|
-
it('should change column down', async () => {
|
|
607
|
-
asMock(queryMock).mockResolvedValueOnce({
|
|
608
|
-
rows: enumTwo.map((value) => [value]),
|
|
609
|
-
});
|
|
610
|
-
asMock(queryMock).mockResolvedValueOnce({
|
|
611
|
-
rows: enumOne.map((value) => [value]),
|
|
612
|
-
});
|
|
613
|
-
|
|
614
|
-
db.up = false;
|
|
615
|
-
|
|
616
|
-
await fn();
|
|
617
|
-
|
|
618
|
-
expectSql([
|
|
619
|
-
'SELECT unnest(enum_range(NULL::"two"))::text',
|
|
620
|
-
'SELECT unnest(enum_range(NULL::"one"))::text',
|
|
621
|
-
`
|
|
622
|
-
ALTER TABLE "table"
|
|
623
|
-
ALTER COLUMN "changeType" TYPE integer,
|
|
624
|
-
ALTER COLUMN "changeEnum" TYPE "one",
|
|
625
|
-
ALTER COLUMN "changeTypeUsing" TYPE integer USING b::int,
|
|
626
|
-
ALTER COLUMN "changeCollate" TYPE text COLLATE 'de_DE',
|
|
627
|
-
ALTER COLUMN "changeDefault" SET DEFAULT 'from',
|
|
628
|
-
ALTER COLUMN "changeNull" SET NOT NULL,
|
|
629
|
-
ALTER COLUMN "changeCompression" SET COMPRESSION DEFAULT
|
|
630
|
-
`,
|
|
631
|
-
`COMMENT ON COLUMN "table"."changeComment" IS 'comment 1'`,
|
|
632
|
-
]);
|
|
633
|
-
|
|
634
|
-
const [{ ast }] = asMock(db.options.appCodeUpdater).mock.calls[0];
|
|
635
|
-
expect(ast.shape.changeEnum.from.column.options).toEqual(enumTwo);
|
|
636
|
-
expect(ast.shape.changeEnum.to.column.options).toEqual(enumOne);
|
|
637
|
-
});
|
|
638
|
-
});
|
|
639
|
-
|
|
640
|
-
it('should add composite primary key via change', async () => {
|
|
641
|
-
const fn = () => {
|
|
642
|
-
return db.changeTable('table', (t) => ({
|
|
643
|
-
id: t.change(t.integer(), t.integer().primaryKey()),
|
|
644
|
-
text: t.change(t.integer(), t.integer().primaryKey()),
|
|
645
|
-
}));
|
|
646
|
-
};
|
|
647
|
-
|
|
648
|
-
await fn();
|
|
649
|
-
expectSql(`
|
|
650
|
-
ALTER TABLE "table"
|
|
651
|
-
ADD PRIMARY KEY ("id", "text")
|
|
652
|
-
`);
|
|
653
|
-
|
|
654
|
-
queryMock.mockClear();
|
|
655
|
-
db.up = false;
|
|
656
|
-
await fn();
|
|
657
|
-
expectSql(`
|
|
658
|
-
ALTER TABLE "table"
|
|
659
|
-
DROP CONSTRAINT "table_pkey"
|
|
660
|
-
`);
|
|
661
|
-
});
|
|
662
|
-
|
|
663
|
-
it('should drop composite primary key via change', async () => {
|
|
664
|
-
const fn = () => {
|
|
665
|
-
return db.changeTable('table', (t) => ({
|
|
666
|
-
id: t.change(t.integer().primaryKey(), t.integer()),
|
|
667
|
-
text: t.change(t.integer().primaryKey(), t.integer()),
|
|
668
|
-
}));
|
|
669
|
-
};
|
|
670
|
-
|
|
671
|
-
await fn();
|
|
672
|
-
expectSql(`
|
|
673
|
-
ALTER TABLE "table"
|
|
674
|
-
DROP CONSTRAINT "table_pkey"
|
|
675
|
-
`);
|
|
676
|
-
|
|
677
|
-
queryMock.mockClear();
|
|
678
|
-
db.up = false;
|
|
679
|
-
await fn();
|
|
680
|
-
expectSql(`
|
|
681
|
-
ALTER TABLE "table"
|
|
682
|
-
ADD PRIMARY KEY ("id", "text")
|
|
683
|
-
`);
|
|
684
|
-
});
|
|
685
|
-
|
|
686
|
-
it('should change composite primary key', async () => {
|
|
687
|
-
const fn = () => {
|
|
688
|
-
return db.changeTable('table', (t) => ({
|
|
689
|
-
id: t.change(t.integer().primaryKey(), t.integer()),
|
|
690
|
-
text: t.change(t.integer().primaryKey(), t.integer().primaryKey()),
|
|
691
|
-
active: t.change(t.integer(), t.integer().primaryKey()),
|
|
692
|
-
}));
|
|
693
|
-
};
|
|
694
|
-
|
|
695
|
-
await fn();
|
|
696
|
-
expectSql(`
|
|
697
|
-
ALTER TABLE "table"
|
|
698
|
-
DROP CONSTRAINT "table_pkey",
|
|
699
|
-
ADD PRIMARY KEY ("text", "active")
|
|
700
|
-
`);
|
|
701
|
-
|
|
702
|
-
queryMock.mockClear();
|
|
703
|
-
db.up = false;
|
|
704
|
-
await fn();
|
|
705
|
-
expectSql(`
|
|
706
|
-
ALTER TABLE "table"
|
|
707
|
-
DROP CONSTRAINT "table_pkey",
|
|
708
|
-
ADD PRIMARY KEY ("id", "text")
|
|
709
|
-
`);
|
|
710
|
-
});
|
|
711
|
-
|
|
712
|
-
it('should change column foreign key', async () => {
|
|
713
|
-
const fn = () => {
|
|
714
|
-
return db.changeTable('table', (t) => ({
|
|
715
|
-
addFkey: t.change(
|
|
716
|
-
t.integer(),
|
|
717
|
-
t.integer().foreignKey('otherTable', 'foreignId'),
|
|
718
|
-
),
|
|
719
|
-
addFkeyWithOptions: t.change(
|
|
720
|
-
t.integer(),
|
|
721
|
-
t.integer().foreignKey('otherTable', 'foreignId', {
|
|
722
|
-
name: 'foreignKeyName',
|
|
723
|
-
match: 'FULL',
|
|
724
|
-
onUpdate: 'SET NULL',
|
|
725
|
-
onDelete: 'CASCADE',
|
|
726
|
-
}),
|
|
727
|
-
),
|
|
728
|
-
removeFkey: t.change(
|
|
729
|
-
t.integer().foreignKey('otherTable', 'foreignId'),
|
|
730
|
-
t.integer(),
|
|
731
|
-
),
|
|
732
|
-
removeFkeyWithOptions: t.change(
|
|
733
|
-
t.integer().foreignKey('otherTable', 'foreignId', {
|
|
734
|
-
name: 'foreignKeyName',
|
|
735
|
-
match: 'FULL',
|
|
736
|
-
onUpdate: 'SET NULL',
|
|
737
|
-
onDelete: 'CASCADE',
|
|
738
|
-
}),
|
|
739
|
-
t.integer(),
|
|
740
|
-
),
|
|
741
|
-
changeForeignKey: t.change(
|
|
742
|
-
t.integer().foreignKey('a', 'aId', {
|
|
743
|
-
name: 'fromFkeyName',
|
|
744
|
-
match: 'PARTIAL',
|
|
745
|
-
onUpdate: 'RESTRICT',
|
|
746
|
-
onDelete: 'SET DEFAULT',
|
|
747
|
-
}),
|
|
748
|
-
t.integer().foreignKey('b', 'bId', {
|
|
749
|
-
name: 'toFkeyName',
|
|
750
|
-
match: 'FULL',
|
|
751
|
-
onUpdate: 'NO ACTION',
|
|
752
|
-
onDelete: 'CASCADE',
|
|
753
|
-
}),
|
|
754
|
-
),
|
|
755
|
-
}));
|
|
756
|
-
};
|
|
757
|
-
|
|
758
|
-
await fn();
|
|
759
|
-
expectSql(`
|
|
760
|
-
ALTER TABLE "table"
|
|
761
|
-
DROP CONSTRAINT "table_removeFkey_fkey",
|
|
762
|
-
DROP CONSTRAINT "foreignKeyName",
|
|
763
|
-
DROP CONSTRAINT "fromFkeyName",
|
|
764
|
-
ADD CONSTRAINT "table_addFkey_fkey" FOREIGN KEY ("addFkey") REFERENCES "otherTable"("foreignId"),
|
|
765
|
-
ADD CONSTRAINT "foreignKeyName" FOREIGN KEY ("addFkeyWithOptions") REFERENCES "otherTable"("foreignId") MATCH FULL ON DELETE CASCADE ON UPDATE SET NULL,
|
|
766
|
-
ADD CONSTRAINT "toFkeyName" FOREIGN KEY ("changeForeignKey") REFERENCES "b"("bId") MATCH FULL ON DELETE CASCADE ON UPDATE NO ACTION
|
|
767
|
-
`);
|
|
768
|
-
|
|
769
|
-
queryMock.mockClear();
|
|
770
|
-
db.up = false;
|
|
771
|
-
await fn();
|
|
772
|
-
expectSql(`
|
|
773
|
-
ALTER TABLE "table"
|
|
774
|
-
DROP CONSTRAINT "table_addFkey_fkey",
|
|
775
|
-
DROP CONSTRAINT "foreignKeyName",
|
|
776
|
-
DROP CONSTRAINT "toFkeyName",
|
|
777
|
-
ADD CONSTRAINT "table_removeFkey_fkey" FOREIGN KEY ("removeFkey") REFERENCES "otherTable"("foreignId"),
|
|
778
|
-
ADD CONSTRAINT "foreignKeyName" FOREIGN KEY ("removeFkeyWithOptions") REFERENCES "otherTable"("foreignId") MATCH FULL ON DELETE CASCADE ON UPDATE SET NULL,
|
|
779
|
-
ADD CONSTRAINT "fromFkeyName" FOREIGN KEY ("changeForeignKey") REFERENCES "a"("aId") MATCH PARTIAL ON DELETE SET DEFAULT ON UPDATE RESTRICT
|
|
780
|
-
`);
|
|
781
|
-
});
|
|
782
|
-
|
|
783
|
-
it('should change index', async () => {
|
|
784
|
-
const fn = () => {
|
|
785
|
-
return db.changeTable('table', (t) => ({
|
|
786
|
-
addIndex: t.change(t.integer(), t.integer().index()),
|
|
787
|
-
addIndexWithOptions: t.change(
|
|
788
|
-
t.integer(),
|
|
789
|
-
t.integer().index({
|
|
790
|
-
collate: 'collate',
|
|
791
|
-
opclass: 'opclass',
|
|
792
|
-
order: 'order',
|
|
793
|
-
unique: true,
|
|
794
|
-
using: 'using',
|
|
795
|
-
include: ['a', 'b'],
|
|
796
|
-
with: 'with',
|
|
797
|
-
tablespace: 'tablespace',
|
|
798
|
-
where: 'where',
|
|
799
|
-
dropMode: 'CASCADE',
|
|
800
|
-
}),
|
|
801
|
-
),
|
|
802
|
-
removeIndex: t.change(t.integer().index(), t.integer()),
|
|
803
|
-
removeIndexWithOptions: t.change(
|
|
804
|
-
t.integer().index({
|
|
805
|
-
collate: 'collate',
|
|
806
|
-
opclass: 'opclass',
|
|
807
|
-
order: 'order',
|
|
808
|
-
unique: true,
|
|
809
|
-
using: 'using',
|
|
810
|
-
include: ['a', 'b'],
|
|
811
|
-
with: 'with',
|
|
812
|
-
tablespace: 'tablespace',
|
|
813
|
-
where: 'where',
|
|
814
|
-
dropMode: 'CASCADE',
|
|
815
|
-
}),
|
|
816
|
-
t.integer(),
|
|
817
|
-
),
|
|
818
|
-
changeIndex: t.change(
|
|
819
|
-
t.integer().index({
|
|
820
|
-
name: 'from',
|
|
821
|
-
collate: 'from',
|
|
822
|
-
opclass: 'from',
|
|
823
|
-
order: 'from',
|
|
824
|
-
unique: false,
|
|
825
|
-
using: 'from',
|
|
826
|
-
include: ['a', 'b'],
|
|
827
|
-
with: 'from',
|
|
828
|
-
tablespace: 'from',
|
|
829
|
-
where: 'from',
|
|
830
|
-
dropMode: 'CASCADE',
|
|
831
|
-
}),
|
|
832
|
-
t.integer().index({
|
|
833
|
-
name: 'to',
|
|
834
|
-
collate: 'to',
|
|
835
|
-
opclass: 'to',
|
|
836
|
-
order: 'to',
|
|
837
|
-
unique: true,
|
|
838
|
-
using: 'to',
|
|
839
|
-
include: ['c', 'd'],
|
|
840
|
-
with: 'to',
|
|
841
|
-
tablespace: 'to',
|
|
842
|
-
where: 'to',
|
|
843
|
-
dropMode: 'RESTRICT',
|
|
844
|
-
}),
|
|
845
|
-
),
|
|
846
|
-
}));
|
|
847
|
-
};
|
|
848
|
-
|
|
849
|
-
await fn();
|
|
850
|
-
expectSql([
|
|
851
|
-
`DROP INDEX "table_removeIndex_idx"`,
|
|
852
|
-
`DROP INDEX "table_removeIndexWithOptions_idx" CASCADE`,
|
|
853
|
-
`DROP INDEX "from" CASCADE`,
|
|
854
|
-
`CREATE INDEX "table_addIndex_idx" ON "table" ("addIndex")`,
|
|
855
|
-
`CREATE UNIQUE INDEX "table_addIndexWithOptions_idx" ON "table" USING using ("addIndexWithOptions" COLLATE 'collate' opclass order) INCLUDE ("a", "b") WITH (with) TABLESPACE tablespace WHERE where`,
|
|
856
|
-
`CREATE UNIQUE INDEX "to" ON "table" USING to ("changeIndex" COLLATE 'to' to to) INCLUDE ("c", "d") WITH (to) TABLESPACE to WHERE to`,
|
|
857
|
-
]);
|
|
858
|
-
|
|
859
|
-
queryMock.mockClear();
|
|
860
|
-
db.up = false;
|
|
861
|
-
await fn();
|
|
862
|
-
expectSql([
|
|
863
|
-
`DROP INDEX "table_addIndex_idx"`,
|
|
864
|
-
`DROP INDEX "table_addIndexWithOptions_idx" CASCADE`,
|
|
865
|
-
`DROP INDEX "to" RESTRICT`,
|
|
866
|
-
`CREATE INDEX "table_removeIndex_idx" ON "table" ("removeIndex")`,
|
|
867
|
-
`CREATE UNIQUE INDEX "table_removeIndexWithOptions_idx" ON "table" USING using ("removeIndexWithOptions" COLLATE 'collate' opclass order) INCLUDE ("a", "b") WITH (with) TABLESPACE tablespace WHERE where`,
|
|
868
|
-
`CREATE INDEX "from" ON "table" USING from ("changeIndex" COLLATE 'from' from from) INCLUDE ("a", "b") WITH (from) TABLESPACE from WHERE from`,
|
|
869
|
-
]);
|
|
870
|
-
});
|
|
871
|
-
|
|
872
|
-
it('should rename a column', async () => {
|
|
873
|
-
const fn = () => {
|
|
874
|
-
return db.changeTable('table', (t) => ({
|
|
875
|
-
a: t.rename('b'),
|
|
876
|
-
}));
|
|
877
|
-
};
|
|
878
|
-
|
|
879
|
-
await fn();
|
|
880
|
-
expectSql(
|
|
881
|
-
`
|
|
882
|
-
ALTER TABLE "table"
|
|
883
|
-
RENAME COLUMN "a" TO "b"
|
|
884
|
-
`,
|
|
885
|
-
);
|
|
886
|
-
|
|
887
|
-
queryMock.mockClear();
|
|
888
|
-
db.up = false;
|
|
889
|
-
await fn();
|
|
890
|
-
expectSql(
|
|
891
|
-
`
|
|
892
|
-
ALTER TABLE "table"
|
|
893
|
-
RENAME COLUMN "b" TO "a"
|
|
894
|
-
`,
|
|
895
|
-
);
|
|
896
|
-
});
|
|
897
|
-
});
|