@prisma/orm-target-postgres 8.0.0-rc.17-dev.37 → 8.0.0-rc.17-dev.38
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/{adapter-C0SKPLzt-D3_mXLaM.mjs → adapter-C0SKPLzt-flxKm2YQ.mjs} +5 -5
- package/dist/{adapter-C0SKPLzt-D3_mXLaM.mjs.map → adapter-C0SKPLzt-flxKm2YQ.mjs.map} +1 -1
- package/dist/adapter.mjs +5 -5
- package/dist/adapter__adapter.mjs +2 -2
- package/dist/adapter__control.mjs +6 -6
- package/dist/adapter__runtime.mjs +4 -4
- package/dist/adapter__sql-renderer.mjs +1 -1
- package/dist/{authoring-kZOSollq-DP0v31A_.mjs → authoring-CTn87jlt-VHX7hiNU.mjs} +5 -5
- package/dist/{authoring-kZOSollq-DP0v31A_.mjs.map → authoring-CTn87jlt-VHX7hiNU.mjs.map} +1 -1
- package/dist/autoincrement-widths-DbyXRo5B-BUVCYb_V.mjs +39 -0
- package/dist/autoincrement-widths-DbyXRo5B-BUVCYb_V.mjs.map +1 -0
- package/dist/{check-expressions-BaFrBceq-ChgvazEN.mjs → check-expressions-CVLs1Cgf-DaMRk-Q4.mjs} +3 -3
- package/dist/{check-expressions-BaFrBceq-ChgvazEN.mjs.map → check-expressions-CVLs1Cgf-DaMRk-Q4.mjs.map} +1 -1
- package/dist/{codec-registry-CKBDkxX7-Kw84Or3s.mjs → codec-registry-BWUY_QLt-CzrMkP9N.mjs} +4 -4
- package/dist/{codec-registry-CKBDkxX7-Kw84Or3s.mjs.map → codec-registry-BWUY_QLt-CzrMkP9N.mjs.map} +1 -1
- package/dist/{codecs-BK3J4C0n-B8EnUXZf.mjs → codecs-Cb5S70Lx-WRSQkpza.mjs} +3 -3
- package/dist/{codecs-BK3J4C0n-B8EnUXZf.mjs.map → codecs-Cb5S70Lx-WRSQkpza.mjs.map} +1 -1
- package/dist/{contract-free-DjI-gclO.mjs → contract-free-spGyVyoh.mjs} +3 -3
- package/dist/{contract-free-DjI-gclO.mjs.map → contract-free-spGyVyoh.mjs.map} +1 -1
- package/dist/{control-DJo3P3yL.mjs → control-C4-UbYOH.mjs} +6 -3
- package/dist/control-C4-UbYOH.mjs.map +1 -0
- package/dist/{control-C5pTVhtN.mjs → control-DnqvbRrL.mjs} +105 -23
- package/dist/control-DnqvbRrL.mjs.map +1 -0
- package/dist/{control-adapter-CEeF_Na4-CMRZNp7S.mjs → control-adapter-CEeF_Na4-Cp6Si4hD.mjs} +6 -6
- package/dist/{control-adapter-CEeF_Na4-CMRZNp7S.mjs.map → control-adapter-CEeF_Na4-Cp6Si4hD.mjs.map} +1 -1
- package/dist/{control-policy-C5VoaD11-lzAw5cjN.mjs → control-policy-DXaIsgUW-Btyo9Vs8.mjs} +172 -130
- package/dist/control-policy-DXaIsgUW-Btyo9Vs8.mjs.map +1 -0
- package/dist/data-transform-C-3UJ3hC.d.mts +1 -0
- package/dist/{data-transform-Bo32KRbq-BLn1_UG-.mjs → data-transform-CtHnNYhF-r19375h3.mjs} +11 -4
- package/dist/data-transform-CtHnNYhF-r19375h3.mjs.map +1 -0
- package/dist/{data-transform-Ck5FbyNO-BNE7QlAo.d.mts → data-transform-nGy9rz87-CEOXAj91.d.mts} +14 -3
- package/dist/data-transform-nGy9rz87-CEOXAj91.d.mts.map +1 -0
- package/dist/{data-type-entries-DoR61yeO-BB2cY7rI.mjs → data-type-entries-15a-vBdm-vIj5l1u5.mjs} +3 -3
- package/dist/{data-type-entries-DoR61yeO-BB2cY7rI.mjs.map → data-type-entries-15a-vBdm-vIj5l1u5.mjs.map} +1 -1
- package/dist/{data-types-DRkmmE9S-C5Q9oH4Q.mjs → data-types-K6tDhu1D-BN--9o1o.mjs} +3 -3
- package/dist/{data-types-DRkmmE9S-C5Q9oH4Q.mjs.map → data-types-K6tDhu1D-BN--9o1o.mjs.map} +1 -1
- package/dist/{ddl-CFWv3VOT-Ad-I5p22.mjs → ddl-BKqbtVN3-CPHiYaCY.mjs} +3 -3
- package/dist/{ddl-CFWv3VOT-Ad-I5p22.mjs.map → ddl-BKqbtVN3-CPHiYaCY.mjs.map} +1 -1
- package/dist/{descriptor-meta-Dekti3e8-DLSepvAq.mjs → descriptor-meta-D5OipARb-6znWwvjE.mjs} +8 -8
- package/dist/{descriptor-meta-Dekti3e8-DLSepvAq.mjs.map → descriptor-meta-D5OipARb-6znWwvjE.mjs.map} +1 -1
- package/dist/{descriptor-meta-DyjDJfnQ-5lgalclQ.mjs → descriptor-meta-DyjDJfnQ-CoD4Kmpz.mjs} +3 -3
- package/dist/{descriptor-meta-DyjDJfnQ-5lgalclQ.mjs.map → descriptor-meta-DyjDJfnQ-CoD4Kmpz.mjs.map} +1 -1
- package/dist/{descriptor-meta-runtime-iArZEoCE-GhLNDdg-.mjs → descriptor-meta-runtime-D4a-hsd_-B_YkwgHQ.mjs} +3 -3
- package/dist/{descriptor-meta-runtime-iArZEoCE-GhLNDdg-.mjs.map → descriptor-meta-runtime-D4a-hsd_-B_YkwgHQ.mjs.map} +1 -1
- package/dist/{diff-database-schema-CUSXh2y2-CWRGCPL7.mjs → diff-database-schema-BV6Px0Gg-DAC6TL3P.mjs} +6 -6
- package/dist/{diff-database-schema-CUSXh2y2-CWRGCPL7.mjs.map → diff-database-schema-BV6Px0Gg-DAC6TL3P.mjs.map} +1 -1
- package/dist/driver.mjs +1 -1
- package/dist/driver__control.mjs +1 -1
- package/dist/{errors-DZ3zQdpT.d.mts → errors-D5sJ0fgp.d.mts} +2 -2
- package/dist/{errors-DZ3zQdpT.d.mts.map → errors-D5sJ0fgp.d.mts.map} +1 -1
- package/dist/{full-text-search-document-DJd-9K-K-CuV_QLH3.mjs → full-text-search-document-DYNz29YC-CfVTPwIL.mjs} +3 -3
- package/dist/{full-text-search-document-DJd-9K-K-CuV_QLH3.mjs.map → full-text-search-document-DYNz29YC-CfVTPwIL.mjs.map} +1 -1
- package/dist/indexes-BWHRVhke-vqXUnRfT.d.mts +49 -0
- package/dist/indexes-BWHRVhke-vqXUnRfT.d.mts.map +1 -0
- package/dist/{infer-psl-contract-BCPaLzjl-ByBJpE6R.mjs → infer-psl-contract-B_Bl_RJC-BfJbvDUs.mjs} +6 -6
- package/dist/{infer-psl-contract-BCPaLzjl-ByBJpE6R.mjs.map → infer-psl-contract-B_Bl_RJC-BfJbvDUs.mjs.map} +1 -1
- package/dist/{issue-planner-BLOtwO3z.d.mts → issue-planner-BiJDKtW5.d.mts} +10 -3
- package/dist/issue-planner-BiJDKtW5.d.mts.map +1 -0
- package/dist/migration-C9ZH26Nj.mjs.map +1 -1
- package/dist/{migration-CQeS0oqg.d.mts → migration-NJo7cPpB.d.mts} +6 -6
- package/dist/{migration-CQeS0oqg.d.mts.map → migration-NJo7cPpB.d.mts.map} +1 -1
- package/dist/{op-factory-call-DF9ijUbg-CSF8ZhJM.d.mts → op-factory-call-DkaMatJ4-D_7fWo-v.d.mts} +46 -87
- package/dist/op-factory-call-DkaMatJ4-D_7fWo-v.d.mts.map +1 -0
- package/dist/op-factory-call-LGCmMtZM.d.mts +1 -0
- package/dist/{op-factory-call-DiwaNQVO-NSekrcmI.mjs → op-factory-call-ltgiEZ8g-CX6WX57X.mjs} +163 -99
- package/dist/op-factory-call-ltgiEZ8g-CX6WX57X.mjs.map +1 -0
- package/dist/{planner-DCYVwcYk-vGUsjG3x.mjs → planner-Ccn9yxL7-B6Pgoz6c.mjs} +95 -18
- package/dist/planner-Ccn9yxL7-B6Pgoz6c.mjs.map +1 -0
- package/dist/{planner-C6vpC6nq.d.mts → planner-Xei8enE-.d.mts} +5 -4
- package/dist/planner-Xei8enE-.d.mts.map +1 -0
- package/dist/{planner-ddl-builders-Y0_96xpe-BzugdEDO.mjs → planner-ddl-builders-BcJ353Wj-Dfaixf4X.mjs} +6 -38
- package/dist/planner-ddl-builders-BcJ353Wj-Dfaixf4X.mjs.map +1 -0
- package/dist/{planner-identity-values-CRS2cQ6v-DakZeIQj.mjs → planner-identity-values-BZdomjRU-G521DabU.mjs} +3 -3
- package/dist/{planner-identity-values-CRS2cQ6v-DakZeIQj.mjs.map → planner-identity-values-BZdomjRU-G521DabU.mjs.map} +1 -1
- package/dist/{planner-produced-postgres-migration-BPk0jQUi-BFV5JJn1.mjs → planner-produced-postgres-migration-Brgj59VY-DOOLRWyy.mjs} +4 -4
- package/dist/{planner-produced-postgres-migration-BPk0jQUi-BFV5JJn1.mjs.map → planner-produced-postgres-migration-Brgj59VY-DOOLRWyy.mjs.map} +1 -1
- package/dist/planner-produced-postgres-migration-DgyIhdpw.d.mts +1 -0
- package/dist/{planner-produced-postgres-migration-CoLy4THO-CkCRWsv_.d.mts → planner-produced-postgres-migration-MoopN05f-CfmsQNwj.d.mts} +3 -3
- package/dist/planner-produced-postgres-migration-MoopN05f-CfmsQNwj.d.mts.map +1 -0
- package/dist/{planner-schema-lookup-kMIVP2y--CdO4VlnF.mjs → planner-schema-lookup-CdgWer9s.mjs} +2 -2
- package/dist/planner-schema-lookup-CdgWer9s.mjs.map +1 -0
- package/dist/{planner-sql-checks-CXDdt_9m.d.mts → planner-sql-checks-C54jJ5qt.d.mts} +16 -2
- package/dist/planner-sql-checks-C54jJ5qt.d.mts.map +1 -0
- package/dist/planner-sql-checks-CX37qDix-Gkq38UQQ.mjs +108 -0
- package/dist/planner-sql-checks-CX37qDix-Gkq38UQQ.mjs.map +1 -0
- package/dist/planner-target-details-CUEF0s90-COTks5yz.mjs +14 -0
- package/dist/planner-target-details-CUEF0s90-COTks5yz.mjs.map +1 -0
- package/dist/{postgres-codec-traits-BUygtI9N-CB-uwvY1.mjs → postgres-codec-traits-BV62PF0L-NuMNArAx.mjs} +3 -3
- package/dist/{postgres-codec-traits-BUygtI9N-CB-uwvY1.mjs.map → postgres-codec-traits-BV62PF0L-NuMNArAx.mjs.map} +1 -1
- package/dist/{postgres-contract-view-6xGfZyGS-C58Bint3.mjs → postgres-contract-view-3yxlqPfK-CRFLsRHu.mjs} +7 -7
- package/dist/{postgres-contract-view-6xGfZyGS-C58Bint3.mjs.map → postgres-contract-view-3yxlqPfK-CRFLsRHu.mjs.map} +1 -1
- package/dist/{postgres-migration-BSvGOQze-WEc_3gN0.mjs → postgres-migration-CLIfS2iQ-BgnVMLRT.mjs} +63 -20
- package/dist/postgres-migration-CLIfS2iQ-BgnVMLRT.mjs.map +1 -0
- package/dist/{postgres-migration-Dajq9YrO-_sZwyRnK.d.mts → postgres-migration-D5OiThXV-CihIARAE.d.mts} +27 -8
- package/dist/{postgres-migration-Dajq9YrO-_sZwyRnK.d.mts.map → postgres-migration-D5OiThXV-CihIARAE.d.mts.map} +1 -1
- package/dist/{postgres-schema-DIaAgaL6-Dmqzjbu5.mjs → postgres-schema-Ysxbqkzr-hFRwS-zT.mjs} +3 -3
- package/dist/{postgres-schema-DIaAgaL6-Dmqzjbu5.mjs.map → postgres-schema-Ysxbqkzr-hFRwS-zT.mjs.map} +1 -1
- package/dist/{prisma7-binding-DQlvZyAM.mjs → prisma7-binding-nxvUgQTH.mjs} +6 -6
- package/dist/{prisma7-binding-DQlvZyAM.mjs.map → prisma7-binding-nxvUgQTH.mjs.map} +1 -1
- package/dist/{render-ops-D1lOuFbE-d95NrYqF.mjs → render-ops-Cw9B6aq6-CMzRGNUZ.mjs} +3 -3
- package/dist/{render-ops-D1lOuFbE-d95NrYqF.mjs.map → render-ops-Cw9B6aq6-CMzRGNUZ.mjs.map} +1 -1
- package/dist/{resolve-ddl-schema-b746rtzf-Dydnc_gK.mjs → resolve-ddl-schema-BvsUhPsJ-CY5uEwIr.mjs} +3 -3
- package/dist/{resolve-ddl-schema-b746rtzf-Dydnc_gK.mjs.map → resolve-ddl-schema-BvsUhPsJ-CY5uEwIr.mjs.map} +1 -1
- package/dist/{sql-renderer-DT4IEOVi-CBE8uTub.mjs → sql-renderer-DT4IEOVi-CGCgCiTV.mjs} +3 -3
- package/dist/{sql-renderer-DT4IEOVi-CBE8uTub.mjs.map → sql-renderer-DT4IEOVi-CGCgCiTV.mjs.map} +1 -1
- package/dist/{sql-utils-CVsvXiX4-C7xD0Bgv.mjs → sql-utils-Df-nf6eM-Ov1KgjWm.mjs} +24 -3
- package/dist/{sql-utils-CVsvXiX4-C7xD0Bgv.mjs.map → sql-utils-Df-nf6eM-Ov1KgjWm.mjs.map} +1 -1
- package/dist/target.d.mts +13 -13
- package/dist/target.mjs +29 -29
- package/dist/target__codecs.mjs +2 -2
- package/dist/target__contract-free.mjs +3 -3
- package/dist/target__control.mjs +3 -3
- package/dist/target__data-transform.d.mts +2 -2
- package/dist/target__data-transform.mjs +1 -1
- package/dist/target__data-types.mjs +2 -2
- package/dist/target__diff-database-schema.mjs +1 -1
- package/dist/target__errors.d.mts +1 -1
- package/dist/target__full-text-index-authoring.mjs +1 -1
- package/dist/target__issue-planner.d.mts +1 -1
- package/dist/target__issue-planner.mjs +1 -1
- package/dist/target__migration.d.mts +3 -3
- package/dist/target__migration.mjs +3 -3
- package/dist/target__op-factory-call.d.mts +3 -3
- package/dist/target__op-factory-call.mjs +2 -2
- package/dist/target__pack.mjs +1 -1
- package/dist/target__planner-ddl-builders.mjs +1 -1
- package/dist/target__planner-identity-values.mjs +1 -1
- package/dist/target__planner-produced-postgres-migration.d.mts +2 -2
- package/dist/target__planner-produced-postgres-migration.mjs +1 -1
- package/dist/target__planner-schema-lookup.mjs +1 -1
- package/dist/target__planner-sql-checks.d.mts +2 -2
- package/dist/target__planner-sql-checks.mjs +2 -2
- package/dist/target__planner.d.mts +1 -1
- package/dist/target__planner.mjs +2 -2
- package/dist/target__prisma7-binding.mjs +1 -1
- package/dist/target__render-ops.mjs +1 -1
- package/dist/target__runtime.mjs +4 -4
- package/dist/target__runtime.mjs.map +1 -1
- package/dist/target__schema-ir-annotations.mjs +1 -1
- package/dist/target__sql-utils.mjs +2 -2
- package/dist/target__types.mjs +2 -2
- package/package.json +9 -9
- package/dist/control-C5pTVhtN.mjs.map +0 -1
- package/dist/control-DJo3P3yL.mjs.map +0 -1
- package/dist/control-policy-C5VoaD11-lzAw5cjN.mjs.map +0 -1
- package/dist/data-transform-BSM7TQpE.d.mts +0 -1
- package/dist/data-transform-Bo32KRbq-BLn1_UG-.mjs.map +0 -1
- package/dist/data-transform-Ck5FbyNO-BNE7QlAo.d.mts.map +0 -1
- package/dist/issue-planner-BLOtwO3z.d.mts.map +0 -1
- package/dist/op-factory-call-CBqqbXBb.d.mts +0 -1
- package/dist/op-factory-call-DF9ijUbg-CSF8ZhJM.d.mts.map +0 -1
- package/dist/op-factory-call-DiwaNQVO-NSekrcmI.mjs.map +0 -1
- package/dist/planner-C6vpC6nq.d.mts.map +0 -1
- package/dist/planner-DCYVwcYk-vGUsjG3x.mjs.map +0 -1
- package/dist/planner-ddl-builders-Y0_96xpe-BzugdEDO.mjs.map +0 -1
- package/dist/planner-produced-postgres-migration-CoLy4THO-CkCRWsv_.d.mts.map +0 -1
- package/dist/planner-produced-postgres-migration-D7zijd5s.d.mts +0 -1
- package/dist/planner-schema-lookup-kMIVP2y--CdO4VlnF.mjs.map +0 -1
- package/dist/planner-sql-checks-Bt_KuSiH-CdGZDp7M.mjs +0 -46
- package/dist/planner-sql-checks-Bt_KuSiH-CdGZDp7M.mjs.map +0 -1
- package/dist/planner-sql-checks-CXDdt_9m.d.mts.map +0 -1
- package/dist/postgres-migration-BSvGOQze-WEc_3gN0.mjs.map +0 -1
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { s as postgresError } from "./errors-DYyzTYzE-39CV_aMo.mjs";
|
|
2
|
-
import { _ as pgInt8, f as pgFloat4, g as pgInt4, h as pgInt2, p as pgFloat8 } from "./data-types-
|
|
3
|
-
import { d as isPostgresSchema } from "./postgres-schema-
|
|
2
|
+
import { A as pgTimestamptz, E as pgTime, I as pgVarbit, L as pgVarchar, M as pgTimetz, O as pgTimestamp, R as postgresDataTypes, _ as pgInt8, f as pgFloat4, g as pgInt4, h as pgInt2, p as pgFloat8, w as pgText, x as pgNumeric } from "./data-types-K6tDhu1D-BN--9o1o.mjs";
|
|
3
|
+
import { d as isPostgresSchema } from "./postgres-schema-Ysxbqkzr-hFRwS-zT.mjs";
|
|
4
4
|
import { n as PostgresSchemaNodeKind, o as postgresNodeEntityKind, r as PostgresTableSchemaNode, t as PostgresNativeEnumSchemaNode } from "./postgres-table-schema-node-BBkitBQh-DT1T5VWU.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import { t as
|
|
7
|
-
import { C as DropNativeEnumTypeCall, D as EnableRowLevelSecurityCall, E as DropTableCall, F as SetNotNullCall,
|
|
8
|
-
import {
|
|
5
|
+
import { i as stackDataTypes } from "./planner-sql-checks-CX37qDix-Gkq38UQQ.mjs";
|
|
6
|
+
import { t as buildTargetDetails } from "./planner-target-details-CUEF0s90-COTks5yz.mjs";
|
|
7
|
+
import { C as DropNativeEnumTypeCall, D as EnableRowLevelSecurityCall, E as DropTableCall, F as SetNotNullCall, L as columnNameOfCall, O as RawSqlCall, P as SetDefaultCall, S as DropIndexCall, V as postgresDefaultToDdlColumnDefault, _ as DisableRowLevelSecurityCall, a as AddNativeEnumValueCall, b as DropConstraintCall, c as AddUniqueCall, d as CreateIndexCall, f as CreateNativeEnumTypeCall, g as DataTransformCall, h as CreateTableCall, i as AddForeignKeyCall, l as AlterColumnTypeCall, m as CreateSchemaCall, n as AddColumnCall, o as AddPrimaryKeyCall, r as AddColumnWithTemporaryDefaultCall, s as AddRequiredColumnToEmptyTableCall, t as AddCheckConstraintCall, v as DropCheckConstraintCall, w as DropNotNullCall, x as DropDefaultCall, y as DropColumnCall } from "./op-factory-call-ltgiEZ8g-CX6WX57X.mjs";
|
|
8
|
+
import { t as buildColumnTypeSql } from "./planner-ddl-builders-BcJ353Wj-Dfaixf4X.mjs";
|
|
9
|
+
import { n as resolveIdentityValue } from "./planner-identity-values-BZdomjRU-G521DabU.mjs";
|
|
9
10
|
import { n as defaultPrimaryKeyName, r as defaultUniqueName, t as defaultForeignKeyName } from "./default-constraint-names-CtcRXhV8-nz3ff6b8.mjs";
|
|
10
|
-
import { i as hasUniqueConstraint, n as hasForeignKey, t as buildSchemaLookupMap } from "./planner-schema-lookup-kMIVP2y--CdO4VlnF.mjs";
|
|
11
11
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
12
|
-
import { sqlDataTypeOfCodec } from "@prisma/orm-family-sql/contract/data-type";
|
|
12
|
+
import { dataTypeParams, resolveWrittenSqlTypes, sqlDataTypeOfCodec } from "@prisma/orm-family-sql/contract/data-type";
|
|
13
13
|
import { UNBOUND_NAMESPACE_ID, entityAt } from "@prisma/orm-framework/components/ir";
|
|
14
14
|
import { issueOutcome, orderIssuesByDependencies } from "@prisma/orm-framework/components/control";
|
|
15
15
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
16
16
|
import * as contractFree from "@prisma/orm-family-sql/relational-core/contract-free";
|
|
17
|
+
import { columnTakesTemporaryValue } from "@prisma/orm-family-sql/family/control";
|
|
17
18
|
import { RelationalSchemaNodeKind, SqlSchemaIR, contractDefaultRefusal, defaultInCanonicalForm } from "@prisma/orm-family-sql/schema-ir/types";
|
|
18
19
|
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
19
20
|
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
20
|
-
//#region ../../../3-targets/3-targets/postgres/dist/control-policy-
|
|
21
|
+
//#region ../../../3-targets/3-targets/postgres/dist/control-policy-DXaIsgUW.mjs
|
|
21
22
|
/**
|
|
22
23
|
* The storage-`entries` coordinate `(entityKind, entityName)` a Postgres diff
|
|
23
24
|
* node addresses — a table by its name, a native enum by its physical type
|
|
@@ -44,7 +45,7 @@ function postgresNodeStorageCoordinate(node) {
|
|
|
44
45
|
const AUTOINCREMENT = "autoincrement()";
|
|
45
46
|
/**
|
|
46
47
|
* Reconstructs the `StorageColumn`-shaped fields the DDL builder functions
|
|
47
|
-
* (`buildColumnTypeSql`, `
|
|
48
|
+
* (`buildColumnTypeSql`, `resolveIdentityValue`)
|
|
48
49
|
* expect, from a column node's own stamped codec identity (`codecRef` /
|
|
49
50
|
* `codecBaseNativeType`, Decision 5) — never the contract. The node's fields
|
|
50
51
|
* are already resolved past any `typeRef` indirection, so the builders get
|
|
@@ -100,11 +101,7 @@ function renderColumnDdl(name, column, types) {
|
|
|
100
101
|
* Builds the `ALTER COLUMN … TYPE` operands for an expected column node.
|
|
101
102
|
*/
|
|
102
103
|
function renderColumnAlterType(column, types) {
|
|
103
|
-
|
|
104
|
-
return {
|
|
105
|
-
qualifiedTargetType: buildColumnTypeSql(like, types, {}, false),
|
|
106
|
-
formatTypeExpected: buildExpectedFormatType(like, types)
|
|
107
|
-
};
|
|
104
|
+
return buildColumnTypeSql(columnLike(column), types, {}, false);
|
|
108
105
|
}
|
|
109
106
|
/**
|
|
110
107
|
* Resolves the identity value (monoid neutral element) SQL literal used as
|
|
@@ -134,40 +131,93 @@ function buildSetDefaultColumn(columnName, defaultNode, types) {
|
|
|
134
131
|
...ifDefined("codecRef", defaultNode.codecRef)
|
|
135
132
|
});
|
|
136
133
|
}
|
|
137
|
-
/** The
|
|
134
|
+
/** The changes between data types that keep every value: each pair is `from→to` by data type id. */
|
|
138
135
|
const SAFE_WIDENINGS = /* @__PURE__ */ new Set([
|
|
139
136
|
`${pgInt2.id}→${pgInt4.id}`,
|
|
140
137
|
`${pgInt2.id}→${pgInt8.id}`,
|
|
141
138
|
`${pgInt4.id}→${pgInt8.id}`,
|
|
142
|
-
`${
|
|
139
|
+
`${pgInt2.id}→${pgFloat4.id}`,
|
|
140
|
+
`${pgInt2.id}→${pgFloat8.id}`,
|
|
141
|
+
`${pgInt4.id}→${pgFloat8.id}`,
|
|
142
|
+
`${pgFloat4.id}→${pgFloat8.id}`,
|
|
143
|
+
`${pgVarchar.id}→${pgText.id}`,
|
|
144
|
+
`${pgInt2.id}→${pgText.id}`,
|
|
145
|
+
`${pgInt4.id}→${pgText.id}`,
|
|
146
|
+
`${pgInt8.id}→${pgText.id}`,
|
|
147
|
+
`${pgNumeric.id}→${pgText.id}`,
|
|
148
|
+
`${pgFloat4.id}→${pgText.id}`,
|
|
149
|
+
`${pgFloat8.id}→${pgText.id}`
|
|
143
150
|
]);
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
/** Types whose `length` caps their values; a larger cap, or none, keeps every value. */
|
|
152
|
+
const LENGTH_CAPPED = /* @__PURE__ */ new Set([pgVarchar.id, pgVarbit.id]);
|
|
153
|
+
/** Types whose `precision` rounds their fractional seconds; more, or none, keeps every value. */
|
|
154
|
+
const PRECISION_ROUNDED = /* @__PURE__ */ new Set([
|
|
155
|
+
pgTime.id,
|
|
156
|
+
pgTimetz.id,
|
|
157
|
+
pgTimestamp.id,
|
|
158
|
+
pgTimestamptz.id
|
|
159
|
+
]);
|
|
160
|
+
function numberParam(params, key) {
|
|
161
|
+
const value = params[key];
|
|
162
|
+
return typeof value === "number" ? value : void 0;
|
|
163
|
+
}
|
|
164
|
+
/** Whether a cap, where `undefined` means none, is at least as large as before. */
|
|
165
|
+
function capGrows(from, to) {
|
|
166
|
+
return to === void 0 || from !== void 0 && to >= from;
|
|
153
167
|
}
|
|
154
|
-
/**
|
|
155
|
-
|
|
168
|
+
/**
|
|
169
|
+
* A `numeric` keeps every value when it allows at least as many digits before the point and after
|
|
170
|
+
* it; an unconstrained `numeric` holds any value.
|
|
171
|
+
*/
|
|
172
|
+
function numericGrows(from, to) {
|
|
173
|
+
const toPrecision = numberParam(to, "precision");
|
|
174
|
+
if (toPrecision === void 0) return true;
|
|
175
|
+
const fromPrecision = numberParam(from, "precision");
|
|
176
|
+
if (fromPrecision === void 0) return false;
|
|
177
|
+
const fromScale = numberParam(from, "scale") ?? 0;
|
|
178
|
+
const toScale = numberParam(to, "scale") ?? 0;
|
|
179
|
+
return toScale >= fromScale && toPrecision - toScale >= fromPrecision - fromScale;
|
|
180
|
+
}
|
|
181
|
+
/** Whether changing a column from one type to another keeps every value. */
|
|
182
|
+
function isSafeTypeWidening(from, to) {
|
|
183
|
+
if (SAFE_WIDENINGS.has(`${from.dataType}→${to.dataType}`)) return true;
|
|
184
|
+
if (from.dataType !== to.dataType) return false;
|
|
185
|
+
if (LENGTH_CAPPED.has(from.dataType)) return capGrows(numberParam(from.params, "length"), numberParam(to.params, "length"));
|
|
186
|
+
if (PRECISION_ROUNDED.has(from.dataType)) return capGrows(numberParam(from.params, "precision"), numberParam(to.params, "precision"));
|
|
187
|
+
if (from.dataType === pgNumeric.id) return numericGrows(from.params, to.params);
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
function isParamRecord(value) {
|
|
191
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
192
|
+
}
|
|
193
|
+
/** The data type a column node's codec represents, with its parameters. */
|
|
194
|
+
function columnType(column, types) {
|
|
156
195
|
if (column.codecRef === void 0) throw new InternalError(`Column "${column.name}" carries no codec, so its data type is unknown; a type change is planned only between columns built from contracts.`);
|
|
157
|
-
|
|
196
|
+
const type = sqlDataTypeOfCodec(column.codecRef.codecId, types);
|
|
197
|
+
const typeParams = column.codecRef.typeParams;
|
|
198
|
+
const params = isParamRecord(typeParams) ? dataTypeParams(type, typeParams) : {};
|
|
199
|
+
return {
|
|
200
|
+
dataType: type.id,
|
|
201
|
+
params: type.sql.normalize(params)
|
|
202
|
+
};
|
|
158
203
|
}
|
|
159
|
-
/** The
|
|
160
|
-
function
|
|
161
|
-
|
|
204
|
+
/** The type of an introspected column, read from the type name introspection reports. */
|
|
205
|
+
function introspectedColumnType(column) {
|
|
206
|
+
if (column.resolvedNativeType === void 0) return void 0;
|
|
207
|
+
const [only, ...others] = resolveWrittenSqlTypes(column.resolvedNativeType, postgresDataTypes);
|
|
208
|
+
return only === void 0 || others.length > 0 ? void 0 : {
|
|
209
|
+
dataType: only.dataType,
|
|
210
|
+
params: only.typeParams
|
|
211
|
+
};
|
|
162
212
|
}
|
|
163
213
|
/**
|
|
164
|
-
* Whether changing
|
|
165
|
-
*
|
|
214
|
+
* Whether changing a live column to the contract's column keeps every value. A column introspected
|
|
215
|
+
* from the database carries no codec, so its type is read from the name introspection reports.
|
|
166
216
|
*/
|
|
167
217
|
function liveColumnWidensSafely(expected, actual, types) {
|
|
168
218
|
if (expected.many === true || actual.many === true) return false;
|
|
169
|
-
const from = actual.
|
|
170
|
-
return from !== void 0 && isSafeTypeWidening(from,
|
|
219
|
+
const from = actual.codecRef === void 0 ? introspectedColumnType(actual) : columnType(actual, types);
|
|
220
|
+
return from !== void 0 && isSafeTypeWidening(from, columnType(expected, types));
|
|
171
221
|
}
|
|
172
222
|
/**
|
|
173
223
|
* Look up a storage table by its explicit namespace coordinate. Returns
|
|
@@ -204,6 +254,16 @@ function columnNodePair(issue) {
|
|
|
204
254
|
actual: blindCast(issue.actual)
|
|
205
255
|
};
|
|
206
256
|
}
|
|
257
|
+
/** The `--backfill` statement's column an issue is about, if a statement names it. */
|
|
258
|
+
function backfilled(ctx, ddlSchemaName, tableName, columnName) {
|
|
259
|
+
const namespaceId = namespaceIdForDdlSchema(ctx, ddlSchemaName);
|
|
260
|
+
return ctx.statementColumns.backfill.find((column) => column.namespaceId === namespaceId && column.table === tableName && column.column === columnName);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Handles a required column with no default added to an existing table, for a field a
|
|
264
|
+
* `--backfill` statement names: a nullable add, a data transform whose slots the user fills, then
|
|
265
|
+
* `SET NOT NULL`. Every other such column is left to `notNullAddColumnCallStrategy`.
|
|
266
|
+
*/
|
|
207
267
|
const notNullBackfillCallStrategy = (issues, ctx) => {
|
|
208
268
|
if (!ctx.policy.allowedOperationClasses.includes("data")) return { kind: "no_match" };
|
|
209
269
|
const matched = [];
|
|
@@ -217,11 +277,18 @@ const notNullBackfillCallStrategy = (issues, ctx) => {
|
|
|
217
277
|
const ddlSchemaName = issueSchemaName(issue);
|
|
218
278
|
const tableName = issueTableName(issue);
|
|
219
279
|
if (ddlSchemaName === void 0 || tableName === void 0) continue;
|
|
280
|
+
const named = backfilled(ctx, ddlSchemaName, tableName, expected.name);
|
|
281
|
+
if (named === void 0) continue;
|
|
220
282
|
const schemaName = emissionSchemaName(ctx, ddlSchemaName);
|
|
283
|
+
const slot = named.text;
|
|
221
284
|
matched.push(issue);
|
|
222
285
|
const ddl = renderColumnDdl(expected.name, expected, ctx.types);
|
|
223
286
|
const nullableSpec = contractFree.col(ddl.name, ddl.type, { ...ddl.codecRef !== void 0 ? { codecRef: ddl.codecRef } : {} });
|
|
224
|
-
calls.push(new AddColumnCall(schemaName, tableName, nullableSpec), new DataTransformCall(`backfill-${tableName}-${expected.name}`,
|
|
287
|
+
calls.push(new AddColumnCall(schemaName, tableName, nullableSpec), new DataTransformCall(`backfill-${tableName}-${expected.name}`, `${slot}:check`, `${slot}:run`, "data", {
|
|
288
|
+
schema: schemaName,
|
|
289
|
+
table: tableName,
|
|
290
|
+
column: expected.name
|
|
291
|
+
}), new SetNotNullCall(schemaName, tableName, expected.name));
|
|
225
292
|
}
|
|
226
293
|
if (matched.length === 0) return { kind: "no_match" };
|
|
227
294
|
return {
|
|
@@ -232,22 +299,16 @@ const notNullBackfillCallStrategy = (issues, ctx) => {
|
|
|
232
299
|
};
|
|
233
300
|
};
|
|
234
301
|
/**
|
|
235
|
-
* Handles `not-equal` column
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
* the plan, and its order, the same either way.
|
|
302
|
+
* Handles a `not-equal` column issue whose type differs, for a field a `--convert` statement names,
|
|
303
|
+
* in a plan that may include `data` operations: `migration plan`. The alter is classed `data` and
|
|
304
|
+
* its USING clause is a slot the user fills with the conversion. A known-safe widening needs no
|
|
305
|
+
* conversion and is left to `mapNodeIssueToCall`, as is every type change no statement names: a
|
|
306
|
+
* direct alter, `widening` or `destructive`, which the plan asks about.
|
|
241
307
|
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
* the legacy coordinate walk emitted two: `type_mismatch` +
|
|
245
|
-
* `nullability_mismatch`). When this strategy consumes the issue for its
|
|
246
|
-
* type portion, it also emits whatever nullability delta the same node pair
|
|
247
|
-
* carries — using the same construction `nullableTighteningCallStrategy` /
|
|
248
|
-
* the mapper's direct dispatch would have used — so the issue is never
|
|
249
|
-
* partially handled.
|
|
308
|
+
* One node issue can carry both type and nullability drift, so the strategy also emits the
|
|
309
|
+
* nullability change: `SET NOT NULL` after the alter, whose conversion can map NULL to a value.
|
|
250
310
|
*/
|
|
311
|
+
/** A field as a statement names it: with its namespace only when the contract has several. */
|
|
251
312
|
const typeChangeCallStrategy = (issues, ctx) => {
|
|
252
313
|
if (ctx.fromContract === null || !ctx.policy.allowedOperationClasses.includes("data")) return { kind: "no_match" };
|
|
253
314
|
const matched = [];
|
|
@@ -258,22 +319,27 @@ const typeChangeCallStrategy = (issues, ctx) => {
|
|
|
258
319
|
if (pair === void 0) continue;
|
|
259
320
|
const { expected, actual } = pair;
|
|
260
321
|
if (!columnTypeChangedNativeOnly(expected, actual)) continue;
|
|
261
|
-
const isSafeWidening = isSafeTypeWidening(columnDataType(actual, ctx.types), columnDataType(expected, ctx.types));
|
|
262
322
|
const ddlSchemaName = issueSchemaName(issue);
|
|
263
323
|
const tableName = issueTableName(issue);
|
|
264
324
|
if (ddlSchemaName === void 0 || tableName === void 0) continue;
|
|
325
|
+
const namespaceId = namespaceIdForDdlSchema(ctx, ddlSchemaName);
|
|
326
|
+
const converted = ctx.statementColumns.convert.find((column) => column.namespaceId === namespaceId && column.table === tableName && column.column === expected.name);
|
|
327
|
+
if (converted === void 0) continue;
|
|
328
|
+
if (isSafeTypeWidening(columnType(actual, ctx.types), columnType(expected, ctx.types))) continue;
|
|
265
329
|
const schemaName = emissionSchemaName(ctx, ddlSchemaName);
|
|
266
330
|
matched.push(issue);
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
331
|
+
calls.push(new AlterColumnTypeCall({
|
|
332
|
+
schemaName,
|
|
333
|
+
tableName,
|
|
334
|
+
columnName: expected.name,
|
|
335
|
+
type: renderColumnAlterType(expected, ctx.types),
|
|
336
|
+
using: {
|
|
337
|
+
kind: "placeholder",
|
|
338
|
+
slot: `${converted.text}:convert`
|
|
339
|
+
},
|
|
340
|
+
dataTypes: ctx.dataTypes
|
|
341
|
+
}));
|
|
342
|
+
if (expected.nullable !== actual.nullable) calls.push(expected.nullable ? new DropNotNullCall(schemaName, tableName, expected.name) : new SetNotNullCall(schemaName, tableName, expected.name));
|
|
277
343
|
}
|
|
278
344
|
if (matched.length === 0) return { kind: "no_match" };
|
|
279
345
|
return {
|
|
@@ -294,11 +360,11 @@ function columnTypeChangedNativeOnly(expected, actual) {
|
|
|
294
360
|
return expected.nativeType !== actual.nativeType;
|
|
295
361
|
}
|
|
296
362
|
/**
|
|
297
|
-
* Handles `not-equal` column
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
363
|
+
* Handles a `not-equal` column issue whose type did not change but which becomes required, for a
|
|
364
|
+
* field a `--backfill` statement names: a data transform whose slots the user fills with values for
|
|
365
|
+
* the NULLs, then `SET NOT NULL`. Every other such column gets the direct `SET NOT NULL` of
|
|
366
|
+
* `mapNodeIssueToCall`. A type-changed issue's nullability is handled by `typeChangeCallStrategy`
|
|
367
|
+
* or the direct alter.
|
|
302
368
|
*/
|
|
303
369
|
const nullableTighteningCallStrategy = (issues, ctx) => {
|
|
304
370
|
if (!ctx.policy.allowedOperationClasses.includes("data")) return { kind: "no_match" };
|
|
@@ -314,9 +380,16 @@ const nullableTighteningCallStrategy = (issues, ctx) => {
|
|
|
314
380
|
const ddlSchemaName = issueSchemaName(issue);
|
|
315
381
|
const tableName = issueTableName(issue);
|
|
316
382
|
if (ddlSchemaName === void 0 || tableName === void 0) continue;
|
|
383
|
+
const named = backfilled(ctx, ddlSchemaName, tableName, expected.name);
|
|
384
|
+
if (named === void 0) continue;
|
|
317
385
|
const schemaName = emissionSchemaName(ctx, ddlSchemaName);
|
|
386
|
+
const slot = named.text;
|
|
318
387
|
matched.push(issue);
|
|
319
|
-
calls.push(new DataTransformCall(`handle-nulls-${tableName}-${expected.name}`,
|
|
388
|
+
calls.push(new DataTransformCall(`handle-nulls-${tableName}-${expected.name}`, `${slot}:check`, `${slot}:run`, "data", {
|
|
389
|
+
schema: schemaName,
|
|
390
|
+
table: tableName,
|
|
391
|
+
column: expected.name
|
|
392
|
+
}), new SetNotNullCall(schemaName, tableName, expected.name));
|
|
320
393
|
}
|
|
321
394
|
if (matched.length === 0) return { kind: "no_match" };
|
|
322
395
|
return {
|
|
@@ -375,7 +448,8 @@ const storageTypePlanCallStrategy = (issues, ctx) => {
|
|
|
375
448
|
* nullable → backfill identity value → `SET NOT NULL` → `DROP DEFAULT`).
|
|
376
449
|
* The temp-default value is resolved from the column node's `codecRef`
|
|
377
450
|
* (`resolveColumnTemporaryDefault`, wrapping `resolveIdentityValue`).
|
|
378
|
-
* - Empty-table guarded
|
|
451
|
+
* - Empty-table guarded, for a column in a key, or whose values come from a value set, which
|
|
452
|
+
* no one value stands in for: emit a hand-built op with a `tableIsEmptyCheck`
|
|
379
453
|
* precheck so the failure message is "table is not empty" rather than the
|
|
380
454
|
* raw PG NOT NULL violation.
|
|
381
455
|
*
|
|
@@ -385,8 +459,6 @@ const storageTypePlanCallStrategy = (issues, ctx) => {
|
|
|
385
459
|
const notNullAddColumnCallStrategy = (issues, ctx) => {
|
|
386
460
|
const matched = [];
|
|
387
461
|
const calls = [];
|
|
388
|
-
const schemaLookups = buildSchemaLookupMap(ctx.schema);
|
|
389
|
-
const mutableStorageTypes = blindCast(ctx.storageTypes);
|
|
390
462
|
for (const issue of issues) {
|
|
391
463
|
if (issueOutcome(issue) !== "not-found") continue;
|
|
392
464
|
const node = issueNode(issue);
|
|
@@ -401,30 +473,12 @@ const notNullAddColumnCallStrategy = (issues, ctx) => {
|
|
|
401
473
|
const contractTable = tableAt(ctx.toContract.storage, namespaceId, tableName);
|
|
402
474
|
const column = contractTable?.columns[expected.name];
|
|
403
475
|
if (!contractTable || !column) continue;
|
|
404
|
-
|
|
405
|
-
if (!schemaTable) continue;
|
|
476
|
+
if (ctx.schema.tables[tableName] === void 0) continue;
|
|
406
477
|
const temporaryDefault = resolveColumnTemporaryDefault(expected, ctx.codecHooks, ctx.types);
|
|
407
|
-
const
|
|
408
|
-
const canUseSharedTempDefault = temporaryDefault !== null && canUseSharedTemporaryDefaultStrategy({
|
|
409
|
-
table: contractTable,
|
|
410
|
-
schemaTable,
|
|
411
|
-
schemaLookup,
|
|
412
|
-
columnName: expected.name
|
|
413
|
-
});
|
|
478
|
+
const canUseSharedTempDefault = temporaryDefault !== null && columnTakesTemporaryValue(contractTable, expected.name);
|
|
414
479
|
matched.push(issue);
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
schemaName,
|
|
418
|
-
tableName,
|
|
419
|
-
columnName: expected.name,
|
|
420
|
-
column,
|
|
421
|
-
types: ctx.types,
|
|
422
|
-
storageTypes: mutableStorageTypes,
|
|
423
|
-
temporaryDefault
|
|
424
|
-
}));
|
|
425
|
-
continue;
|
|
426
|
-
}
|
|
427
|
-
calls.push(new AddNotNullColumnDirectCall(schemaName, tableName, expected.name, renderColumnDdl(expected.name, expected, ctx.types)));
|
|
480
|
+
const ddl = renderColumnDdl(expected.name, expected, ctx.types);
|
|
481
|
+
calls.push(canUseSharedTempDefault && temporaryDefault !== null ? new AddColumnWithTemporaryDefaultCall(schemaName, tableName, ddl.name, ddl.type, temporaryDefault) : new AddRequiredColumnToEmptyTableCall(schemaName, tableName, ddl.name, ddl.type));
|
|
428
482
|
}
|
|
429
483
|
if (matched.length === 0) return { kind: "no_match" };
|
|
430
484
|
return {
|
|
@@ -433,36 +487,19 @@ const notNullAddColumnCallStrategy = (issues, ctx) => {
|
|
|
433
487
|
calls
|
|
434
488
|
};
|
|
435
489
|
};
|
|
436
|
-
function canUseSharedTemporaryDefaultStrategy(options) {
|
|
437
|
-
const { table, schemaTable, schemaLookup, columnName } = options;
|
|
438
|
-
if (table.primaryKey?.columns.includes(columnName) && !schemaTable.primaryKey) return false;
|
|
439
|
-
for (const unique of table.uniques) {
|
|
440
|
-
if (!unique.columns.includes(columnName)) continue;
|
|
441
|
-
if (!schemaLookup || !hasUniqueConstraint(schemaLookup, unique.columns)) return false;
|
|
442
|
-
}
|
|
443
|
-
for (const foreignKey of table.foreignKeys) {
|
|
444
|
-
if (!foreignKey.source.columns.includes(columnName)) continue;
|
|
445
|
-
if (!schemaLookup || !hasForeignKey(schemaLookup, foreignKey)) return false;
|
|
446
|
-
}
|
|
447
|
-
return true;
|
|
448
|
-
}
|
|
449
490
|
/**
|
|
450
491
|
* Ordered list of Postgres planner strategies, shared by `migration plan`
|
|
451
492
|
* and `db update` / `db init`. The issue planner runs each strategy in
|
|
452
493
|
* order, letting it consume any issues it handles, and routes whatever's
|
|
453
|
-
* left through `mapNodeIssueToCall`.
|
|
454
|
-
* `policy.allowedOperationClasses`:
|
|
494
|
+
* left through `mapNodeIssueToCall`.
|
|
455
495
|
*
|
|
456
|
-
*
|
|
457
|
-
*
|
|
458
|
-
*
|
|
459
|
-
*
|
|
460
|
-
*
|
|
461
|
-
*
|
|
462
|
-
*
|
|
463
|
-
* the issue for the downstream strategies (`storageTypePlanCallStrategy`,
|
|
464
|
-
* `notNullAddColumnCallStrategy`) or the `mapNodeIssueToCall` default to
|
|
465
|
-
* handle with direct DDL.
|
|
496
|
+
* The strategies that write a placeholder (`notNullBackfillCallStrategy`,
|
|
497
|
+
* `typeChangeCallStrategy`, `nullableTighteningCallStrategy`) act only on a
|
|
498
|
+
* field a `--backfill` or `--convert` statement names, and only when the
|
|
499
|
+
* policy allows `data` (`migration plan`). Every other required field added to
|
|
500
|
+
* an existing table gets the temporary default of
|
|
501
|
+
* `notNullAddColumnCallStrategy`, and every other change the direct DDL of
|
|
502
|
+
* `mapNodeIssueToCall`, under either command.
|
|
466
503
|
*
|
|
467
504
|
* Codec-typed storage type entries are dispatched through
|
|
468
505
|
* `storageTypePlanCallStrategy`.
|
|
@@ -744,7 +781,7 @@ function mapTableNodeIssue(issue, schemaName, ddlSchemaName, types) {
|
|
|
744
781
|
if (!expected.rlsEnabled && actual.rlsEnabled) return ok([new DisableRowLevelSecurityCall(ddlSchemaName, expected.name)]);
|
|
745
782
|
return notOk(nodeConflict("unsupportedOperation", `unhandled table-attribute drift on "${expected.name}": table not-equal with no rlsEnabled delta (a second table attribute drifted)`));
|
|
746
783
|
}
|
|
747
|
-
function mapColumnNodeIssue(issue, schemaName, tableName, types) {
|
|
784
|
+
function mapColumnNodeIssue(issue, schemaName, tableName, types, dataTypes) {
|
|
748
785
|
if (issueOutcome(issue) === "not-found") {
|
|
749
786
|
const column = blindCast(issue.expected);
|
|
750
787
|
return ok([new AddColumnCall(schemaName, tableName, renderColumnDdl(column.name, column, types))]);
|
|
@@ -753,14 +790,14 @@ function mapColumnNodeIssue(issue, schemaName, tableName, types) {
|
|
|
753
790
|
const expected = blindCast(issue.expected);
|
|
754
791
|
const actual = blindCast(issue.actual);
|
|
755
792
|
const calls = [];
|
|
756
|
-
if (columnTypeChanged(expected, actual)) {
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
}
|
|
793
|
+
if (columnTypeChanged(expected, actual)) calls.push(new AlterColumnTypeCall({
|
|
794
|
+
schemaName,
|
|
795
|
+
tableName,
|
|
796
|
+
columnName: expected.name,
|
|
797
|
+
type: renderColumnAlterType(expected, types),
|
|
798
|
+
dataTypes,
|
|
799
|
+
operationClass: liveColumnWidensSafely(expected, actual, types) ? "widening" : "destructive"
|
|
800
|
+
}));
|
|
764
801
|
if (expected.nullable !== actual.nullable) calls.push(expected.nullable ? new DropNotNullCall(schemaName, tableName, expected.name) : new SetNotNullCall(schemaName, tableName, expected.name));
|
|
765
802
|
return ok(calls);
|
|
766
803
|
}
|
|
@@ -850,7 +887,7 @@ function mapNodeIssueToCall(issue, ctx) {
|
|
|
850
887
|
const schemaName = emissionSchemaName(ctx, ddlSchemaName);
|
|
851
888
|
switch (node.nodeKind) {
|
|
852
889
|
case PostgresSchemaNodeKind.table: return mapTableNodeIssue(issue, schemaName, ddlSchemaName, ctx.types);
|
|
853
|
-
case RelationalSchemaNodeKind.column: return mapColumnNodeIssue(issue, schemaName, tableName, ctx.types);
|
|
890
|
+
case RelationalSchemaNodeKind.column: return mapColumnNodeIssue(issue, schemaName, tableName, ctx.types, ctx.dataTypes);
|
|
854
891
|
case RelationalSchemaNodeKind.columnDefault: {
|
|
855
892
|
const columnName = issueColumnName(issue);
|
|
856
893
|
if (columnName === void 0) return notOk(nodeConflict("unsupportedOperation", `Default issue has no column in its path: ${issue.path.join("/")}`));
|
|
@@ -885,7 +922,12 @@ function planIssues(options) {
|
|
|
885
922
|
storageTypes: options.storageTypes,
|
|
886
923
|
schema,
|
|
887
924
|
policy,
|
|
888
|
-
frameworkComponents
|
|
925
|
+
frameworkComponents,
|
|
926
|
+
statementColumns: options.statementColumns ?? {
|
|
927
|
+
convert: [],
|
|
928
|
+
backfill: []
|
|
929
|
+
},
|
|
930
|
+
dataTypes: stackDataTypes(frameworkComponents)
|
|
889
931
|
};
|
|
890
932
|
const strategies = options.strategies ?? postgresPlannerStrategies;
|
|
891
933
|
let remaining = options.issues;
|
|
@@ -1190,4 +1232,4 @@ function resolvePostgresNodeIssueControlPolicySubject(issue, contract) {
|
|
|
1190
1232
|
//#endregion
|
|
1191
1233
|
export { planIssues as a, renderPostgresSuppression as c, resolvePostgresNodeIssueControlPolicySubject as d, resolvePostgresNodeIssueCreationFactoryName as f, issueSchemaName as i, resolveNamespaceIdForDdlSchema as l, conflictForDisallowedCall as n, postgresNodeStorageCoordinate as o, issueNode as r, postgresPlannerStrategies as s, coalesceSubtreeIssues as t, resolvePostgresCallControlPolicySubject as u };
|
|
1192
1234
|
|
|
1193
|
-
//# sourceMappingURL=control-policy-
|
|
1235
|
+
//# sourceMappingURL=control-policy-DXaIsgUW-Btyo9Vs8.mjs.map
|