@prisma-next/target-postgres 0.3.0-dev.10 → 0.3.0-dev.113
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/LICENSE +201 -0
- package/README.md +9 -2
- package/dist/control.d.mts +19 -0
- package/dist/control.d.mts.map +1 -0
- package/dist/control.mjs +3513 -0
- package/dist/control.mjs.map +1 -0
- package/dist/descriptor-meta-DxB8oZzB.mjs +13 -0
- package/dist/descriptor-meta-DxB8oZzB.mjs.map +1 -0
- package/dist/pack.d.mts +10 -0
- package/dist/pack.d.mts.map +1 -0
- package/dist/pack.mjs +9 -0
- package/dist/pack.mjs.map +1 -0
- package/dist/runtime.d.mts +9 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +21 -0
- package/dist/runtime.mjs.map +1 -0
- package/package.json +34 -33
- package/src/core/migrations/planner-identity-values.ts +129 -0
- package/src/core/migrations/planner-recipes.ts +83 -0
- package/src/core/migrations/planner-reconciliation.ts +613 -0
- package/src/core/migrations/planner-sql.ts +329 -0
- package/src/core/migrations/planner-target-details.ts +16 -0
- package/src/core/migrations/planner.ts +411 -406
- package/src/core/migrations/runner.ts +32 -36
- package/src/core/migrations/statement-builders.ts +9 -7
- package/src/core/types.ts +5 -0
- package/src/exports/control.ts +56 -8
- package/src/exports/pack.ts +5 -2
- package/src/exports/runtime.ts +7 -12
- package/dist/chunk-RKEXRSSI.js +0 -14
- package/dist/chunk-RKEXRSSI.js.map +0 -1
- package/dist/core/descriptor-meta.d.ts +0 -9
- package/dist/core/descriptor-meta.d.ts.map +0 -1
- package/dist/core/migrations/planner.d.ts +0 -14
- package/dist/core/migrations/planner.d.ts.map +0 -1
- package/dist/core/migrations/runner.d.ts +0 -8
- package/dist/core/migrations/runner.d.ts.map +0 -1
- package/dist/core/migrations/statement-builders.d.ts +0 -30
- package/dist/core/migrations/statement-builders.d.ts.map +0 -1
- package/dist/exports/control.d.ts +0 -8
- package/dist/exports/control.d.ts.map +0 -1
- package/dist/exports/control.js +0 -1255
- package/dist/exports/control.js.map +0 -1
- package/dist/exports/pack.d.ts +0 -4
- package/dist/exports/pack.d.ts.map +0 -1
- package/dist/exports/pack.js +0 -11
- package/dist/exports/pack.js.map +0 -1
- package/dist/exports/runtime.d.ts +0 -12
- package/dist/exports/runtime.d.ts.map +0 -1
- package/dist/exports/runtime.js +0 -19
- package/dist/exports/runtime.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor-meta-DxB8oZzB.mjs","names":[],"sources":["../src/core/descriptor-meta.ts"],"sourcesContent":["export const postgresTargetDescriptorMeta = {\n kind: 'target',\n familyId: 'sql',\n targetId: 'postgres',\n id: 'postgres',\n version: '0.0.1',\n capabilities: {},\n} as const;\n"],"mappings":";AAAA,MAAa,+BAA+B;CAC1C,MAAM;CACN,UAAU;CACV,UAAU;CACV,IAAI;CACJ,SAAS;CACT,cAAc,EAAE;CACjB"}
|
package/dist/pack.d.mts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CodecTypes } from "@prisma-next/adapter-postgres/codec-types";
|
|
2
|
+
import { TargetPackRef } from "@prisma-next/contract/framework-components";
|
|
3
|
+
|
|
4
|
+
//#region src/exports/pack.d.ts
|
|
5
|
+
declare const _default: TargetPackRef<"sql", "postgres"> & {
|
|
6
|
+
readonly __codecTypes?: CodecTypes;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { _default as default };
|
|
10
|
+
//# sourceMappingURL=pack.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pack.d.mts","names":[],"sources":["../src/exports/pack.ts"],"sourcesContent":[],"mappings":";;;;cACgF,UAKjD;0BACL;AANsD,CAAA"}
|
package/dist/pack.mjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { t as postgresTargetDescriptorMeta } from "./descriptor-meta-DxB8oZzB.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/exports/pack.ts
|
|
4
|
+
const postgresPack = postgresTargetDescriptorMeta;
|
|
5
|
+
var pack_default = postgresPack;
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { pack_default as default };
|
|
9
|
+
//# sourceMappingURL=pack.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pack.mjs","names":[],"sources":["../src/exports/pack.ts"],"sourcesContent":["import type { CodecTypes } from '@prisma-next/adapter-postgres/codec-types';\nimport type { TargetPackRef } from '@prisma-next/contract/framework-components';\nimport { postgresTargetDescriptorMeta } from '../core/descriptor-meta';\n\nconst postgresPack = postgresTargetDescriptorMeta;\n\nexport default postgresPack as TargetPackRef<'sql', 'postgres'> & {\n readonly __codecTypes?: CodecTypes;\n};\n"],"mappings":";;;AAIA,MAAM,eAAe;AAErB,mBAAe"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RuntimeTargetInstance } from "@prisma-next/core-execution-plane/types";
|
|
2
|
+
import { SqlRuntimeTargetDescriptor } from "@prisma-next/sql-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/exports/runtime.d.ts
|
|
5
|
+
interface PostgresRuntimeTargetInstance extends RuntimeTargetInstance<'sql', 'postgres'> {}
|
|
6
|
+
declare const postgresRuntimeTargetDescriptor: SqlRuntimeTargetDescriptor<'postgres', PostgresRuntimeTargetInstance>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { PostgresRuntimeTargetInstance, postgresRuntimeTargetDescriptor as default };
|
|
9
|
+
//# sourceMappingURL=runtime.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/exports/runtime.ts"],"sourcesContent":[],"mappings":";;;;UAKiB,6BAAA,SAAsC;AAAvD,cAEM,+BAFyC,EAER,0BAFqC,CAAA,UAAA,EAI1E,6BAJ0E,CAAA"}
|
package/dist/runtime.mjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { t as postgresTargetDescriptorMeta } from "./descriptor-meta-DxB8oZzB.mjs";
|
|
2
|
+
import { createCodecRegistry } from "@prisma-next/sql-relational-core/ast";
|
|
3
|
+
|
|
4
|
+
//#region src/exports/runtime.ts
|
|
5
|
+
const postgresRuntimeTargetDescriptor = {
|
|
6
|
+
...postgresTargetDescriptorMeta,
|
|
7
|
+
codecs: () => createCodecRegistry(),
|
|
8
|
+
operationSignatures: () => [],
|
|
9
|
+
parameterizedCodecs: () => [],
|
|
10
|
+
create() {
|
|
11
|
+
return {
|
|
12
|
+
familyId: "sql",
|
|
13
|
+
targetId: "postgres"
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var runtime_default = postgresRuntimeTargetDescriptor;
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { runtime_default as default };
|
|
21
|
+
//# sourceMappingURL=runtime.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.mjs","names":["postgresRuntimeTargetDescriptor: SqlRuntimeTargetDescriptor<\n 'postgres',\n PostgresRuntimeTargetInstance\n>"],"sources":["../src/exports/runtime.ts"],"sourcesContent":["import type { RuntimeTargetInstance } from '@prisma-next/core-execution-plane/types';\nimport { createCodecRegistry } from '@prisma-next/sql-relational-core/ast';\nimport type { SqlRuntimeTargetDescriptor } from '@prisma-next/sql-runtime';\nimport { postgresTargetDescriptorMeta } from '../core/descriptor-meta';\n\nexport interface PostgresRuntimeTargetInstance extends RuntimeTargetInstance<'sql', 'postgres'> {}\n\nconst postgresRuntimeTargetDescriptor: SqlRuntimeTargetDescriptor<\n 'postgres',\n PostgresRuntimeTargetInstance\n> = {\n ...postgresTargetDescriptorMeta,\n codecs: () => createCodecRegistry(),\n operationSignatures: () => [],\n parameterizedCodecs: () => [],\n create(): PostgresRuntimeTargetInstance {\n return {\n familyId: 'sql',\n targetId: 'postgres',\n };\n },\n};\n\nexport default postgresRuntimeTargetDescriptor;\n"],"mappings":";;;;AAOA,MAAMA,kCAGF;CACF,GAAG;CACH,cAAc,qBAAqB;CACnC,2BAA2B,EAAE;CAC7B,2BAA2B,EAAE;CAC7B,SAAwC;AACtC,SAAO;GACL,UAAU;GACV,UAAU;GACX;;CAEJ;AAED,sBAAe"}
|
package/package.json
CHANGED
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/target-postgres",
|
|
3
|
-
"version": "0.3.0-dev.
|
|
3
|
+
"version": "0.3.0-dev.113",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Postgres target pack for Prisma Next",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"arktype": "^2.0.0",
|
|
9
|
-
"@prisma-next/
|
|
10
|
-
"@prisma-next/
|
|
11
|
-
"@prisma-next/
|
|
12
|
-
"@prisma-next/core-control-plane": "0.3.0-dev.
|
|
13
|
-
"@prisma-next/
|
|
14
|
-
"@prisma-next/sql-contract": "0.3.0-dev.
|
|
15
|
-
"@prisma-next/sql-errors": "0.3.0-dev.
|
|
16
|
-
"@prisma-next/sql-
|
|
17
|
-
"@prisma-next/utils": "0.3.0-dev.
|
|
9
|
+
"@prisma-next/cli": "0.3.0-dev.113",
|
|
10
|
+
"@prisma-next/family-sql": "0.3.0-dev.113",
|
|
11
|
+
"@prisma-next/contract": "0.3.0-dev.113",
|
|
12
|
+
"@prisma-next/core-control-plane": "0.3.0-dev.113",
|
|
13
|
+
"@prisma-next/core-execution-plane": "0.3.0-dev.113",
|
|
14
|
+
"@prisma-next/sql-contract": "0.3.0-dev.113",
|
|
15
|
+
"@prisma-next/sql-errors": "0.3.0-dev.113",
|
|
16
|
+
"@prisma-next/sql-runtime": "0.3.0-dev.113",
|
|
17
|
+
"@prisma-next/utils": "0.3.0-dev.113",
|
|
18
|
+
"@prisma-next/sql-relational-core": "0.3.0-dev.113",
|
|
19
|
+
"@prisma-next/sql-schema-ir": "0.3.0-dev.113"
|
|
18
20
|
},
|
|
19
21
|
"devDependencies": {
|
|
20
|
-
"
|
|
21
|
-
"tsup": "8.5.1",
|
|
22
|
+
"tsdown": "0.18.4",
|
|
22
23
|
"typescript": "5.9.3",
|
|
23
|
-
"vitest": "4.0.
|
|
24
|
-
"@prisma-next/adapter-postgres": "0.3.0-dev.
|
|
25
|
-
"@prisma-next/driver-postgres": "0.3.0-dev.
|
|
26
|
-
"@prisma-next/
|
|
24
|
+
"vitest": "4.0.17",
|
|
25
|
+
"@prisma-next/adapter-postgres": "0.3.0-dev.113",
|
|
26
|
+
"@prisma-next/driver-postgres": "0.3.0-dev.113",
|
|
27
|
+
"@prisma-next/extension-pgvector": "0.3.0-dev.113",
|
|
28
|
+
"@prisma-next/test-utils": "0.0.1",
|
|
29
|
+
"@prisma-next/tsconfig": "0.0.0",
|
|
30
|
+
"@prisma-next/tsdown": "0.0.0"
|
|
27
31
|
},
|
|
28
32
|
"files": [
|
|
29
33
|
"dist",
|
|
@@ -31,27 +35,24 @@
|
|
|
31
35
|
"packs"
|
|
32
36
|
],
|
|
33
37
|
"exports": {
|
|
34
|
-
"./control":
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
"types": "./dist/exports/pack.d.ts",
|
|
44
|
-
"import": "./dist/exports/pack.js"
|
|
45
|
-
}
|
|
38
|
+
"./control": "./dist/control.mjs",
|
|
39
|
+
"./pack": "./dist/pack.mjs",
|
|
40
|
+
"./runtime": "./dist/runtime.mjs",
|
|
41
|
+
"./package.json": "./package.json"
|
|
42
|
+
},
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "https://github.com/prisma/prisma-next.git",
|
|
46
|
+
"directory": "packages/3-targets/3-targets/postgres"
|
|
46
47
|
},
|
|
47
48
|
"scripts": {
|
|
48
|
-
"build": "
|
|
49
|
+
"build": "tsdown",
|
|
49
50
|
"test": "vitest run --passWithNoTests",
|
|
50
51
|
"test:coverage": "vitest run --coverage --passWithNoTests",
|
|
51
52
|
"typecheck": "tsc --project tsconfig.json --noEmit",
|
|
52
|
-
"lint": "biome check . --
|
|
53
|
-
"lint:fix": "biome check --write .
|
|
54
|
-
"lint:fix:unsafe": "biome check --write --unsafe .
|
|
55
|
-
"clean": "
|
|
53
|
+
"lint": "biome check . --error-on-warnings",
|
|
54
|
+
"lint:fix": "biome check --write .",
|
|
55
|
+
"lint:fix:unsafe": "biome check --write --unsafe .",
|
|
56
|
+
"clean": "rm -rf dist dist-tsc dist-tsc-prod coverage .tmp-output"
|
|
56
57
|
}
|
|
57
58
|
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { CodecControlHooks } from '@prisma-next/family-sql/control';
|
|
2
|
+
import type { StorageColumn } from '@prisma-next/sql-contract/types';
|
|
3
|
+
import { ifDefined } from '@prisma-next/utils/defined';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Resolves the identity value (monoid neutral element) as a SQL literal for a column's type.
|
|
7
|
+
* Checks codec hooks first (extensions can provide type-specific identity values),
|
|
8
|
+
* then falls back to the built-in map.
|
|
9
|
+
*/
|
|
10
|
+
export function resolveIdentityValue(
|
|
11
|
+
column: StorageColumn,
|
|
12
|
+
codecHooks: Map<string, CodecControlHooks>,
|
|
13
|
+
): string | null {
|
|
14
|
+
if (column.codecId) {
|
|
15
|
+
const hookDefault = codecHooks.get(column.codecId)?.resolveIdentityValue?.({
|
|
16
|
+
nativeType: column.nativeType,
|
|
17
|
+
codecId: column.codecId,
|
|
18
|
+
...ifDefined('typeParams', column.typeParams),
|
|
19
|
+
});
|
|
20
|
+
if (hookDefault !== undefined) {
|
|
21
|
+
return hookDefault;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return buildBuiltinIdentityValue(column.nativeType, column.typeParams);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Returns the built-in identity value (monoid neutral element) as a SQL literal for the given
|
|
30
|
+
* PostgreSQL native type — e.g. 0 for integers, '' for text, false for booleans.
|
|
31
|
+
*
|
|
32
|
+
* This is the planner's fallback when no codec hook provides a type-specific identity value.
|
|
33
|
+
*
|
|
34
|
+
* Returns null for unrecognized types (for example enums and extension-owned types without a
|
|
35
|
+
* hook), which causes the planner to fall back to the empty-table precheck.
|
|
36
|
+
*
|
|
37
|
+
* @internal Exported for testing only.
|
|
38
|
+
*/
|
|
39
|
+
export function buildBuiltinIdentityValue(
|
|
40
|
+
nativeType: string,
|
|
41
|
+
typeParams?: Record<string, unknown>,
|
|
42
|
+
): string | null {
|
|
43
|
+
const normalizedNativeType = normalizeIdentityValueNativeType(nativeType);
|
|
44
|
+
|
|
45
|
+
if (normalizedNativeType.endsWith('[]')) {
|
|
46
|
+
return "'{}'";
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
switch (normalizedNativeType) {
|
|
50
|
+
case 'text':
|
|
51
|
+
case 'character':
|
|
52
|
+
case 'bpchar':
|
|
53
|
+
case 'character varying':
|
|
54
|
+
case 'varchar':
|
|
55
|
+
return "''";
|
|
56
|
+
|
|
57
|
+
case 'int2':
|
|
58
|
+
case 'int4':
|
|
59
|
+
case 'int8':
|
|
60
|
+
case 'integer':
|
|
61
|
+
case 'bigint':
|
|
62
|
+
case 'smallint':
|
|
63
|
+
case 'float4':
|
|
64
|
+
case 'float8':
|
|
65
|
+
case 'real':
|
|
66
|
+
case 'double precision':
|
|
67
|
+
case 'numeric':
|
|
68
|
+
case 'decimal':
|
|
69
|
+
return '0';
|
|
70
|
+
|
|
71
|
+
case 'bool':
|
|
72
|
+
case 'boolean':
|
|
73
|
+
return 'false';
|
|
74
|
+
|
|
75
|
+
case 'uuid':
|
|
76
|
+
return "'00000000-0000-0000-0000-000000000000'";
|
|
77
|
+
|
|
78
|
+
case 'json':
|
|
79
|
+
return "'{}'::json";
|
|
80
|
+
case 'jsonb':
|
|
81
|
+
return "'{}'::jsonb";
|
|
82
|
+
|
|
83
|
+
case 'date':
|
|
84
|
+
case 'timestamp':
|
|
85
|
+
case 'timestamptz':
|
|
86
|
+
case 'timestamp with time zone':
|
|
87
|
+
case 'timestamp without time zone':
|
|
88
|
+
return "'epoch'";
|
|
89
|
+
|
|
90
|
+
case 'time':
|
|
91
|
+
case 'time without time zone':
|
|
92
|
+
return "'00:00:00'";
|
|
93
|
+
case 'timetz':
|
|
94
|
+
case 'time with time zone':
|
|
95
|
+
return "'00:00:00+00'";
|
|
96
|
+
|
|
97
|
+
case 'interval':
|
|
98
|
+
return "'0'";
|
|
99
|
+
|
|
100
|
+
case 'bytea':
|
|
101
|
+
return "''::bytea";
|
|
102
|
+
case 'tsvector':
|
|
103
|
+
return "''::tsvector";
|
|
104
|
+
|
|
105
|
+
case 'bit':
|
|
106
|
+
return buildBitIdentityValue(typeParams);
|
|
107
|
+
case 'bit varying':
|
|
108
|
+
case 'varbit':
|
|
109
|
+
return "B''";
|
|
110
|
+
|
|
111
|
+
default:
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function normalizeIdentityValueNativeType(nativeType: string): string {
|
|
117
|
+
return nativeType.trim().toLowerCase().replace(/\s+/g, ' ');
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function buildBitIdentityValue(typeParams?: Record<string, unknown>): string | null {
|
|
121
|
+
const length = typeParams?.['length'];
|
|
122
|
+
if (length === undefined) {
|
|
123
|
+
return "B'0'";
|
|
124
|
+
}
|
|
125
|
+
if (typeof length !== 'number' || !Number.isInteger(length) || length <= 0) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
return `B'${'0'.repeat(length)}'`;
|
|
129
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { quoteIdentifier } from '@prisma-next/adapter-postgres/control';
|
|
2
|
+
import type { CodecControlHooks, SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';
|
|
3
|
+
import type { StorageColumn } from '@prisma-next/sql-contract/types';
|
|
4
|
+
import type { PostgresPlanTargetDetails } from './planner';
|
|
5
|
+
import {
|
|
6
|
+
buildAddColumnSql,
|
|
7
|
+
columnExistsCheck,
|
|
8
|
+
columnHasNoDefaultCheck,
|
|
9
|
+
columnNullabilityCheck,
|
|
10
|
+
qualifyTableName,
|
|
11
|
+
} from './planner-sql';
|
|
12
|
+
import { buildTargetDetails } from './planner-target-details';
|
|
13
|
+
|
|
14
|
+
export function buildAddColumnOperationIdentity(
|
|
15
|
+
schema: string,
|
|
16
|
+
tableName: string,
|
|
17
|
+
columnName: string,
|
|
18
|
+
): Pick<
|
|
19
|
+
SqlMigrationPlanOperation<PostgresPlanTargetDetails>,
|
|
20
|
+
'id' | 'label' | 'summary' | 'target'
|
|
21
|
+
> {
|
|
22
|
+
return {
|
|
23
|
+
id: `column.${tableName}.${columnName}`,
|
|
24
|
+
label: `Add column ${columnName} to ${tableName}`,
|
|
25
|
+
summary: `Adds column ${columnName} to table ${tableName}`,
|
|
26
|
+
target: {
|
|
27
|
+
id: 'postgres',
|
|
28
|
+
details: buildTargetDetails('table', tableName, schema),
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function buildAddNotNullColumnWithTemporaryDefaultOperation(options: {
|
|
34
|
+
readonly schema: string;
|
|
35
|
+
readonly tableName: string;
|
|
36
|
+
readonly columnName: string;
|
|
37
|
+
readonly column: StorageColumn;
|
|
38
|
+
readonly codecHooks: Map<string, CodecControlHooks>;
|
|
39
|
+
readonly temporaryDefault: string;
|
|
40
|
+
}): SqlMigrationPlanOperation<PostgresPlanTargetDetails> {
|
|
41
|
+
const { schema, tableName, columnName, column, codecHooks, temporaryDefault } = options;
|
|
42
|
+
const qualified = qualifyTableName(schema, tableName);
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
...buildAddColumnOperationIdentity(schema, tableName, columnName),
|
|
46
|
+
operationClass: 'additive',
|
|
47
|
+
precheck: [
|
|
48
|
+
{
|
|
49
|
+
description: `ensure column "${columnName}" is missing`,
|
|
50
|
+
sql: columnExistsCheck({ schema, table: tableName, column: columnName, exists: false }),
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
execute: [
|
|
54
|
+
{
|
|
55
|
+
description: `add column "${columnName}"`,
|
|
56
|
+
sql: buildAddColumnSql(qualified, columnName, column, codecHooks, temporaryDefault),
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
description: `drop temporary default from column "${columnName}"`,
|
|
60
|
+
sql: `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} DROP DEFAULT`,
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
postcheck: [
|
|
64
|
+
{
|
|
65
|
+
description: `verify column "${columnName}" exists`,
|
|
66
|
+
sql: columnExistsCheck({ schema, table: tableName, column: columnName }),
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
description: `verify column "${columnName}" is NOT NULL`,
|
|
70
|
+
sql: columnNullabilityCheck({
|
|
71
|
+
schema,
|
|
72
|
+
table: tableName,
|
|
73
|
+
column: columnName,
|
|
74
|
+
nullable: false,
|
|
75
|
+
}),
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
description: `verify column "${columnName}" has no default after temporary default removal`,
|
|
79
|
+
sql: columnHasNoDefaultCheck({ schema, table: tableName, column: columnName }),
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
};
|
|
83
|
+
}
|