@contember/schema-migrations 1.0.0-alpha.0 → 1.0.0-alpha.4

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.
Files changed (63) hide show
  1. package/dist/src/MigrationCreator.d.ts +0 -1
  2. package/dist/src/MigrationCreator.d.ts.map +1 -1
  3. package/dist/src/MigrationCreator.js +0 -6
  4. package/dist/src/MigrationCreator.js.map +1 -1
  5. package/dist/src/SchemaDiffer.d.ts.map +1 -1
  6. package/dist/src/SchemaDiffer.js +3 -2
  7. package/dist/src/SchemaDiffer.js.map +1 -1
  8. package/dist/src/modifications/ModificationHandlerFactory.d.ts.map +1 -1
  9. package/dist/src/modifications/ModificationHandlerFactory.js +3 -1
  10. package/dist/src/modifications/ModificationHandlerFactory.js.map +1 -1
  11. package/dist/src/modifications/differs/RemoveChangedViewDiffer.d.ts +10 -0
  12. package/dist/src/modifications/differs/RemoveChangedViewDiffer.d.ts.map +1 -0
  13. package/dist/src/modifications/differs/RemoveChangedViewDiffer.js +46 -0
  14. package/dist/src/modifications/differs/RemoveChangedViewDiffer.js.map +1 -0
  15. package/dist/src/modifications/differs/index.d.ts +1 -0
  16. package/dist/src/modifications/differs/index.d.ts.map +1 -1
  17. package/dist/src/modifications/differs/index.js +1 -0
  18. package/dist/src/modifications/differs/index.js.map +1 -1
  19. package/dist/src/modifications/entities/CreateEntityModification.d.ts.map +1 -1
  20. package/dist/src/modifications/entities/CreateEntityModification.js +2 -0
  21. package/dist/src/modifications/entities/CreateEntityModification.js.map +1 -1
  22. package/dist/src/modifications/entities/CreateViewModification.d.ts +7 -0
  23. package/dist/src/modifications/entities/CreateViewModification.d.ts.map +1 -0
  24. package/dist/src/modifications/entities/CreateViewModification.js +60 -0
  25. package/dist/src/modifications/entities/CreateViewModification.js.map +1 -0
  26. package/dist/src/modifications/entities/RemoveEntityModification.d.ts.map +1 -1
  27. package/dist/src/modifications/entities/RemoveEntityModification.js +2 -1
  28. package/dist/src/modifications/entities/RemoveEntityModification.js.map +1 -1
  29. package/dist/src/modifications/entities/UpdateEntityNameModification.d.ts.map +1 -1
  30. package/dist/src/modifications/entities/UpdateEntityNameModification.js +13 -7
  31. package/dist/src/modifications/entities/UpdateEntityNameModification.js.map +1 -1
  32. package/dist/src/modifications/entities/UpdateViewModification.d.ts.map +1 -1
  33. package/dist/src/modifications/entities/UpdateViewModification.js +3 -14
  34. package/dist/src/modifications/entities/UpdateViewModification.js.map +1 -1
  35. package/dist/src/modifications/entities/index.d.ts +1 -1
  36. package/dist/src/modifications/entities/index.d.ts.map +1 -1
  37. package/dist/src/modifications/entities/index.js +1 -1
  38. package/dist/src/modifications/entities/index.js.map +1 -1
  39. package/dist/src/modifications/utils/viewDependencies.d.ts +5 -0
  40. package/dist/src/modifications/utils/viewDependencies.d.ts.map +1 -0
  41. package/dist/src/modifications/utils/viewDependencies.js +23 -0
  42. package/dist/src/modifications/utils/viewDependencies.js.map +1 -0
  43. package/dist/src/tsconfig.tsbuildinfo +1 -1
  44. package/dist/tests/cases/integration/createEntity.test.js +8 -12
  45. package/dist/tests/cases/integration/createEntity.test.js.map +1 -1
  46. package/dist/tests/cases/integration/updateView.test.js +480 -20
  47. package/dist/tests/cases/integration/updateView.test.js.map +1 -1
  48. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  49. package/package.json +6 -6
  50. package/src/MigrationCreator.ts +0 -8
  51. package/src/SchemaDiffer.ts +6 -4
  52. package/src/modifications/ModificationHandlerFactory.ts +3 -1
  53. package/src/modifications/differs/RemoveChangedViewDiffer.ts +42 -0
  54. package/src/modifications/differs/index.ts +1 -0
  55. package/src/modifications/entities/CreateEntityModification.ts +2 -0
  56. package/src/modifications/entities/CreateViewModification.ts +65 -0
  57. package/src/modifications/entities/RemoveEntityModification.ts +4 -2
  58. package/src/modifications/entities/UpdateEntityNameModification.ts +13 -8
  59. package/src/modifications/entities/UpdateViewModification.ts +3 -16
  60. package/src/modifications/entities/index.ts +1 -1
  61. package/src/modifications/utils/viewDependencies.ts +20 -0
  62. package/tests/cases/integration/createEntity.test.ts +8 -12
  63. package/tests/cases/integration/updateView.test.ts +430 -17
