@contember/schema-migrations 1.4.6 → 1.4.7
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/modifications/columns/columnUtils.js +1 -1
- package/dist/src/modifications/columns/columnUtils.js.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/tests/cases/integration/createColumn.test.js +72 -2
- package/dist/tests/cases/integration/createColumn.test.js.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/modifications/columns/columnUtils.ts +1 -1
- package/tests/cases/integration/createColumn.test.ts +72 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/schema-migrations",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.7",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"typings": "dist/src/index.d.ts",
|
|
@@ -12,16 +12,16 @@
|
|
|
12
12
|
"test": "vitest --dir ./tests/cases"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@contember/database": "1.4.
|
|
16
|
-
"@contember/database-migrations": "1.4.
|
|
17
|
-
"@contember/engine-common": "1.4.
|
|
18
|
-
"@contember/schema": "1.4.
|
|
19
|
-
"@contember/schema-utils": "1.4.
|
|
15
|
+
"@contember/database": "1.4.7",
|
|
16
|
+
"@contember/database-migrations": "1.4.7",
|
|
17
|
+
"@contember/engine-common": "1.4.7",
|
|
18
|
+
"@contember/schema": "1.4.7",
|
|
19
|
+
"@contember/schema-utils": "1.4.7",
|
|
20
20
|
"fast-deep-equal": "^3.1.3",
|
|
21
21
|
"rfc6902": "^5.0.1"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@contember/schema-definition": "1.4.
|
|
24
|
+
"@contember/schema-definition": "1.4.7"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"pg": "^8.9.0"
|
|
@@ -36,7 +36,7 @@ export const formatSeedExpression = ({ model, entity, columnType, fillValue, cop
|
|
|
36
36
|
copyValue?: string
|
|
37
37
|
}): string | null => {
|
|
38
38
|
if (fillValue !== undefined) {
|
|
39
|
-
return escapeValue(fillValue)
|
|
39
|
+
return escapeValue(fillValue).toString()
|
|
40
40
|
} else if (copyValue !== undefined) {
|
|
41
41
|
const copyFrom = getColumnName(model, entity, copyValue)
|
|
42
42
|
return `${wrapIdentifier(copyFrom)}::${columnType}`
|
|
@@ -79,6 +79,10 @@ testMigrations('create a column with default value with "using"', {
|
|
|
79
79
|
updated: createSchema({
|
|
80
80
|
Author: class Author {
|
|
81
81
|
name = def.stringColumn().default('unnamed author').notNull()
|
|
82
|
+
order = def.intColumn().default(0).notNull()
|
|
83
|
+
score = def.doubleColumn().default(1 / 3).notNull()
|
|
84
|
+
active = def.boolColumn().default(false).notNull()
|
|
85
|
+
createdAt = def.dateTimeColumn().default('2024-01-01 10:00').notNull()
|
|
82
86
|
email = def.stringColumn().unique()
|
|
83
87
|
},
|
|
84
88
|
}),
|
|
@@ -97,7 +101,73 @@ testMigrations('create a column with default value with "using"', {
|
|
|
97
101
|
fillValue: 'unnamed author',
|
|
98
102
|
valueMigrationStrategy: 'using',
|
|
99
103
|
},
|
|
104
|
+
{
|
|
105
|
+
modification: 'createColumn',
|
|
106
|
+
entityName: 'Author',
|
|
107
|
+
field: {
|
|
108
|
+
columnName: 'order',
|
|
109
|
+
name: 'order',
|
|
110
|
+
nullable: false,
|
|
111
|
+
default: 0,
|
|
112
|
+
type: Model.ColumnType.Int,
|
|
113
|
+
columnType: 'integer',
|
|
114
|
+
},
|
|
115
|
+
fillValue: 0,
|
|
116
|
+
valueMigrationStrategy: 'using',
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
modification: 'createColumn',
|
|
120
|
+
entityName: 'Author',
|
|
121
|
+
field: {
|
|
122
|
+
columnName: 'score',
|
|
123
|
+
name: 'score',
|
|
124
|
+
nullable: false,
|
|
125
|
+
default: 0.3333333333333333,
|
|
126
|
+
type: Model.ColumnType.Double,
|
|
127
|
+
columnType: 'double precision',
|
|
128
|
+
},
|
|
129
|
+
fillValue: 0.3333333333333333,
|
|
130
|
+
valueMigrationStrategy: 'using',
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
modification: 'createColumn',
|
|
134
|
+
entityName: 'Author',
|
|
135
|
+
field: {
|
|
136
|
+
columnName: 'active',
|
|
137
|
+
name: 'active',
|
|
138
|
+
nullable: false,
|
|
139
|
+
default: false,
|
|
140
|
+
type: Model.ColumnType.Bool,
|
|
141
|
+
columnType: 'boolean',
|
|
142
|
+
},
|
|
143
|
+
fillValue: false,
|
|
144
|
+
valueMigrationStrategy: 'using',
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
modification: 'createColumn',
|
|
148
|
+
entityName: 'Author',
|
|
149
|
+
field: {
|
|
150
|
+
columnName: 'created_at',
|
|
151
|
+
name: 'createdAt',
|
|
152
|
+
nullable: false,
|
|
153
|
+
default: '2024-01-01 10:00',
|
|
154
|
+
type: Model.ColumnType.DateTime,
|
|
155
|
+
columnType: 'timestamptz',
|
|
156
|
+
},
|
|
157
|
+
fillValue: '2024-01-01 10:00',
|
|
158
|
+
valueMigrationStrategy: 'using',
|
|
159
|
+
},
|
|
100
160
|
],
|
|
101
|
-
sql: SQL`
|
|
102
|
-
ALTER TABLE "author"
|
|
161
|
+
sql: SQL`
|
|
162
|
+
ALTER TABLE "author" ADD "name" text;
|
|
163
|
+
ALTER TABLE "author" ALTER "name" SET DATA TYPE text USING $pga$unnamed author$pga$, ALTER "name" SET NOT NULL;
|
|
164
|
+
ALTER TABLE "author" ADD "order" integer;
|
|
165
|
+
ALTER TABLE "author" ALTER "order" SET DATA TYPE integer USING 0, ALTER "order" SET NOT NULL;
|
|
166
|
+
ALTER TABLE "author" ADD "score" double precision;
|
|
167
|
+
ALTER TABLE "author" ALTER "score" SET DATA TYPE double precision USING 0.3333333333333333, ALTER "score" SET NOT NULL;
|
|
168
|
+
ALTER TABLE "author" ADD "active" boolean;
|
|
169
|
+
ALTER TABLE "author" ALTER "active" SET DATA TYPE boolean USING false,
|
|
170
|
+
ALTER "active" SET NOT NULL; ALTER TABLE "author" ADD "created_at" timestamptz;
|
|
171
|
+
ALTER TABLE "author" ALTER "created_at" SET DATA TYPE timestamptz USING $pga$2024-01-01 10:00$pga$, ALTER "created_at" SET NOT NULL;
|
|
172
|
+
`,
|
|
103
173
|
})
|