@contember/schema-migrations 1.3.0-rc.2 → 1.3.0
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/src/SchemaDiffer.d.ts.map +1 -1
- package/dist/src/SchemaDiffer.js +1 -2
- package/dist/src/SchemaDiffer.js.map +1 -1
- package/dist/src/modifications/differs/{RemoveChangedViewDiffer.d.ts → RemoveViewDiffer.d.ts} +5 -2
- package/dist/src/modifications/differs/RemoveViewDiffer.d.ts.map +1 -0
- package/dist/src/modifications/differs/RemoveViewDiffer.js +48 -0
- package/dist/src/modifications/differs/RemoveViewDiffer.js.map +1 -0
- package/dist/src/modifications/differs/index.d.ts +1 -2
- package/dist/src/modifications/differs/index.d.ts.map +1 -1
- package/dist/src/modifications/differs/index.js +1 -2
- package/dist/src/modifications/differs/index.js.map +1 -1
- package/dist/src/modifications/utils/viewDependencies.js +3 -3
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/tests/cases/integration/convertOneHasManyToManyHasManyRelation.test.js +2 -2
- package/dist/tests/cases/integration/convertOneHasManyToManyHasManyRelation.test.js.map +1 -1
- package/dist/tests/cases/integration/convertOneToManyRelation.test.js +24 -16
- package/dist/tests/cases/integration/convertOneToManyRelation.test.js.map +1 -1
- package/dist/tests/cases/integration/createAndDropIndex.test.js +4 -4
- package/dist/tests/cases/integration/createAndDropIndex.test.js.map +1 -1
- package/dist/tests/cases/integration/createColumn.test.js +4 -4
- package/dist/tests/cases/integration/createColumn.test.js.map +1 -1
- package/dist/tests/cases/integration/createEntity.test.js +11 -9
- package/dist/tests/cases/integration/createEntity.test.js.map +1 -1
- package/dist/tests/cases/integration/createEnum.test.js +13 -9
- package/dist/tests/cases/integration/createEnum.test.js.map +1 -1
- package/dist/tests/cases/integration/createManyHasMany.test.js +11 -7
- package/dist/tests/cases/integration/createManyHasMany.test.js.map +1 -1
- package/dist/tests/cases/integration/createManyHasOne.test.js +13 -9
- package/dist/tests/cases/integration/createManyHasOne.test.js.map +1 -1
- package/dist/tests/cases/integration/createOneHasMany.test.js +10 -8
- package/dist/tests/cases/integration/createOneHasMany.test.js.map +1 -1
- package/dist/tests/cases/integration/createOneHasOne.test.js +9 -7
- package/dist/tests/cases/integration/createOneHasOne.test.js.map +1 -1
- package/dist/tests/cases/integration/createRelationInverseSide.test.js +24 -16
- package/dist/tests/cases/integration/createRelationInverseSide.test.js.map +1 -1
- package/dist/tests/cases/integration/createView.test.js +3 -3
- package/dist/tests/cases/integration/createView.test.js.map +1 -1
- package/dist/tests/cases/integration/disableOrphanRemoval.test.js +14 -10
- package/dist/tests/cases/integration/disableOrphanRemoval.test.js.map +1 -1
- package/dist/tests/cases/integration/enableOrphanRemoval.test.js +14 -10
- package/dist/tests/cases/integration/enableOrphanRemoval.test.js.map +1 -1
- package/dist/tests/cases/integration/makeColumnNotNull.test.js +10 -6
- package/dist/tests/cases/integration/makeColumnNotNull.test.js.map +1 -1
- package/dist/tests/cases/integration/makeRelationNotNull.test.js +14 -10
- package/dist/tests/cases/integration/makeRelationNotNull.test.js.map +1 -1
- package/dist/tests/cases/integration/makeRelationNullable.test.js +26 -18
- package/dist/tests/cases/integration/makeRelationNullable.test.js.map +1 -1
- package/dist/tests/cases/integration/patchAclSchema.test.js +21 -17
- package/dist/tests/cases/integration/patchAclSchema.test.js.map +1 -1
- package/dist/tests/cases/integration/removeEntity.test.js +60 -52
- package/dist/tests/cases/integration/removeEntity.test.js.map +1 -1
- package/dist/tests/cases/integration/removeEnum.test.js +13 -9
- package/dist/tests/cases/integration/removeEnum.test.js.map +1 -1
- package/dist/tests/cases/integration/removeField.test.js +71 -51
- package/dist/tests/cases/integration/removeField.test.js.map +1 -1
- package/dist/tests/cases/integration/toggleEventLog.test.js +4 -4
- package/dist/tests/cases/integration/toggleEventLog.test.js.map +1 -1
- package/dist/tests/cases/integration/toggleJunctionEventLog.test.js +4 -4
- package/dist/tests/cases/integration/toggleJunctionEventLog.test.js.map +1 -1
- package/dist/tests/cases/integration/updateColumnDefinition.test.js +18 -14
- package/dist/tests/cases/integration/updateColumnDefinition.test.js.map +1 -1
- package/dist/tests/cases/integration/updateEntityName.test.js +66 -50
- package/dist/tests/cases/integration/updateEntityName.test.js.map +1 -1
- package/dist/tests/cases/integration/updateEntityOrderBy.test.js +4 -4
- package/dist/tests/cases/integration/updateEntityOrderBy.test.js.map +1 -1
- package/dist/tests/cases/integration/updateEnum.test.js +16 -12
- package/dist/tests/cases/integration/updateEnum.test.js.map +1 -1
- package/dist/tests/cases/integration/updateFieldName.test.js +120 -96
- package/dist/tests/cases/integration/updateFieldName.test.js.map +1 -1
- package/dist/tests/cases/integration/updateRelationOnDelete.test.js +14 -10
- package/dist/tests/cases/integration/updateRelationOnDelete.test.js.map +1 -1
- package/dist/tests/cases/integration/updateRelationOrderBy.test.js +15 -11
- package/dist/tests/cases/integration/updateRelationOrderBy.test.js.map +1 -1
- package/dist/tests/cases/integration/updateView.test.js +8 -8
- package/dist/tests/cases/integration/updateView.test.js.map +1 -1
- package/dist/tests/src/tests.d.ts +7 -9
- package/dist/tests/src/tests.d.ts.map +1 -1
- package/dist/tests/src/tests.js +13 -16
- package/dist/tests/src/tests.js.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/src/SchemaDiffer.ts +2 -3
- package/src/modifications/differs/{RemoveChangedViewDiffer.ts → RemoveViewDiffer.ts} +30 -7
- package/src/modifications/differs/index.ts +1 -2
- package/src/modifications/utils/viewDependencies.ts +3 -3
- package/tests/cases/integration/convertOneHasManyToManyHasManyRelation.test.ts +3 -3
- package/tests/cases/integration/convertOneToManyRelation.test.ts +32 -24
- package/tests/cases/integration/createAndDropIndex.test.ts +5 -5
- package/tests/cases/integration/createColumn.test.ts +5 -5
- package/tests/cases/integration/createEntity.test.ts +14 -12
- package/tests/cases/integration/createEnum.test.ts +15 -11
- package/tests/cases/integration/createManyHasMany.test.ts +13 -9
- package/tests/cases/integration/createManyHasOne.test.ts +15 -11
- package/tests/cases/integration/createOneHasMany.test.ts +14 -12
- package/tests/cases/integration/createOneHasOne.test.ts +11 -9
- package/tests/cases/integration/createRelationInverseSide.test.ts +26 -18
- package/tests/cases/integration/createView.test.ts +4 -4
- package/tests/cases/integration/disableOrphanRemoval.test.ts +18 -14
- package/tests/cases/integration/enableOrphanRemoval.test.ts +18 -14
- package/tests/cases/integration/makeColumnNotNull.test.ts +10 -6
- package/tests/cases/integration/makeRelationNotNull.test.ts +18 -14
- package/tests/cases/integration/makeRelationNullable.test.ts +30 -22
- package/tests/cases/integration/patchAclSchema.test.ts +21 -17
- package/tests/cases/integration/removeEntity.test.ts +63 -55
- package/tests/cases/integration/removeEnum.test.ts +15 -11
- package/tests/cases/integration/removeField.test.ts +86 -66
- package/tests/cases/integration/toggleEventLog.test.ts +5 -5
- package/tests/cases/integration/toggleJunctionEventLog.test.ts +5 -5
- package/tests/cases/integration/updateColumnDefinition.test.ts +22 -18
- package/tests/cases/integration/updateEntityName.test.ts +67 -51
- package/tests/cases/integration/updateEntityOrderBy.test.ts +5 -5
- package/tests/cases/integration/updateEnum.test.ts +20 -16
- package/tests/cases/integration/updateFieldName.test.ts +126 -102
- package/tests/cases/integration/updateRelationOnDelete.test.ts +18 -14
- package/tests/cases/integration/updateRelationOrderBy.test.ts +23 -19
- package/tests/cases/integration/updateView.test.ts +9 -9
- package/tests/src/tests.ts +19 -29
- package/dist/src/modifications/differs/ChangeViewNonViewDiffer.d.ts +0 -6
- package/dist/src/modifications/differs/ChangeViewNonViewDiffer.d.ts.map +0 -1
- package/dist/src/modifications/differs/ChangeViewNonViewDiffer.js +0 -19
- package/dist/src/modifications/differs/ChangeViewNonViewDiffer.js.map +0 -1
- package/dist/src/modifications/differs/RemoveChangedViewDiffer.d.ts.map +0 -1
- package/dist/src/modifications/differs/RemoveChangedViewDiffer.js +0 -33
- package/dist/src/modifications/differs/RemoveChangedViewDiffer.js.map +0 -1
- package/src/modifications/differs/ChangeViewNonViewDiffer.ts +0 -17
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SchemaDefinition as def } from '@contember/schema-definition'
|
|
1
|
+
import { createSchema, SchemaDefinition as def } from '@contember/schema-definition'
|
|
2
2
|
import { testMigrations } from '../../src/tests'
|
|
3
3
|
import { SQL } from '../../src/tags'
|
|
4
4
|
|
|
@@ -24,8 +24,8 @@ namespace EventLogDisabled {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
testMigrations('event log junction - disable', {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
original: createSchema(EventLogNoConfig),
|
|
28
|
+
updated: createSchema(EventLogDisabled),
|
|
29
29
|
diff: [
|
|
30
30
|
{
|
|
31
31
|
modification: 'toggleJunctionEventLog',
|
|
@@ -39,8 +39,8 @@ testMigrations('event log junction - disable', {
|
|
|
39
39
|
})
|
|
40
40
|
|
|
41
41
|
testMigrations('event log junction - enable', {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
original: createSchema(EventLogDisabled),
|
|
43
|
+
updated: createSchema(EventLogNoConfig),
|
|
44
44
|
diff: [
|
|
45
45
|
{
|
|
46
46
|
modification: 'toggleJunctionEventLog',
|
|
@@ -5,18 +5,22 @@ import { SQL } from '../../src/tags'
|
|
|
5
5
|
import { updateColumnDefinitionModification } from '../../../src'
|
|
6
6
|
|
|
7
7
|
testMigrations('update column definition', {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
original: {
|
|
9
|
+
model: new SchemaBuilder()
|
|
10
|
+
.entity('Author', e =>
|
|
11
|
+
e.column('name', c => c.type(Model.ColumnType.String)).column('registeredAt', c => c.type(Model.ColumnType.Date)),
|
|
12
|
+
)
|
|
13
|
+
.buildSchema(),
|
|
14
|
+
},
|
|
15
|
+
updated: {
|
|
16
|
+
model: new SchemaBuilder()
|
|
17
|
+
.entity('Author', e =>
|
|
18
|
+
e
|
|
19
|
+
.column('name', c => c.type(Model.ColumnType.String))
|
|
20
|
+
.column('registeredAt', c => c.type(Model.ColumnType.DateTime)),
|
|
21
|
+
)
|
|
22
|
+
.buildSchema(),
|
|
23
|
+
},
|
|
20
24
|
diff: [
|
|
21
25
|
{
|
|
22
26
|
modification: 'updateColumnDefinition',
|
|
@@ -44,8 +48,8 @@ namespace SeqUpdated {
|
|
|
44
48
|
}
|
|
45
49
|
}
|
|
46
50
|
testMigrations('add sequence to existing column', {
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
original: createSchema(SeqOrig),
|
|
52
|
+
updated: createSchema(SeqUpdated),
|
|
49
53
|
diff: [
|
|
50
54
|
updateColumnDefinitionModification.createModification({
|
|
51
55
|
entityName: 'Author',
|
|
@@ -108,8 +112,8 @@ namespace ViewColDepUpdated {
|
|
|
108
112
|
}
|
|
109
113
|
|
|
110
114
|
testMigrations('recreate view dependent on entity after changing column type', {
|
|
111
|
-
|
|
112
|
-
|
|
115
|
+
original: createSchema(ViewColDepOrig),
|
|
116
|
+
updated: createSchema(ViewColDepUpdated),
|
|
113
117
|
diff: [{ modification: 'removeEntity', entityName: 'AuthorMetaY' }, {
|
|
114
118
|
modification: 'removeEntity',
|
|
115
119
|
entityName: 'AuthorMetaX',
|
|
@@ -181,8 +185,8 @@ namespace NotNullUpdated {
|
|
|
181
185
|
}
|
|
182
186
|
}
|
|
183
187
|
testMigrations('set not null and fill', {
|
|
184
|
-
|
|
185
|
-
|
|
188
|
+
original: createSchema(NotNullOrig),
|
|
189
|
+
updated: createSchema(NotNullUpdated),
|
|
186
190
|
noDiff: true,
|
|
187
191
|
diff: [
|
|
188
192
|
updateColumnDefinitionModification.createModification({
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { testMigrations } from '../../src/tests'
|
|
2
|
-
import { SchemaBuilder } from '@contember/schema-definition'
|
|
2
|
+
import { SchemaBuilder, c, createSchema } from '@contember/schema-definition'
|
|
3
3
|
import { Model } from '@contember/schema'
|
|
4
4
|
import { SQL } from '../../src/tags'
|
|
5
5
|
|
|
6
6
|
testMigrations('rename entity without renaming a table', {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
original: {
|
|
8
|
+
model: new SchemaBuilder()
|
|
9
|
+
.entity('Author', e => e.tableName('user').column('name', c => c.type(Model.ColumnType.String)))
|
|
10
|
+
.entity('Post', e => e.column('title').manyHasOne('author', r => r.target('Author')))
|
|
11
|
+
.buildSchema(),
|
|
12
|
+
},
|
|
13
|
+
updated: {
|
|
14
|
+
model: new SchemaBuilder()
|
|
15
|
+
.entity('User', e => e.column('name', c => c.type(Model.ColumnType.String)))
|
|
16
|
+
.entity('Post', e => e.column('title').manyHasOne('author', r => r.target('User')))
|
|
17
|
+
.buildSchema(),
|
|
18
|
+
},
|
|
15
19
|
diff: [
|
|
16
20
|
{
|
|
17
21
|
modification: 'updateEntityName',
|
|
@@ -24,12 +28,16 @@ testMigrations('rename entity without renaming a table', {
|
|
|
24
28
|
})
|
|
25
29
|
|
|
26
30
|
testMigrations('rename entity and table', {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
original: {
|
|
32
|
+
model: new SchemaBuilder()
|
|
33
|
+
.entity('Author', e => e.column('name', c => c.type(Model.ColumnType.String)))
|
|
34
|
+
.buildSchema(),
|
|
35
|
+
},
|
|
36
|
+
updated: {
|
|
37
|
+
model: new SchemaBuilder()
|
|
38
|
+
.entity('User', e => e.column('name', c => c.type(Model.ColumnType.String)))
|
|
39
|
+
.buildSchema(),
|
|
40
|
+
},
|
|
33
41
|
diff: [
|
|
34
42
|
{
|
|
35
43
|
modification: 'updateEntityName',
|
|
@@ -45,14 +53,18 @@ testMigrations('rename entity and table', {
|
|
|
45
53
|
|
|
46
54
|
|
|
47
55
|
testMigrations('rename entity with one-has-one (constraint)', {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
original: {
|
|
57
|
+
model: new SchemaBuilder()
|
|
58
|
+
.entity('Author', e => e.oneHasOne('content', r => r.target('Content')))
|
|
59
|
+
.entity('Content', e => e.column('foo'))
|
|
60
|
+
.buildSchema(),
|
|
61
|
+
},
|
|
62
|
+
updated: {
|
|
63
|
+
model: new SchemaBuilder()
|
|
64
|
+
.entity('User', e => e.tableName('author').oneHasOne('content', r => r.target('Content')))
|
|
65
|
+
.entity('Content', e => e.column('foo'))
|
|
66
|
+
.buildSchema(),
|
|
67
|
+
},
|
|
56
68
|
diff: [
|
|
57
69
|
{
|
|
58
70
|
modification: 'updateEntityName',
|
|
@@ -65,20 +77,22 @@ testMigrations('rename entity with one-has-one (constraint)', {
|
|
|
65
77
|
})
|
|
66
78
|
|
|
67
79
|
testMigrations('rename table with acl', {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
original: {
|
|
81
|
+
model: new SchemaBuilder()
|
|
82
|
+
.entity('Site', entity => entity.column('name', c => c.type(Model.ColumnType.String)))
|
|
83
|
+
.buildSchema(),
|
|
84
|
+
acl: {
|
|
85
|
+
roles: {
|
|
86
|
+
admin: {
|
|
87
|
+
variables: {},
|
|
88
|
+
stages: '*',
|
|
89
|
+
entities: {
|
|
90
|
+
Site: {
|
|
91
|
+
predicates: {},
|
|
92
|
+
operations: {
|
|
93
|
+
read: {
|
|
94
|
+
id: true,
|
|
95
|
+
},
|
|
82
96
|
},
|
|
83
97
|
},
|
|
84
98
|
},
|
|
@@ -86,20 +100,22 @@ testMigrations('rename table with acl', {
|
|
|
86
100
|
},
|
|
87
101
|
},
|
|
88
102
|
},
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
+
updated: {
|
|
104
|
+
model: new SchemaBuilder()
|
|
105
|
+
.entity('Website', entity => entity.column('name', c => c.type(Model.ColumnType.String)).tableName('site'))
|
|
106
|
+
.buildSchema(),
|
|
107
|
+
acl: {
|
|
108
|
+
roles: {
|
|
109
|
+
admin: {
|
|
110
|
+
variables: {},
|
|
111
|
+
stages: '*',
|
|
112
|
+
entities: {
|
|
113
|
+
Website: {
|
|
114
|
+
predicates: {},
|
|
115
|
+
operations: {
|
|
116
|
+
read: {
|
|
117
|
+
id: true,
|
|
118
|
+
},
|
|
103
119
|
},
|
|
104
120
|
},
|
|
105
121
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { testMigrations } from '../../src/tests'
|
|
2
|
-
import { SchemaBuilder, SchemaDefinition as def } from '@contember/schema-definition'
|
|
2
|
+
import { createSchema, SchemaBuilder, SchemaDefinition as def } from '@contember/schema-definition'
|
|
3
3
|
import { Model } from '@contember/schema'
|
|
4
4
|
import { SQL } from '../../src/tags'
|
|
5
5
|
|
|
@@ -18,8 +18,8 @@ namespace SchemaWithOrderBy {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
testMigrations('update entity add order by', {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
original: createSchema(SchemaWithoutOrderBy),
|
|
22
|
+
updated: createSchema(SchemaWithOrderBy),
|
|
23
23
|
diff: [
|
|
24
24
|
{
|
|
25
25
|
modification: 'updateEntityOrderBy',
|
|
@@ -31,8 +31,8 @@ testMigrations('update entity add order by', {
|
|
|
31
31
|
})
|
|
32
32
|
|
|
33
33
|
testMigrations('update entity remove order by', {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
original: createSchema(SchemaWithOrderBy),
|
|
35
|
+
updated: createSchema(SchemaWithoutOrderBy),
|
|
36
36
|
diff: [
|
|
37
37
|
{
|
|
38
38
|
modification: 'updateEntityOrderBy',
|
|
@@ -4,22 +4,26 @@ import { Model } from '@contember/schema'
|
|
|
4
4
|
import { SQL } from '../../src/tags'
|
|
5
5
|
|
|
6
6
|
testMigrations('update enum', {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
e
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
7
|
+
original: {
|
|
8
|
+
model: new SchemaBuilder()
|
|
9
|
+
.entity('Post', e =>
|
|
10
|
+
e
|
|
11
|
+
.column('title', c => c.type(Model.ColumnType.String))
|
|
12
|
+
.column('status', c => c.type(Model.ColumnType.Enum, { enumName: 'postStatus' })),
|
|
13
|
+
)
|
|
14
|
+
.enum('postStatus', ['publish', 'draft', 'autodraft'])
|
|
15
|
+
.buildSchema(),
|
|
16
|
+
},
|
|
17
|
+
updated: {
|
|
18
|
+
model: new SchemaBuilder()
|
|
19
|
+
.entity('Post', e =>
|
|
20
|
+
e
|
|
21
|
+
.column('title', c => c.type(Model.ColumnType.String))
|
|
22
|
+
.column('status', c => c.type(Model.ColumnType.Enum, { enumName: 'postStatus' })),
|
|
23
|
+
)
|
|
24
|
+
.enum('postStatus', ['publish', 'draft'])
|
|
25
|
+
.buildSchema(),
|
|
26
|
+
},
|
|
23
27
|
diff: [
|
|
24
28
|
{
|
|
25
29
|
modification: 'updateEnum',
|
|
@@ -4,12 +4,16 @@ import { Acl, Model } from '@contember/schema'
|
|
|
4
4
|
import { SQL } from '../../src/tags'
|
|
5
5
|
|
|
6
6
|
testMigrations('rename a field', {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
original: {
|
|
8
|
+
model: new SchemaBuilder()
|
|
9
|
+
.entity('Author', e => e.column('firstName', c => c.type(Model.ColumnType.String).columnName('name')))
|
|
10
|
+
.buildSchema(),
|
|
11
|
+
},
|
|
12
|
+
updated: {
|
|
13
|
+
model: new SchemaBuilder()
|
|
14
|
+
.entity('Author', e => e.column('name', c => c.type(Model.ColumnType.String)))
|
|
15
|
+
.buildSchema(),
|
|
16
|
+
},
|
|
13
17
|
diff: [
|
|
14
18
|
{
|
|
15
19
|
modification: 'updateFieldName',
|
|
@@ -23,12 +27,16 @@ testMigrations('rename a field', {
|
|
|
23
27
|
})
|
|
24
28
|
|
|
25
29
|
testMigrations('rename a field with column', {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
original: {
|
|
31
|
+
model: new SchemaBuilder()
|
|
32
|
+
.entity('Author', e => e.column('firstName', c => c.type(Model.ColumnType.String)))
|
|
33
|
+
.buildSchema(),
|
|
34
|
+
},
|
|
35
|
+
updated: {
|
|
36
|
+
model: new SchemaBuilder()
|
|
37
|
+
.entity('Author', e => e.column('name', c => c.type(Model.ColumnType.String)))
|
|
38
|
+
.buildSchema(),
|
|
39
|
+
},
|
|
32
40
|
diff: [
|
|
33
41
|
{
|
|
34
42
|
modification: 'updateFieldName',
|
|
@@ -45,14 +53,18 @@ testMigrations('rename a field with column', {
|
|
|
45
53
|
|
|
46
54
|
|
|
47
55
|
testMigrations('rename a field with one-has-one', {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
original: {
|
|
57
|
+
model: new SchemaBuilder()
|
|
58
|
+
.entity('Author', e => e.oneHasOne('content', r => r.target('Content')))
|
|
59
|
+
.entity('Content', e => e.column('foo'))
|
|
60
|
+
.buildSchema(),
|
|
61
|
+
},
|
|
62
|
+
updated: {
|
|
63
|
+
model: new SchemaBuilder()
|
|
64
|
+
.entity('Author', e => e.oneHasOne('description', r => r.target('Content').joiningColumn('content_id')))
|
|
65
|
+
.entity('Content', e => e.column('foo'))
|
|
66
|
+
.buildSchema(),
|
|
67
|
+
},
|
|
56
68
|
diff: [
|
|
57
69
|
{
|
|
58
70
|
modification: 'updateFieldName',
|
|
@@ -66,16 +78,20 @@ testMigrations('rename a field with one-has-one', {
|
|
|
66
78
|
})
|
|
67
79
|
|
|
68
80
|
testMigrations('rename a relation', {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
original: {
|
|
82
|
+
model: new SchemaBuilder()
|
|
83
|
+
.entity('Post', e => e.column('title').manyHasOne('user', r => r.target('Author').inversedBy('posts')))
|
|
84
|
+
.entity('Author', e => e.column('name'))
|
|
85
|
+
.buildSchema(),
|
|
86
|
+
},
|
|
87
|
+
updated: {
|
|
88
|
+
model: new SchemaBuilder()
|
|
89
|
+
.entity('Post', e =>
|
|
90
|
+
e.column('title').manyHasOne('author', r => r.target('Author').inversedBy('posts').joiningColumn('user_id')),
|
|
91
|
+
)
|
|
92
|
+
.entity('Author', e => e.column('name'))
|
|
93
|
+
.buildSchema(),
|
|
94
|
+
},
|
|
79
95
|
diff: [
|
|
80
96
|
{
|
|
81
97
|
modification: 'updateFieldName',
|
|
@@ -90,16 +106,20 @@ testMigrations('rename a relation', {
|
|
|
90
106
|
|
|
91
107
|
|
|
92
108
|
testMigrations('rename a relation with joining column', {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
|
|
109
|
+
original: {
|
|
110
|
+
model: new SchemaBuilder()
|
|
111
|
+
.entity('Post', e => e.column('title').manyHasOne('user', r => r.target('Author').inversedBy('posts')))
|
|
112
|
+
.entity('Author', e => e.column('name'))
|
|
113
|
+
.buildSchema(),
|
|
114
|
+
},
|
|
115
|
+
updated: {
|
|
116
|
+
model: new SchemaBuilder()
|
|
117
|
+
.entity('Post', e =>
|
|
118
|
+
e.column('title').manyHasOne('author', r => r.target('Author').inversedBy('posts')),
|
|
119
|
+
)
|
|
120
|
+
.entity('Author', e => e.column('name'))
|
|
121
|
+
.buildSchema(),
|
|
122
|
+
},
|
|
103
123
|
diff: [
|
|
104
124
|
{
|
|
105
125
|
modification: 'updateFieldName',
|
|
@@ -115,39 +135,41 @@ testMigrations('rename a relation with joining column', {
|
|
|
115
135
|
|
|
116
136
|
|
|
117
137
|
testMigrations('rename relation with acl', {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
},
|
|
132
|
-
stages: '*',
|
|
133
|
-
entities: {
|
|
134
|
-
Post: {
|
|
135
|
-
predicates: {
|
|
136
|
-
author: { user: { id: 'authorId' } },
|
|
137
|
-
},
|
|
138
|
-
operations: {
|
|
139
|
-
read: {
|
|
140
|
-
title: 'author',
|
|
141
|
-
},
|
|
138
|
+
original: {
|
|
139
|
+
model: new SchemaBuilder()
|
|
140
|
+
.entity('Post', e => e.column('title').manyHasOne('user', r => r.target('Author').inversedBy('posts')))
|
|
141
|
+
.entity('Comment', e => e.column('content').manyHasOne('post', r => r.target('Post')))
|
|
142
|
+
.entity('Author', e => e.column('name'))
|
|
143
|
+
.buildSchema(),
|
|
144
|
+
acl: {
|
|
145
|
+
roles: {
|
|
146
|
+
admin: {
|
|
147
|
+
variables: {
|
|
148
|
+
authorId: {
|
|
149
|
+
type: Acl.VariableType.entity,
|
|
150
|
+
entityName: 'Author',
|
|
142
151
|
},
|
|
143
152
|
},
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
153
|
+
stages: '*',
|
|
154
|
+
entities: {
|
|
155
|
+
Post: {
|
|
156
|
+
predicates: {
|
|
157
|
+
author: { user: { id: 'authorId' } },
|
|
158
|
+
},
|
|
159
|
+
operations: {
|
|
160
|
+
read: {
|
|
161
|
+
title: 'author',
|
|
162
|
+
},
|
|
163
|
+
},
|
|
147
164
|
},
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
165
|
+
Comment: {
|
|
166
|
+
predicates: {
|
|
167
|
+
postAuthor: { post: { user: { id: 'authorId' } } },
|
|
168
|
+
},
|
|
169
|
+
operations: {
|
|
170
|
+
read: {
|
|
171
|
+
content: 'postAuthor',
|
|
172
|
+
},
|
|
151
173
|
},
|
|
152
174
|
},
|
|
153
175
|
},
|
|
@@ -155,41 +177,43 @@ testMigrations('rename relation with acl', {
|
|
|
155
177
|
},
|
|
156
178
|
},
|
|
157
179
|
},
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
},
|
|
174
|
-
stages: '*',
|
|
175
|
-
entities: {
|
|
176
|
-
Post: {
|
|
177
|
-
predicates: {
|
|
178
|
-
author: { author: { id: 'authorId' } },
|
|
179
|
-
},
|
|
180
|
-
operations: {
|
|
181
|
-
read: {
|
|
182
|
-
title: 'author',
|
|
183
|
-
},
|
|
180
|
+
updated: {
|
|
181
|
+
model: new SchemaBuilder()
|
|
182
|
+
.entity('Post', e =>
|
|
183
|
+
e.column('title').manyHasOne('author', r => r.target('Author').inversedBy('posts').joiningColumn('user_id')),
|
|
184
|
+
)
|
|
185
|
+
.entity('Comment', e => e.column('content').manyHasOne('post', r => r.target('Post')))
|
|
186
|
+
.entity('Author', e => e.column('name'))
|
|
187
|
+
.buildSchema(),
|
|
188
|
+
acl: {
|
|
189
|
+
roles: {
|
|
190
|
+
admin: {
|
|
191
|
+
variables: {
|
|
192
|
+
authorId: {
|
|
193
|
+
type: Acl.VariableType.entity,
|
|
194
|
+
entityName: 'Author',
|
|
184
195
|
},
|
|
185
196
|
},
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
197
|
+
stages: '*',
|
|
198
|
+
entities: {
|
|
199
|
+
Post: {
|
|
200
|
+
predicates: {
|
|
201
|
+
author: { author: { id: 'authorId' } },
|
|
202
|
+
},
|
|
203
|
+
operations: {
|
|
204
|
+
read: {
|
|
205
|
+
title: 'author',
|
|
206
|
+
},
|
|
207
|
+
},
|
|
189
208
|
},
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
209
|
+
Comment: {
|
|
210
|
+
predicates: {
|
|
211
|
+
postAuthor: { post: { author: { id: 'authorId' } } },
|
|
212
|
+
},
|
|
213
|
+
operations: {
|
|
214
|
+
read: {
|
|
215
|
+
content: 'postAuthor',
|
|
216
|
+
},
|
|
193
217
|
},
|
|
194
218
|
},
|
|
195
219
|
},
|
|
@@ -4,20 +4,24 @@ import { Model } from '@contember/schema'
|
|
|
4
4
|
import { SQL } from '../../src/tags'
|
|
5
5
|
|
|
6
6
|
testMigrations('update relation ondelete to cascade', {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
entity
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
original: {
|
|
8
|
+
model: new SchemaBuilder()
|
|
9
|
+
.entity('Post', entity =>
|
|
10
|
+
entity.column('name', c => c.type(Model.ColumnType.String)).manyHasOne('category', r => r.target('Category')),
|
|
11
|
+
)
|
|
12
|
+
.entity('Category', e => e.column('name', c => c.type(Model.ColumnType.String)))
|
|
13
|
+
.buildSchema(),
|
|
14
|
+
},
|
|
15
|
+
updated: {
|
|
16
|
+
model: new SchemaBuilder()
|
|
17
|
+
.entity('Post', entity =>
|
|
18
|
+
entity
|
|
19
|
+
.column('name', c => c.type(Model.ColumnType.String))
|
|
20
|
+
.manyHasOne('category', r => r.target('Category').onDelete(Model.OnDelete.cascade)),
|
|
21
|
+
)
|
|
22
|
+
.entity('Category', e => e.column('name', c => c.type(Model.ColumnType.String)))
|
|
23
|
+
.buildSchema(),
|
|
24
|
+
},
|
|
21
25
|
diff: [
|
|
22
26
|
{
|
|
23
27
|
modification: 'updateRelationOnDelete',
|