@@ -1,5 +1,5 @@
1
1
  import { MigrationBuilder } from '@contember/database-migrations'
2
- import { Schema } from '@contember/schema'
2
+ import { Acl, Schema } from '@contember/schema'
3
3
  import {
4
4
  removeField,
5
5
  SchemaUpdater,
@@ -46,7 +46,9 @@ export const RemoveEntityModification: ModificationHandlerStatic<RemoveEntityMod
46
46
  ({ role }) => ({
47
47
  ...role,
48
48
  variables: Object.fromEntries(
49
- Object.entries(role.variables).filter(([, variable]) => variable.entityName !== this.data.entityName),
49
+ Object.entries(role.variables).filter(([, variable]) =>
50
+ variable.type !== Acl.VariableType.entity || variable.entityName !== this.data.entityName,
51
+ ),
50
52
  ),
51
53
  }),
52
54
  updateAclEntities(({ entities }) => {
@@ -1,5 +1,5 @@
1
1
  import { MigrationBuilder } from '@contember/database-migrations'
2
- import { Model, Schema } from '@contember/schema'
2
+ import { Acl, Model, Schema } from '@contember/schema'
3
3
  import {
4
4
  SchemaUpdater,
5
5
  updateAcl,
@@ -82,13 +82,18 @@ export const UpdateEntityNameModification: ModificationHandlerStatic<UpdateEntit
82
82
  ({ role }) => ({
83
83
  ...role,
84
84
  variables: Object.fromEntries(
85
- Object.entries(role.variables).map(([key, variable]) => [
86
- key,
87
- {
88
- ...variable,
89
- entityName: changeValue(this.data.entityName, this.data.newEntityName)(variable.entityName),
90
- },
91
- ]),
85
+ Object.entries(role.variables).map(([key, variable]) => {
86
+ if (variable.type === Acl.VariableType.entity) {
87
+ return [
88
+ key,
89
+ {
90
+ ...variable,
91
+ entityName: changeValue(this.data.entityName, this.data.newEntityName)(variable.entityName),
92
+ },
93
+ ]
94
+ }
95
+ return [key, variable]
96
+ }),
92
97
  ),
93
98
  }),
94
99
  updateAclEntities(({ entities }) => {
@@ -10,10 +10,11 @@ export const UpdateViewModification: ModificationHandlerStatic<UpdateViewModific
10
10
 
11
11
  public createSql(builder: MigrationBuilder): void {
12
12
  const entity = this.schema.model.entities[this.data.entityName]
13
- builder.dropView(entity.tableName, { ifExists: true })
14
13
  builder.createView(
15
14
  entity.tableName,
16
- {},
15
+ {
16
+ replace: true,
17
+ },
17
18
  this.data.view.sql,
18
19
  )
19
20
  }
@@ -34,20 +35,6 @@ export const UpdateViewModification: ModificationHandlerStatic<UpdateViewModific
34
35
  static createModification(data: UpdateViewModificationData) {
35
36
  return { modification: this.id, ...data }
36
37
  }
37
-
38
- static createDiff(originalSchema: Schema, updatedSchema: Schema) {
39
- return Object.values(updatedSchema.model.entities)
40
- .filter((it): it is Model.Entity & Required<Pick<Model.Entity, 'view'>> => {
41
- const origView = originalSchema.model.entities[it.name]?.view
42
- return !!it.view?.sql && !!origView && origView?.sql !== it.view.sql
43
- })
44
- .map(it =>
45
- UpdateViewModification.createModification({
46
- entityName: it.name,
47
- view: it.view,
48
- }),
49
- )
50
- }
51
38
  }
52
39
 
53
40
  export interface UpdateViewModificationData {
@@ -1,5 +1,5 @@
1
1
  export * from './CreateEntityModification'
2
+ export * from './CreateViewModification'
2
3
  export * from './RemoveEntityModification'
3
4
  export * from './UpdateEntityNameModification'
4
5
  export * from './UpdateEntityTableNameModification'
5
- export * from './UpdateViewModification'
@@ -0,0 +1,20 @@
1
+ import { Model } from '@contember/schema'
2
+
3
+ type ViewDependants = Map<string, Set<Model.Entity>>
4
+ export const getViewDirectDependants = (model: Model.Schema): ViewDependants => {
5
+ const dependants: ViewDependants = new Map(Object.values(model.entities).filter(it => it.view).map(it => [it.name, new Set()]))
6
+ for (const entity of Object.values(model.entities)) {
7
+ if (!entity.view?.dependencies?.length) {
8
+ continue
9
+ }
10
+ for (const dependency of entity.view.dependencies) {
11
+ const entityDependants = dependants.get(dependency)
12
+ if (!entityDependants) {
13
+ // not a view
14
+ continue
15
+ }
16
+ entityDependants.add(entity)
17
+ }
18
+ }
19
+ return dependants
20
+ }
@@ -111,7 +111,7 @@ testMigrations('create a view', {
111
111
  updatedSchema: def.createModel(ViewEntityUpdatedSchema),
112
112
  diff: [
113
113
  {
114
- modification: 'createEntity',
114
+ modification: 'createView',
115
115
  entity: {
116
116
  fields: {
117
117
  id: {
@@ -121,6 +121,13 @@ testMigrations('create a view', {
121
121
  type: Model.ColumnType.Uuid,
122
122
  columnType: 'uuid',
123
123
  },
124
+ name: {
125
+ columnName: 'name',
126
+ name: 'name',
127
+ nullable: true,
128
+ type: Model.ColumnType.String,
129
+ columnType: 'text',
130
+ },
124
131
  },
125
132
  name: 'Author',
126
133
  primary: 'id',
@@ -130,17 +137,6 @@ testMigrations('create a view', {
130
137
  view: { sql: "SELECT null as id, 'John' AS name" },
131
138
  },
132
139
  },
133
- {
134
- modification: 'createColumn',
135
- entityName: 'Author',
136
- field: {
137
- columnName: 'name',
138
- name: 'name',
139
- nullable: true,
140
- type: Model.ColumnType.String,
141
- columnType: 'text',
142
- },
143
- },
144
140
  ],
145
141
  sql: SQL`CREATE VIEW "author" AS SELECT null as id, 'John' AS name;`,
146
142
  })
@@ -1,44 +1,457 @@
1
1
  import { testMigrations } from '../../src/tests'
2
2
  import { SQL } from '../../src/tags'
3
3
  import { SchemaDefinition as def } from '@contember/schema-definition'
4
- import { Model } from '@contember/schema'
5
4
 
6
5
  namespace ViewEntityOriginalSchema {
7
6
  @def.View("SELECT null as id, 'John' AS name")
8
7
  export class Author {
9
8
  name = def.stringColumn()
10
9
  }
10
+
11
+ @def.View('SELECT * FROM author', { dependencies: [Author] })
12
+ export class Author2 {
13
+ name = def.stringColumn()
14
+ }
15
+
16
+ @def.View('SELECT * FROM author2', { dependencies: [Author2] })
17
+ export class Author3 {
18
+ name = def.stringColumn()
19
+ }
11
20
  }
12
21
 
13
- namespace ViewEntityUpdatedSchema {
14
- @def.View("SELECT null as id, 'John' AS name, 'root@localhost' as email")
22
+ namespace ViewEntityUpdatedSchema1 {
23
+ @def.View("SELECT null as id, 'Jack' AS name")
15
24
  export class Author {
16
25
  name = def.stringColumn()
17
- email = def.stringColumn()
26
+ }
27
+
28
+ @def.View('SELECT * FROM author', { dependencies: [Author] })
29
+ export class Author2 {
30
+ name = def.stringColumn()
31
+ }
32
+
33
+ @def.View('SELECT * FROM author2', { dependencies: [Author2] })
34
+ export class Author3 {
35
+ name = def.stringColumn()
18
36
  }
19
37
  }
20
- testMigrations('update a view', {
38
+
39
+
40
+ testMigrations('update a view 1', {
21
41
  originalSchema: def.createModel(ViewEntityOriginalSchema),
22
- updatedSchema: def.createModel(ViewEntityUpdatedSchema),
42
+ updatedSchema: def.createModel(ViewEntityUpdatedSchema1),
23
43
  diff: [
24
44
  {
25
- modification: 'updateView',
45
+ modification: 'removeEntity',
46
+ entityName: 'Author3',
47
+ },
48
+ {
49
+ modification: 'removeEntity',
50
+ entityName: 'Author2',
51
+ },
52
+ {
53
+ modification: 'removeEntity',
26
54
  entityName: 'Author',
27
- view: {
28
- sql: "SELECT null as id, 'John' AS name, 'root@localhost' as email",
55
+ },
56
+ {
57
+ modification: 'createView',
58
+ entity: {
59
+ name: 'Author',
60
+ primary: 'id',
61
+ primaryColumn: 'id',
62
+ unique: {},
63
+ fields: {
64
+ id: {
65
+ name: 'id',
66
+ columnName: 'id',
67
+ nullable: false,
68
+ type: 'Uuid',
69
+ columnType: 'uuid',
70
+ },
71
+ name: {
72
+ name: 'name',
73
+ columnName: 'name',
74
+ nullable: true,
75
+ type: 'String',
76
+ columnType: 'text',
77
+ },
78
+ },
79
+ tableName: 'author',
80
+ view: {
81
+ sql: "SELECT null as id, 'Jack' AS name",
82
+ },
83
+ },
84
+ },
85
+ {
86
+ modification: 'createView',
87
+ entity: {
88
+ name: 'Author2',
89
+ primary: 'id',
90
+ primaryColumn: 'id',
91
+ unique: {},
92
+ fields: {
93
+ id: {
94
+ name: 'id',
95
+ columnName: 'id',
96
+ nullable: false,
97
+ type: 'Uuid',
98
+ columnType: 'uuid',
99
+ },
100
+ name: {
101
+ name: 'name',
102
+ columnName: 'name',
103
+ nullable: true,
104
+ type: 'String',
105
+ columnType: 'text',
106
+ },
107
+ },
108
+ tableName: 'author2',
109
+ view: {
110
+ sql: 'SELECT * FROM author',
111
+ dependencies: [
112
+ 'Author',
113
+ ],
114
+ },
115
+ },
116
+ },
117
+ {
118
+ modification: 'createView',
119
+ entity: {
120
+ name: 'Author3',
121
+ primary: 'id',
122
+ primaryColumn: 'id',
123
+ unique: {},
124
+ fields: {
125
+ id: {
126
+ name: 'id',
127
+ columnName: 'id',
128
+ nullable: false,
129
+ type: 'Uuid',
130
+ columnType: 'uuid',
131
+ },
132
+ name: {
133
+ name: 'name',
134
+ columnName: 'name',
135
+ nullable: true,
136
+ type: 'String',
137
+ columnType: 'text',
138
+ },
139
+ },
140
+ tableName: 'author3',
141
+ view: {
142
+ sql: 'SELECT * FROM author2',
143
+ dependencies: [
144
+ 'Author2',
145
+ ],
146
+ },
147
+ },
148
+ },
149
+ ],
150
+ sql: SQL`DROP VIEW "author3";
151
+ DROP VIEW "author2";
152
+ DROP VIEW "author";
153
+ CREATE VIEW "author" AS SELECT null as id, 'Jack' AS name;
154
+ CREATE VIEW "author2" AS SELECT * FROM author;
155
+ CREATE VIEW "author3" AS SELECT * FROM author2;`,
156
+ })
157
+
158
+
159
+ namespace ViewEntityUpdatedSchema2 {
160
+ @def.View("SELECT null as id, 'John' AS name")
161
+ export class Author {
162
+ name = def.stringColumn()
163
+ }
164
+
165
+ @def.View('SELECT id, name FROM author', { dependencies: [Author] })
166
+ export class Author2 {
167
+ name = def.stringColumn()
168
+ }
169
+
170
+ @def.View('SELECT * FROM author2', { dependencies: [Author2] })
171
+ export class Author3 {
172
+ name = def.stringColumn()
173
+ }
174
+ }
175
+
176
+ testMigrations('update a view 2', {
177
+ originalSchema: def.createModel(ViewEntityOriginalSchema),
178
+ updatedSchema: def.createModel(ViewEntityUpdatedSchema2),
179
+ diff: [
180
+ {
181
+ modification: 'removeEntity',
182
+ entityName: 'Author3',
183
+ },
184
+ {
185
+ modification: 'removeEntity',
186
+ entityName: 'Author2',
187
+ },
188
+ {
189
+ modification: 'createView',
190
+ entity: {
191
+ name: 'Author2',
192
+ primary: 'id',
193
+ primaryColumn: 'id',
194
+ unique: {},
195
+ fields: {
196
+ id: {
197
+ name: 'id',
198
+ columnName: 'id',
199
+ nullable: false,
200
+ type: 'Uuid',
201
+ columnType: 'uuid',
202
+ },
203
+ name: {
204
+ name: 'name',
205
+ columnName: 'name',
206
+ nullable: true,
207
+ type: 'String',
208
+ columnType: 'text',
209
+ },
210
+ },
211
+ tableName: 'author2',
212
+ view: {
213
+ sql: 'SELECT id, name FROM author',
214
+ dependencies: [
215
+ 'Author',
216
+ ],
217
+ },
218
+ },
219
+ },
220
+ {
221
+ modification: 'createView',
222
+ entity: {
223
+ name: 'Author3',
224
+ primary: 'id',
225
+ primaryColumn: 'id',
226
+ unique: {},
227
+ fields: {
228
+ id: {
229
+ name: 'id',
230
+ columnName: 'id',
231
+ nullable: false,
232
+ type: 'Uuid',
233
+ columnType: 'uuid',
234
+ },
235
+ name: {
236
+ name: 'name',
237
+ columnName: 'name',
238
+ nullable: true,
239
+ type: 'String',
240
+ columnType: 'text',
241
+ },
242
+ },
243
+ tableName: 'author3',
244
+ view: {
245
+ sql: 'SELECT * FROM author2',
246
+ dependencies: [
247
+ 'Author2',
248
+ ],
249
+ },
29
250
  },
30
251
  },
252
+ ],
253
+ sql: SQL`DROP VIEW "author3";
254
+ DROP VIEW "author2";
255
+ CREATE VIEW "author2" AS SELECT id, name FROM author;
256
+ CREATE VIEW "author3" AS SELECT * FROM author2;
257
+ `,
258
+ })
259
+
260
+
261
+ namespace ViewEntityUpdatedSchema3 {
262
+ @def.View("SELECT null as id, 'John' AS name")
263
+ export class Author {
264
+ name = def.stringColumn()
265
+ }
266
+
267
+ @def.View('SELECT * FROM author', { dependencies: [Author] })
268
+ export class Author2 {
269
+ name = def.stringColumn()
270
+ }
271
+
272
+ @def.View('SELECT id, name FROM author2', { dependencies: [Author2] })
273
+ export class Author3 {
274
+ name = def.stringColumn()
275
+ }
276
+ }
277
+
278
+ testMigrations('update a view 3', {
279
+ originalSchema: def.createModel(ViewEntityOriginalSchema),
280
+ updatedSchema: def.createModel(ViewEntityUpdatedSchema3),
281
+ diff: [
282
+ {
283
+ modification: 'removeEntity',
284
+ entityName: 'Author3',
285
+ },
31
286
  {
32
- modification: 'createColumn',
287
+ modification: 'createView',
288
+ entity: {
289
+ name: 'Author3',
290
+ primary: 'id',
291
+ primaryColumn: 'id',
292
+ unique: {},
293
+ fields: {
294
+ id: {
295
+ name: 'id',
296
+ columnName: 'id',
297
+ nullable: false,
298
+ type: 'Uuid',
299
+ columnType: 'uuid',
300
+ },
301
+ name: {
302
+ name: 'name',
303
+ columnName: 'name',
304
+ nullable: true,
305
+ type: 'String',
306
+ columnType: 'text',
307
+ },
308
+ },
309
+ tableName: 'author3',
310
+ view: {
311
+ sql: 'SELECT id, name FROM author2',
312
+ dependencies: [
313
+ 'Author2',
314
+ ],
315
+ },
316
+ },
317
+ },
318
+ ],
319
+ sql: SQL`DROP VIEW "author3";
320
+ CREATE VIEW "author3" AS SELECT id, name FROM author2;`,
321
+ })
322
+
323
+
324
+ namespace ViewEntityUpdatedSchema4 {
325
+ @def.View("SELECT null as id, 'Jack' AS name")
326
+ export class Author {
327
+ name = def.stringColumn()
328
+ }
329
+
330
+ @def.View('SELECT id, name FROM author', { dependencies: [Author] })
331
+ export class Author2 {
332
+ name = def.stringColumn()
333
+ }
334
+
335
+ @def.View('SELECT id, name FROM author2', { dependencies: [Author2] })
336
+ export class Author3 {
337
+ name = def.stringColumn()
338
+ }
339
+ }
340
+
341
+ testMigrations('update a view 4', {
342
+ originalSchema: def.createModel(ViewEntityOriginalSchema),
343
+ updatedSchema: def.createModel(ViewEntityUpdatedSchema4),
344
+ diff: [
345
+ {
346
+ modification: 'removeEntity',
347
+ entityName: 'Author3',
348
+ },
349
+ {
350
+ modification: 'removeEntity',
351
+ entityName: 'Author2',
352
+ },
353
+ {
354
+ modification: 'removeEntity',
33
355
  entityName: 'Author',
34
- field: {
35
- columnName: 'email',
36
- name: 'email',
37
- nullable: true,
38
- type: Model.ColumnType.String,
39
- columnType: 'text',
356
+ },
357
+ {
358
+ modification: 'createView',
359
+ entity: {
360
+ name: 'Author',
361
+ primary: 'id',
362
+ primaryColumn: 'id',
363
+ unique: {},
364
+ fields: {
365
+ id: {
366
+ name: 'id',
367
+ columnName: 'id',
368
+ nullable: false,
369
+ type: 'Uuid',
370
+ columnType: 'uuid',
371
+ },
372
+ name: {
373
+ name: 'name',
374
+ columnName: 'name',
375
+ nullable: true,
376
+ type: 'String',
377
+ columnType: 'text',
378
+ },
379
+ },
380
+ tableName: 'author',
381
+ view: {
382
+ sql: "SELECT null as id, 'Jack' AS name",
383
+ },
384
+ },
385
+ },
386
+ {
387
+ modification: 'createView',
388
+ entity: {
389
+ name: 'Author2',
390
+ primary: 'id',
391
+ primaryColumn: 'id',
392
+ unique: {},
393
+ fields: {
394
+ id: {
395
+ name: 'id',
396
+ columnName: 'id',
397
+ nullable: false,
398
+ type: 'Uuid',
399
+ columnType: 'uuid',
400
+ },
401
+ name: {
402
+ name: 'name',
403
+ columnName: 'name',
404
+ nullable: true,
405
+ type: 'String',
406
+ columnType: 'text',
407
+ },
408
+ },
409
+ tableName: 'author2',
410
+ view: {
411
+ sql: 'SELECT id, name FROM author',
412
+ dependencies: [
413
+ 'Author',
414
+ ],
415
+ },
416
+ },
417
+ },
418
+ {
419
+ modification: 'createView',
420
+ entity: {
421
+ name: 'Author3',
422
+ primary: 'id',
423
+ primaryColumn: 'id',
424
+ unique: {},
425
+ fields: {
426
+ id: {
427
+ name: 'id',
428
+ columnName: 'id',
429
+ nullable: false,
430
+ type: 'Uuid',
431
+ columnType: 'uuid',
432
+ },
433
+ name: {
434
+ name: 'name',
435
+ columnName: 'name',
436
+ nullable: true,
437
+ type: 'String',
438
+ columnType: 'text',
439
+ },
440
+ },
441
+ tableName: 'author3',
442
+ view: {
443
+ sql: 'SELECT id, name FROM author2',
444
+ dependencies: [
445
+ 'Author2',
446
+ ],
447
+ },
40
448
  },
41
449
  },
42
450
  ],
43
- sql: SQL`DROP VIEW IF EXISTS "author"; CREATE VIEW "author" AS SELECT null as id, 'John' AS name, 'root@localhost' as email;`,
451
+ sql: SQL`DROP VIEW "author3";
452
+ DROP VIEW "author2";
453
+ DROP VIEW "author";
454
+ CREATE VIEW "author" AS SELECT null as id, 'Jack' AS name;
455
+ CREATE VIEW "author2" AS SELECT id, name FROM author;
456
+ CREATE VIEW "author3" AS SELECT id, name FROM author2;`,
44
457
  })