@prisma/orm-family-sql 8.0.0-rc.14-dev.10 → 8.0.0-rc.14-dev.12
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/{ast-BQOF33Tw.d.mts → ast-qnGR-fmK.d.mts} +2 -2
- package/dist/{ast-BQOF33Tw.d.mts.map → ast-qnGR-fmK.d.mts.map} +1 -1
- package/dist/builder.d.mts +2 -2
- package/dist/builder__runtime.d.mts +3 -3
- package/dist/builder__types.d.mts +2 -2
- package/dist/{control-k5_z0qcA.d.mts → control-BFgBjkQh.d.mts} +60 -8
- package/dist/control-BFgBjkQh.d.mts.map +1 -0
- package/dist/{control-DMbej03E.mjs → control-D7yb7l7O.mjs} +132 -6
- package/dist/control-D7yb7l7O.mjs.map +1 -0
- package/dist/{control-adapter-C4_cgvzB-BwZx3_VD.d.mts → control-adapter-C4_cgvzB-BhRxZg-n.d.mts} +3 -3
- package/dist/{control-adapter-C4_cgvzB-BwZx3_VD.d.mts.map → control-adapter-C4_cgvzB-BhRxZg-n.d.mts.map} +1 -1
- package/dist/control-adapter-Cj6XQ7Yo.d.mts +1 -0
- package/dist/{db-DLjWu9-f-BWg-lrGV.d.mts → db-DLjWu9-f-B79_8TyU.d.mts} +3 -3
- package/dist/{db-DLjWu9-f-BWg-lrGV.d.mts.map → db-DLjWu9-f-B79_8TyU.d.mts.map} +1 -1
- package/dist/{diff-C_zQQTgw.d.mts → diff-CPnJUpHZ.d.mts} +3 -3
- package/dist/{diff-C_zQQTgw.d.mts.map → diff-CPnJUpHZ.d.mts.map} +1 -1
- package/dist/{driver-types-BQtRkOJ0-Bv2RPSfr.d.mts → driver-types-DYGFEcyv-DPaNalPf.d.mts} +5 -2
- package/dist/driver-types-DYGFEcyv-DPaNalPf.d.mts.map +1 -0
- package/dist/{expression-B95FOcDX.d.mts → expression-C6yUAU4j.d.mts} +2 -2
- package/dist/{expression-B95FOcDX.d.mts.map → expression-C6yUAU4j.d.mts.map} +1 -1
- package/dist/family.d.mts +7 -7
- package/dist/family.mjs +2 -2
- package/dist/family__control-adapter.d.mts +2 -2
- package/dist/family__control.d.mts +3 -3
- package/dist/family__control.mjs +2 -2
- package/dist/family__diff.d.mts +2 -2
- package/dist/family__migration.d.mts +1 -1
- package/dist/{index-DrWMh8L0.d.mts → index-CQ74jdOW.d.mts} +3 -3
- package/dist/{index-DrWMh8L0.d.mts.map → index-CQ74jdOW.d.mts.map} +1 -1
- package/dist/{migration-CRsGI-9f.d.mts → migration-Ixy5Tqxd.d.mts} +2 -2
- package/dist/{migration-CRsGI-9f.d.mts.map → migration-Ixy5Tqxd.d.mts.map} +1 -1
- package/dist/orm-client.d.mts +6 -6
- package/dist/{prepared-statement-BdsTSY7Y-ICyuLB7c.d.mts → prepared-statement-Cv54gpY_-CbIaPDc1.d.mts} +24 -8
- package/dist/{prepared-statement-BdsTSY7Y-ICyuLB7c.d.mts.map → prepared-statement-Cv54gpY_-CbIaPDc1.d.mts.map} +1 -1
- package/dist/relational-core.d.mts +4 -4
- package/dist/relational-core__ast.d.mts +2 -2
- package/dist/relational-core__expression.d.mts +1 -1
- package/dist/relational-core__types.d.mts +2 -2
- package/dist/runtime.d.mts +4 -4
- package/dist/runtime.mjs +169 -54
- package/dist/runtime.mjs.map +1 -1
- package/dist/runtime__internal__prepared-query.d.mts +1 -1
- package/dist/{types-C0VMsES6-BLOPdA8Y.d.mts → types-BGHABElw-C5MKkR3c.d.mts} +3 -3
- package/dist/{types-C0VMsES6-BLOPdA8Y.d.mts.map → types-BGHABElw-C5MKkR3c.d.mts.map} +1 -1
- package/dist/{types-BKJWoQ40-BzViF_9K.d.mts → types-BHKZ4M-a-DYsrOHhh.d.mts} +3 -3
- package/dist/{types-BKJWoQ40-BzViF_9K.d.mts.map → types-BHKZ4M-a-DYsrOHhh.d.mts.map} +1 -1
- package/dist/types-CXe4fCcu.d.mts +1 -0
- package/package.json +18 -18
- package/dist/control-DMbej03E.mjs.map +0 -1
- package/dist/control-adapter-CDDbpxyt.d.mts +0 -1
- package/dist/control-k5_z0qcA.d.mts.map +0 -1
- package/dist/driver-types-BQtRkOJ0-Bv2RPSfr.d.mts.map +0 -1
- package/dist/types-BsUJ1jWE.d.mts +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { E as CodecRef$1, dt as LoweredStatement, h as AnyQueryAst, m as AnyParamRef } from "./types-Yui2yFf6-DQkiEr9B.mjs";
|
|
2
|
-
import { c as SqlQueryable } from "./driver-types-
|
|
2
|
+
import { c as SqlQueryable } from "./driver-types-DYGFEcyv-DPaNalPf.mjs";
|
|
3
3
|
import "./ddl-types-B23QEzDx-ridB7leA.mjs";
|
|
4
4
|
import { ColumnDefaultLiteralInputValue, ContractMarkerRecord, JsonValue } from "@prisma/orm-framework/contract/types";
|
|
5
5
|
import { CodecCallContext, CodecDescriptorTemplateImpl, CodecImpl, CodecInstanceContext, CodecLookupWithDescriptors, DataTypeId, ToCanonicalForm } from "@prisma/orm-framework/components/codec";
|
|
@@ -285,4 +285,4 @@ declare function compact<T extends Record<string, unknown>>(o: T): T;
|
|
|
285
285
|
declare function collectOrderedParamRefs(ast: AnyQueryAst): ReadonlyArray<AnyParamRef>;
|
|
286
286
|
//#endregion
|
|
287
287
|
export { sqlIntDecode as $, canonicalNumeralText as A, parseJsonBody as B, SqlIntCodec as C, SqlVarcharCodec as D, SqlTextDescriptor as E, encodeLiteralDefault as F, sqlCharDescriptor as G, signedRange as H, escapePslString as I, sqlFloatColumn as J, sqlCharEncode as K, integerTextCanonicalForm as L, compact as M, createNumberClassifier as N, SqlVarcharDescriptor as O, encodeListLiteralDefault as P, sqlIntColumn as Q, isNumeralText as R, SqlFloatDescriptor as S, SqlTextCodec as T, sqlCharColumn as U, printJsonBody as V, sqlCharDecode as W, sqlFloatDescriptor as X, sqlFloatDecode as Y, sqlFloatEncode as Z, SQL_TEXT_CODEC_ID as _, DateTimeShape as a, sqlTextEncode as at, SqlCharDescriptor as b, LiteralDefaultColumn as c, sqlVarcharDescriptor as ct, MarkerReadResult as d, sqlIntDescriptor as et, NumberClassification as f, SQL_INT_CODEC_ID as g, SQL_FLOAT_CODEC_ID as h, CanonicalDateTimeOptions as i, sqlTextDescriptor as it, collectOrderedParamRefs as j, canonicalDateTime as k, Lowerer as l, sqlVarcharEncode as lt, SQL_CHAR_CODEC_ID as m, AdapterProfile as n, sqlTextColumn as nt, EncodedLiteralDefault as o, sqlVarcharColumn as ot, NumberClassifierSpec as p, sqlCharRenderOutputType as q, AdapterTarget as r, sqlTextDecode as rt, IntegerStep as s, sqlVarcharDecode as st, Adapter as t, sqlIntEncode as tt, LowererContext as u, sqlVarcharRenderOutputType as ut, SQL_VARCHAR_CODEC_ID as v, SqlIntDescriptor as w, SqlFloatCodec as x, SqlCharCodec as y, numeralText as z };
|
|
288
|
-
//# sourceMappingURL=ast-
|
|
288
|
+
//# sourceMappingURL=ast-qnGR-fmK.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-
|
|
1
|
+
{"version":3,"file":"ast-qnGR-fmK.d.mts","names":[],"sources":["../../../../2-sql/4-lanes/relational-core/dist/exports/ast.d.mts"],"mappings":";;;;;;;;KAOK;;;;;;;KAOA;WACM;WACA,QAAQ;;WAER;;WAEA;;UAED,eAAe,gBAAgB,gBAAgB;WAC9C;WACA,QAAQ;WACR,cAAc;;;;EAIvB,WAAW,WAAW,eAAe,QAAQ;;UAErC,eAAe;WACd,UAAU;WACV;;KAEN,QAAQ,eAAe,qBAAqB,QAAQ,qBAAqB,KAAK,KAAK,SAAS,eAAe,eAAe;;;;UAIrH,QAAQ,eAAe,qBAAqB,QAAQ;WACnD,SAAS;EAClB,MAAM,KAAK,KAAK,SAAS,eAAe,aAAa;;;;;iBAKtC,cAAc;;;;;iBAKd,qBAAqB;;;;;iBAKrB,YAAY;;;;cAIf,0BAA0B;;iBAEvB,gBAAgB;;UAEvB;WACC,MAAM;WACN;;;UAGD,oBAAoB;WACnB;WAC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W;cAC9E,sBAAsB,iBAAiB;EACnD,OAAO,eAAe,MAAM,mBAAqB;EACjD,OAAO,cAAc,MAAM,mBAAqB;EAChD,WAAW,gBAAgB;EAC3B,WAAW,MAAM;;cAEL,2BAA2B;WAC9B;WACA;WACA;WACA;EACT,YAAY,KAAK,yBAAyB;;cAE9B,oBAAoB;cACpB,qEAAqE,WAAW;cAChF,qBAAqB,iBAAiB;EAClD,OAAO,eAAe,MAAM,mBAAqB;EACjD,OAAO,cAAc,MAAM,mBAAqB;EAChD,WAAW,gBAAgB;EAC3B,WAAW,MAAM;;cAEL,0BAA0B,4BAA4B;WACzD;WACA;WACA;WACA,cAAc,iBAAiB;EACxC,iBAAiB,QAAQ;EACzB,QAAQ,SAAS,gBAAgB,KAAK,yBAAyB;;cAEnD,mBAAmB;cACnB,gBAAgB,SAAS,gEAAgE,WAAW,cAAc;cAClH,wBAAwB,iBAAiB;EACrD,OAAO,eAAe,MAAM,mBAAqB;EACjD,OAAO,cAAc,MAAM,mBAAqB;EAChD,WAAW,gBAAgB;EAC3B,WAAW,MAAM;;cAEL,6BAA6B,4BAA4B;WAC5D;WACA;WACA;WACA,cAAc,iBAAiB;EACxC,iBAAiB,QAAQ;EACzB,QAAQ,SAAS,gBAAgB,KAAK,yBAAyB;;cAEnD,sBAAsB;cACtB,mBAAmB,SAAS,gEAAgE,WAAW,iBAAiB;;;iBAGrH,QAAQ,UAAU,yBAAyB,GAAG,IAAI;;;;;;;;;;;iBAWlD,wBAAwB,KAAK,cAAc,cAAc"}
|
package/dist/builder.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { o as Expression, x as ScopeField } from "./expression-
|
|
2
|
-
import { T as WhereFilter, _ as SelectQuery, a as DeleteQuery, c as GatedMethod, f as QueryContext, g as Scope, h as ResolveRow, i as Db, l as GroupedQuery, s as Functions, t as AggregateFunctions, u as InsertQuery, v as Subquery, w as UpdateQuery, x as TableProxy } from "./db-DLjWu9-f-
|
|
1
|
+
import { o as Expression, x as ScopeField } from "./expression-C6yUAU4j.mjs";
|
|
2
|
+
import { T as WhereFilter, _ as SelectQuery, a as DeleteQuery, c as GatedMethod, f as QueryContext, g as Scope, h as ResolveRow, i as Db, l as GroupedQuery, s as Functions, t as AggregateFunctions, u as InsertQuery, v as Subquery, w as UpdateQuery, x as TableProxy } from "./db-DLjWu9-f-B79_8TyU.mjs";
|
|
3
3
|
export type { AggregateFunctions, Db, DeleteQuery, Expression, Functions, GatedMethod, GroupedQuery, InsertQuery, QueryContext, ResolveRow, Scope, ScopeField, SelectQuery, Subquery, TableProxy, UpdateQuery, WhereFilter };
|
|
@@ -2,9 +2,9 @@ import { c as SqlStorage } from "./sql-storage-BSxD7_vv-C4ugLH39.mjs";
|
|
|
2
2
|
import "./types-BoMDdzjD.mjs";
|
|
3
3
|
import { i as SqlOperationEntry } from "./index-DrUd8HwS.mjs";
|
|
4
4
|
import { c as AnyExpression } from "./types-Yui2yFf6-DQkiEr9B.mjs";
|
|
5
|
-
import "./ast-
|
|
6
|
-
import { l as RawCodecInferer, o as Expression, x as ScopeField } from "./expression-
|
|
7
|
-
import { S as TableProxyContract, f as QueryContext, g as Scope, i as Db, o as FieldProxy, p as RawLane, s as Functions, t as AggregateFunctions } from "./db-DLjWu9-f-
|
|
5
|
+
import "./ast-qnGR-fmK.mjs";
|
|
6
|
+
import { l as RawCodecInferer, o as Expression, x as ScopeField } from "./expression-C6yUAU4j.mjs";
|
|
7
|
+
import { S as TableProxyContract, f as QueryContext, g as Scope, i as Db, o as FieldProxy, p as RawLane, s as Functions, t as AggregateFunctions } from "./db-DLjWu9-f-B79_8TyU.mjs";
|
|
8
8
|
import { a as SqlAggregateDescriptorRegistry, n as ExecutionContext } from "./query-lane-context-BSmWfohZ-QAWw_dXQ.mjs";
|
|
9
9
|
import "./query-lane-context-B0R8L6W-.mjs";
|
|
10
10
|
import { Contract } from "@prisma/orm-framework/contract/types";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { o as Expression, x as ScopeField } from "./expression-
|
|
2
|
-
import { C as UnboundTables, S as TableProxyContract, T as WhereFilter, _ as SelectQuery, a as DeleteQuery, b as TableNamesAcrossNamespaces, c as GatedMethod, d as Namespace, f as QueryContext, g as Scope, h as ResolveRow, i as Db, l as GroupedQuery, m as RawTagFor, n as BooleanCodecType, p as RawLane, r as ContractRawTag, s as Functions, t as AggregateFunctions, u as InsertQuery, v as Subquery, w as UpdateQuery, x as TableProxy, y as TableInAnyNamespace } from "./db-DLjWu9-f-
|
|
1
|
+
import { o as Expression, x as ScopeField } from "./expression-C6yUAU4j.mjs";
|
|
2
|
+
import { C as UnboundTables, S as TableProxyContract, T as WhereFilter, _ as SelectQuery, a as DeleteQuery, b as TableNamesAcrossNamespaces, c as GatedMethod, d as Namespace, f as QueryContext, g as Scope, h as ResolveRow, i as Db, l as GroupedQuery, m as RawTagFor, n as BooleanCodecType, p as RawLane, r as ContractRawTag, s as Functions, t as AggregateFunctions, u as InsertQuery, v as Subquery, w as UpdateQuery, x as TableProxy, y as TableInAnyNamespace } from "./db-DLjWu9-f-B79_8TyU.mjs";
|
|
3
3
|
export type { AggregateFunctions, BooleanCodecType, ContractRawTag, Db, DeleteQuery, Expression, Functions, GatedMethod, GroupedQuery, InsertQuery, Namespace, QueryContext, RawLane, RawTagFor, ResolveRow, Scope, ScopeField, SelectQuery, Subquery, TableInAnyNamespace, TableNamesAcrossNamespaces, TableProxy, TableProxyContract, UnboundTables, UpdateQuery, WhereFilter };
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import { t as StorageColumn } from "./storage-table-DSeWszOL-CI-cItEK.mjs";
|
|
2
|
-
import { c as SqlStorage } from "./sql-storage-BSxD7_vv-C4ugLH39.mjs";
|
|
2
|
+
import { a as SqlNamespaceEntries, c as SqlStorage } from "./sql-storage-BSxD7_vv-C4ugLH39.mjs";
|
|
3
3
|
import { O as SqlControlDriverInstance } from "./types-DTUyRqZv-DLh98w8w.mjs";
|
|
4
4
|
import "./types-BoMDdzjD.mjs";
|
|
5
5
|
import { r as SqlOperationDescriptors } from "./index-DrUd8HwS.mjs";
|
|
6
6
|
import { h as AnyQueryAst } from "./types-Yui2yFf6-DQkiEr9B.mjs";
|
|
7
|
-
import { o as SqlExecuteRequest } from "./driver-types-
|
|
7
|
+
import { o as SqlExecuteRequest } from "./driver-types-DYGFEcyv-DPaNalPf.mjs";
|
|
8
8
|
import { s as DdlNode } from "./ddl-types-B23QEzDx-ridB7leA.mjs";
|
|
9
|
-
import { u as LowererContext } from "./ast-
|
|
9
|
+
import { u as LowererContext } from "./ast-qnGR-fmK.mjs";
|
|
10
10
|
import { t as SQL_EXPRESSION_DATA_TYPE_ID } from "./sql-expression-D_hbJOgM.mjs";
|
|
11
11
|
import "./validators-CZNulH-_.mjs";
|
|
12
12
|
import { _ as SqlSchemaIR, y as SqlSchemaIRNode } from "./types-DinsvYdY-Dv_n3Tac.mjs";
|
|
13
13
|
import "./types-BBT7jidC.mjs";
|
|
14
|
-
import { i as SqlControlAdapter } from "./control-adapter-C4_cgvzB-
|
|
14
|
+
import { i as SqlControlAdapter } from "./control-adapter-C4_cgvzB-BhRxZg-n.mjs";
|
|
15
15
|
import { t as sqlFamilyEnumSpec } from "./authoring-entity-types-CZ-vdwYS-BCsVtN8A.mjs";
|
|
16
|
-
import { A as SqlPlannerSuccessResult, C as SqlMigrationRunnerSuccessValue, O as SqlPlannerFailureResult, T as SqlPlannerConflict, _ as SqlMigrationRunner, h as SqlMigrationPlanner, n as CodecControlHooks, r as CreateSqlMigrationPlanOptions, t as AnyRecord, u as SqlMigrationPlan, v as SqlMigrationRunnerErrorCode, x as SqlMigrationRunnerFailure } from "./types-
|
|
16
|
+
import { A as SqlPlannerSuccessResult, C as SqlMigrationRunnerSuccessValue, O as SqlPlannerFailureResult, T as SqlPlannerConflict, _ as SqlMigrationRunner, h as SqlMigrationPlanner, n as CodecControlHooks, r as CreateSqlMigrationPlanOptions, t as AnyRecord, u as SqlMigrationPlan, v as SqlMigrationRunnerErrorCode, x as SqlMigrationRunnerFailure } from "./types-BHKZ4M-a-DYsrOHhh.mjs";
|
|
17
17
|
import { t as SqlSchemaDiffFn } from "./schema-differ-DpG_gnur-gLIPLPVI.mjs";
|
|
18
|
+
import { StructuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
18
19
|
import { PresetStorageTemplate, TIMESTAMP_NOW_GENERATOR_ID } from "@prisma/orm-framework/components/authoring";
|
|
19
20
|
import { ColumnDefault, Contract, ControlPolicy } from "@prisma/orm-framework/contract/types";
|
|
20
21
|
import { CodecLookupWithDescriptors, DataType, DataTypeLookup } from "@prisma/orm-framework/components/codec";
|
|
21
22
|
import { TargetBoundComponentDescriptor } from "@prisma/orm-framework/components/components";
|
|
22
23
|
import { AssembledAuthoringContributions, ContractSerializer, ControlFamilyDescriptor, ControlFamilyInstance, ControlStack, DiffSubjectGranularity, MigratableTargetDescriptor, MigrationOperationClass, MigrationOperationPolicy, MigrationOperationPolicy as MigrationOperationPolicy$1, MigrationPlan as MigrationPlan$1, MigrationPlanOperation, MigrationPlanOperation as MigrationPlanOperation$1, MigrationPlanner, MigrationPlannerConflict, MigrationPlannerConflict as MigrationPlannerConflict$1, MigrationPlannerResult, OpFactoryCall, OperationPreview, OperationPreviewCapable, PslContractBuildCapable, PslContractInferCapable, SchemaDiffIssue, SchemaVerifier, SchemaViewCapable, SignDatabaseResult, TargetMigrationsCapability, VerifyDatabaseResult, VerifyDatabaseSchemaResult, assembleAuthoringContributions } from "@prisma/orm-framework/components/control";
|
|
23
|
-
import { NotOk, Ok } from "@prisma/orm-framework/utils/result";
|
|
24
|
+
import { NotOk, Ok, Result } from "@prisma/orm-framework/utils/result";
|
|
24
25
|
import { PslDocumentAst } from "@prisma/orm-framework/components/psl-ast";
|
|
25
26
|
import { EmissionSpi, TypesImportSpec } from "@prisma/orm-framework/components/emission";
|
|
26
27
|
//#region ../../../2-sql/9-family/dist/control.d.mts
|
|
@@ -566,6 +567,41 @@ interface SqlControlTargetDescriptor<TTargetId extends string, TTargetDetails, T
|
|
|
566
567
|
createRunner(family: SqlControlFamilyInstance): SqlMigrationRunner<TTargetDetails>;
|
|
567
568
|
}
|
|
568
569
|
//#endregion
|
|
570
|
+
//#region src/core/migrations/apply-table-rename.d.ts
|
|
571
|
+
/** A table a migration renames: `namespaceId` is `undefined` when the migration leaves the namespace to the contracts. */
|
|
572
|
+
interface TableRename {
|
|
573
|
+
readonly namespaceId: string | undefined;
|
|
574
|
+
readonly from: string;
|
|
575
|
+
readonly to: string;
|
|
576
|
+
}
|
|
577
|
+
/** A rename after its table was found in the start contract. */
|
|
578
|
+
interface ResolvedTableRename {
|
|
579
|
+
readonly namespaceId: string;
|
|
580
|
+
readonly from: string;
|
|
581
|
+
readonly to: string;
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Renames a target's own references to a renamed table inside one namespace's entries: entity kinds the family does not know, such as a target's row-level-security markers, that name a table.
|
|
585
|
+
*/
|
|
586
|
+
type RenameTableReferences = (entries: SqlNamespaceEntries, rename: ResolvedTableRename) => SqlNamespaceEntries;
|
|
587
|
+
interface ApplyTableRenameInput {
|
|
588
|
+
readonly startContract: Contract<SqlStorage> | null;
|
|
589
|
+
readonly endContract: Contract<SqlStorage>;
|
|
590
|
+
readonly rename: TableRename;
|
|
591
|
+
readonly renameTableReferences: RenameTableReferences | undefined;
|
|
592
|
+
}
|
|
593
|
+
interface AppliedTableRename {
|
|
594
|
+
/** The start contract with the table under its new name. */
|
|
595
|
+
readonly contract: Contract<SqlStorage>;
|
|
596
|
+
readonly rename: ResolvedTableRename;
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* Resolves the table a migration renames against its start and end contracts and returns the start contract with that table under its new name, so a diff against the end contract sees the table under one name. The table must exist in the start contract (in exactly one namespace when the namespace is not given), and the new name must exist in the end contract and not in the start contract; otherwise the rename is refused with `MIGRATION.TABLE_RENAME_UNMATCHED`.
|
|
600
|
+
*
|
|
601
|
+
* Foreign keys that name the renamed table on either side are retargeted. Index, unique, check and primary-key names are carried unchanged. Target entity kinds that name the table are renamed by the target's `renameTableReferences`.
|
|
602
|
+
*/
|
|
603
|
+
declare function applyTableRename(input: ApplyTableRenameInput): Result<AppliedTableRename, StructuredError>;
|
|
604
|
+
//#endregion
|
|
569
605
|
//#region src/core/migrations/data-type-resolver.d.ts
|
|
570
606
|
/** The data type a codec represents, or `undefined` when no component registers it. */
|
|
571
607
|
type DataTypeResolver = (codecId: string) => DataType | undefined;
|
|
@@ -888,6 +924,18 @@ declare const TABLE_NAME_CASE_CHANGED_CODE = "MIGRATION.TABLE_NAME_CASE_CHANGED"
|
|
|
888
924
|
interface TableNameCaseGuardTable {
|
|
889
925
|
readonly name: string;
|
|
890
926
|
}
|
|
927
|
+
/** A table rename the operator performs by hand, for the target to write the statements of. */
|
|
928
|
+
interface TableRenameByHand {
|
|
929
|
+
readonly namespaceId: string;
|
|
930
|
+
readonly from: string;
|
|
931
|
+
readonly to: string;
|
|
932
|
+
}
|
|
933
|
+
/** A table rename to write as a migration call; `namespaceId` is `undefined` when the call does not need to name the namespace. */
|
|
934
|
+
interface TableRenameInMigration {
|
|
935
|
+
readonly namespaceId: string | undefined;
|
|
936
|
+
readonly from: string;
|
|
937
|
+
readonly to: string;
|
|
938
|
+
}
|
|
891
939
|
/**
|
|
892
940
|
* Finds every (drop `X`, create `Y`) pair in the same namespace where `X` is
|
|
893
941
|
* `Y` with its first letter lowered. That shape is the signature of a schema
|
|
@@ -903,6 +951,10 @@ declare function detectTableNameCaseChanges(input: {
|
|
|
903
951
|
readonly issues: readonly SchemaDiffIssue[];
|
|
904
952
|
readonly tableOf: (issue: SchemaDiffIssue) => TableNameCaseGuardTable | undefined;
|
|
905
953
|
readonly namespaceIdOf: (issue: SchemaDiffIssue) => string;
|
|
954
|
+
readonly renameByHandStatements: (rename: TableRenameByHand) => readonly string[];
|
|
955
|
+
readonly renameTableCall: (rename: TableRenameInMigration) => string;
|
|
956
|
+
readonly contract: Contract<SqlStorage>;
|
|
957
|
+
readonly defaultNamespaceId: string;
|
|
906
958
|
}): SqlPlannerConflict[];
|
|
907
959
|
//#endregion
|
|
908
960
|
//#region src/core/timestamp-now-generator.d.ts
|
|
@@ -1009,5 +1061,5 @@ declare function temporalCodecPresetWithPrecision<const CodecId extends string,
|
|
|
1009
1061
|
//#region src/exports/control.d.ts
|
|
1010
1062
|
declare const _default: SqlFamilyDescriptor;
|
|
1011
1063
|
//#endregion
|
|
1012
|
-
export {
|
|
1013
|
-
//# sourceMappingURL=control-
|
|
1064
|
+
export { TableRenameInMigration as A, createMigrationPlan as B, SqlDescribedContractSpace as C, TableNameCaseGuardTable as D, TABLE_NAME_CASE_CHANGED_CODE as E, buildDataTypeResolver as F, partitionIssuesByControlPolicy as G, detectTableNameCaseChanges as H, buildNativeTypeExpander as I, plannerSuccess as J, planFieldEventOperations as K, contractNamespaceToSchemaIR as L, _default as M, applyTableRename as N, TableRename as O, assembleAuthoringContributions as P, temporalStringAuthoringPresets as Q, contractToSchemaIR as R, SqlControlTargetDescriptor as S, SuppressionRecord as T, extractCodecControlHooks as U, detectDestructiveChanges as V, partitionCallsByControlPolicy as W, runnerSuccess as X, runnerFailure as Y, temporalCodecPresetWithPrecision as Z, NativeTypeExpander as _, DataTypeResolver as a, ResolvedTableRename as b, EnumNamespaceSchemaResolver as c, MigrationOperationPolicy$1 as d, MigrationPlan$1 as f, MigrationPlannerResult as g, MigrationPlannerConflict$1 as h, ControlPolicySubject as i, TargetMigrationsCapability as j, TableRenameByHand as k, INIT_ADDITIVE_POLICY as l, MigrationPlanner as m, ApplyTableRenameInput as n, DefaultRenderer as o, MigrationPlanOperation$1 as p, plannerFailure as q, ContractToSchemaIROptions as r, DefaultResolver as s, AppliedTableRename as t, MigrationOperationClass as u, PlanFieldEventOperationsOptions as v, SqlPslBuildContext as w, SqlControlFamilyInstance as x, RenameTableReferences as y, controlPolicyForCall as z };
|
|
1065
|
+
//# sourceMappingURL=control-BFgBjkQh.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-BFgBjkQh.d.mts","names":[],"sources":["../../../../2-sql/9-family/dist/control.d.mts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;UAoBU;WACC;WACA;WACA;WACA;;KAEN,0BAA0B,YAAY;UACjC;WACC,kBAAkB,cAAc;WAChC,cAAc;WACd,sBAAsB;;UAEvB,iCAAiC,6BAA6B,kBAAkB,kBAAkB,kBAAkB,wBAAwB,kBAAkB,wBAAwB,SAAS,cAAc,yBAAyB;;;;;;;;;EAS9O,oBAAoB,wBAAwB;EAC5C,OAAO;aACI,QAAQ;aACR;aACA;aACA;aACA;MACP,QAAQ;;;;;;;;;;EAUZ,aAAa;aACF;aACA,QAAQ;aACR;aACA,qBAAqB,cAAc;MAC1C;;;;;;;;;;EAUJ,2BAA2B,OAAO,kBAAkB;;;;;;;;EAQpD,mBAAmB,OAAO;EAC1B,KAAK;aACM,QAAQ;aACR;aACA;aACA;MACP,QAAQ;EACZ,WAAW;aACA,QAAQ;aACR;MACP,QAAQ;EACZ,iBAAiB,UAAU,kBAAkB;EAC7C,SAAS,KAAK,cAAc,SAAS,SAAS,0BAA0B,QAAQ;;;;;;EAMhF,WAAW;aACA,QAAQ;aACR;aACA;eACE;eACA;eACA;;MAET;;;;;EAKJ,aAAa;aACF,QAAQ;aACR;aACA;aACA;eACE;eACA;eACA;;MAET;;;;;EAKJ,iBAAiB;aACN,QAAQ;aACR;aACA;eACE;eACA;eACA;eACA;eACA;eACA;eACA;;MAET;EACJ,yCAAyC;EACzC,mBAAmB,qBAAqB,2BAA6B;;;;cAIzD,+BAA+B,+BAA+B;WACjE;WACA;WACA;WACA;WACA,UAAU;WACV,oBAAoB;WACpB;aACE;eACE;iBACE;iBACA;mBACE;mBACA;mBACA;qBACE;;;;eAIN;iBACE;iBACA;mBACE;mBACA;mBACA;qBACE;;;;eAIN;iBACE;iBACA;mBACE;mBACA;mBACA;qBACE;uBACE;uBACA;uBACA;uBACA;uBACA;;;;iBAIN;mBACE;mBACA;mBACA;qBACE;uBACE;uBACA;uBACA;uBACA;;;;;eAKR;iBACE;iBACA;mBACE;mBACA;mBACA;qBACE;;;;eAIN;iBACE;iBACA;mBACE;mBACA;mBACA;qBACE;;;;eAIN;iBACE;mBACE;mBACA;qBACE;qBACA;qBACA;uBACE;;qBAEF;uBACE;yBACE;yBACA;;;qBAGJ;;;iBAGJ;mBACE;mBACA;qBACE;qBACA;qBACA;uBACE;;qBAEF;uBACE;yBACE;yBACA;;;qBAGJ;;;iBAGJ;mBACE;mBACA;qBACE;qBACA;qBACA;uBACE;;qBAEF;uBACE;yBACE;yBACA;;;qBAGJ;;;iBAGJ;mBACE;mBACA;qBACE;qBACA;qBACA;uBACE;yBACE;yBACA;yBACA;yBACA;yBACA;;;;mBAIN;qBACE;qBACA;qBACA;uBACE;yBACE;yBACA;yBACA;yBACA;;;qBAGJ;uBACE;yBACE;yBACA;yBACA;2BACE;6BACE;6BACA;6BACA;;;;;qBAKR;;;iBAGJ;mBACE;mBACA;qBACE;qBACA;qBACA;uBACE;;qBAEF;uBACE;yBACE;yBACA;;;qBAGJ;;;iBAGJ;mBACE;mBACA;qBACE;qBACA;qBACA;uBACE;;qBAEF;uBACE;yBACE;yBACA;;;qBAGJ;;;;;aAKR;eACE;iBACE;mBACE;mBACA;mBACA;qBACE;qBACA;qBACA;qBACA;qBACA;;mBAEF;qBACE;qBACA;qBACA;uBACE;yBACE;yBACA;;;;;;;aAOZ,gEAAgE;aAChE;eACE;QACP;QACA;QACA;QACA;QACA;UACE;;QAEF,aAAa;QACb;UACE,2CAA2C;YACzC;4CACgC;;;;aAI/B;eACE;iBACE,0CAA0C;UACjD;0CACgC;iBACzB,yCAAyC;UAChD;mBACS;0CACuB;iBACzB,6CAA6C;UACpD;mBACS;0CACuB;iBACzB,4CAA4C;UACnD;mBACS;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA,UAAU;0CACa;iBACzB,4CAA4C;mBAC1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BACA;iBACA;mBACE;qBACE;qBACA,qBAAqB;;;;;;;;;cAS5B,UAAU"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { u as namingOf } from "./naming-Cc_t1q6s-CouBOmqZ.mjs";
|
|
2
2
|
import { t as sqlContractCanonicalizationHooks } from "./canonicalization-hooks-dmXkOR4a.mjs";
|
|
3
|
-
import { c as StorageTable } from "./storage-table-ZzbR-xzQ-C8gXT45E.mjs";
|
|
3
|
+
import { c as StorageTable, n as ForeignKey } from "./storage-table-ZzbR-xzQ-C8gXT45E.mjs";
|
|
4
4
|
import { a as sqlExpressionAuthoringEntry, o as sqlExpressionDataType, r as assertNothingCastsFromSqlExpression, t as SQL_EXPRESSION_DATA_TYPE_ID } from "./sql-expression-BXx0Ilj-.mjs";
|
|
5
|
-
import { u as isStorageTypeInstance } from "./types-BmXzMDQL.mjs";
|
|
5
|
+
import { c as isMaterializedSqlNamespace, o as SqlStorage, u as isStorageTypeInstance } from "./types-BmXzMDQL.mjs";
|
|
6
6
|
import { c as SqlSchemaIR, n as RelationalSchemaNodeKind, u as SqlTableIR } from "./types-C5QzgUrH-B7IJM6qN.mjs";
|
|
7
7
|
import { f as sqlAttributeSpecs } from "./sql-attribute-specs-Bs9QDuS7-DmIRJUz9.mjs";
|
|
8
8
|
import { t as sqlEmission } from "./dist-DeiKZwAD.mjs";
|
|
@@ -12,7 +12,7 @@ import { t as sqlFamilyError } from "./errors-B5g0xWro-mWH2C07F.mjs";
|
|
|
12
12
|
import { t as SqlContractSerializer } from "./sql-contract-serializer-C90xg7_q-DBJSt3MT.mjs";
|
|
13
13
|
import { t as collectSupportedCodecTypeIds } from "./verify-BVk5bjdH-BXgGLM2U.mjs";
|
|
14
14
|
import { TEMPORAL_ON_CREATE_ARG, TEMPORAL_ON_UPDATE_ARG, TIMESTAMP_NOW_GENERATOR_ID, temporalAuthoringPresets, temporalPhaseTemplate } from "@prisma/orm-framework/components/authoring";
|
|
15
|
-
import { isPlainRecord } from "@prisma/orm-framework/components/ir";
|
|
15
|
+
import { UNBOUND_NAMESPACE_ID, isPlainRecord } from "@prisma/orm-framework/components/ir";
|
|
16
16
|
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
17
17
|
import { effectiveControlPolicy } from "@prisma/orm-framework/contract/types";
|
|
18
18
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
@@ -619,6 +619,118 @@ var SqlFamilyDescriptor = class {
|
|
|
619
619
|
return createSqlFamilyInstance(stack);
|
|
620
620
|
}
|
|
621
621
|
};
|
|
622
|
+
const TABLE_RENAME_UNMATCHED_CODE = "MIGRATION.TABLE_RENAME_UNMATCHED";
|
|
623
|
+
function tableLabel(namespaceId, tableName) {
|
|
624
|
+
return namespaceId === void 0 || namespaceId === UNBOUND_NAMESPACE_ID ? tableName : `${namespaceId}.${tableName}`;
|
|
625
|
+
}
|
|
626
|
+
function namespacesDeclaring(contract, tableName) {
|
|
627
|
+
return Object.values(contract.storage.namespaces).filter((namespace) => Object.hasOwn(namespace.entries.table ?? {}, tableName)).map((namespace) => namespace.id);
|
|
628
|
+
}
|
|
629
|
+
function declares(contract, namespaceId, tableName) {
|
|
630
|
+
return Object.hasOwn(contract.storage.namespaces[namespaceId]?.entries.table ?? {}, tableName);
|
|
631
|
+
}
|
|
632
|
+
function unmatched(rename, reason) {
|
|
633
|
+
return sqlFamilyError(TABLE_RENAME_UNMATCHED_CODE, `renameTable "${tableLabel(rename.namespaceId, rename.from)}" to "${rename.to}" does not match the migration's contracts: ${reason}.`, {
|
|
634
|
+
why: "renameTable must name a table of the migration's start contract and a new name that the end contract has and the start contract does not. Make the rename its own schema change, so the migration's start contract is the schema before the rename and its end contract the schema after it, and check the spelling and the namespace.",
|
|
635
|
+
meta: {
|
|
636
|
+
from: rename.from,
|
|
637
|
+
to: rename.to
|
|
638
|
+
}
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
function resolveTableRename(rename, startContract, endContract) {
|
|
642
|
+
const namespaceIds = rename.namespaceId === void 0 ? namespacesDeclaring(startContract, rename.from) : declares(startContract, rename.namespaceId, rename.from) ? [rename.namespaceId] : [];
|
|
643
|
+
const [namespaceId, ...others] = namespaceIds;
|
|
644
|
+
if (namespaceId === void 0) return notOk(unmatched(rename, `table "${tableLabel(rename.namespaceId, rename.from)}" does not exist in the start contract`));
|
|
645
|
+
if (others.length > 0) return notOk(unmatched(rename, `table "${rename.from}" is declared in more than one namespace (${namespaceIds.join(", ")}); name its namespace`));
|
|
646
|
+
if (declares(startContract, namespaceId, rename.to)) return notOk(unmatched(rename, `table "${tableLabel(namespaceId, rename.to)}" already exists in the start contract`));
|
|
647
|
+
if (!declares(endContract, namespaceId, rename.to)) return notOk(unmatched(rename, `table "${tableLabel(namespaceId, rename.to)}" does not exist in the end contract`));
|
|
648
|
+
return ok({
|
|
649
|
+
namespaceId,
|
|
650
|
+
from: rename.from,
|
|
651
|
+
to: rename.to
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
function renamedReference(reference, rename) {
|
|
655
|
+
if (!(reference.spaceId === void 0) || reference.namespaceId !== rename.namespaceId || reference.tableName !== rename.from) return reference;
|
|
656
|
+
return {
|
|
657
|
+
...reference,
|
|
658
|
+
tableName: rename.to
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
function renameForeignKeys(table, rename) {
|
|
662
|
+
if (!table.foreignKeys.some((fk) => renamedReference(fk.source, rename) !== fk.source || renamedReference(fk.target, rename) !== fk.target)) return table;
|
|
663
|
+
return new StorageTable({
|
|
664
|
+
...table,
|
|
665
|
+
foreignKeys: table.foreignKeys.map((fk) => new ForeignKey({
|
|
666
|
+
...fk,
|
|
667
|
+
source: renamedReference(fk.source, rename),
|
|
668
|
+
target: renamedReference(fk.target, rename)
|
|
669
|
+
}))
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* The same namespace instance with only `entries` replaced: every own
|
|
674
|
+
* property, including the non-enumerable `kind`, is carried over onto the
|
|
675
|
+
* same prototype, so the target's namespace class (its `qualifyTable`,
|
|
676
|
+
* `ddlSchemaName`, entity getters) keeps working on the copy. This is the
|
|
677
|
+
* one place a frozen contract node is rebuilt without its constructor: the
|
|
678
|
+
* constructors re-hydrate `entries` from raw input, which the already
|
|
679
|
+
* hydrated entities here do not need.
|
|
680
|
+
*/
|
|
681
|
+
function withEntries(namespace, entries) {
|
|
682
|
+
const copy = Object.create(Object.getPrototypeOf(namespace), {
|
|
683
|
+
...Object.getOwnPropertyDescriptors(namespace),
|
|
684
|
+
entries: {
|
|
685
|
+
value: Object.freeze(entries),
|
|
686
|
+
enumerable: true,
|
|
687
|
+
writable: false,
|
|
688
|
+
configurable: false
|
|
689
|
+
}
|
|
690
|
+
});
|
|
691
|
+
return Object.freeze(copy);
|
|
692
|
+
}
|
|
693
|
+
function renameTableInNamespace(namespace, rename, renameTableReferences) {
|
|
694
|
+
const ownsTable = rename.namespaceId === namespace.id;
|
|
695
|
+
const tables = Object.entries(namespace.entries.table ?? {}).map(([name, table]) => [ownsTable && name === rename.from ? rename.to : name, renameForeignKeys(table, rename)]);
|
|
696
|
+
if (tables.every(([name, table]) => namespace.entries.table?.[name] === table)) return namespace;
|
|
697
|
+
if (!isMaterializedSqlNamespace(namespace)) throw new InternalError(`applyTableRename: namespace "${namespace.id}" is not a materialized SQL namespace`);
|
|
698
|
+
const renamedTables = {
|
|
699
|
+
...namespace.entries,
|
|
700
|
+
table: Object.fromEntries(tables)
|
|
701
|
+
};
|
|
702
|
+
return withEntries(namespace, renameTableReferences === void 0 || !ownsTable ? renamedTables : renameTableReferences(renamedTables, rename));
|
|
703
|
+
}
|
|
704
|
+
function renameTableInContract(contract, rename, renameTableReferences) {
|
|
705
|
+
const namespaces = Object.fromEntries(Object.entries(contract.storage.namespaces).map(([id, namespace]) => [id, renameTableInNamespace(namespace, rename, renameTableReferences)]));
|
|
706
|
+
const materialized = {};
|
|
707
|
+
for (const [id, namespace] of Object.entries(namespaces)) {
|
|
708
|
+
if (!isMaterializedSqlNamespace(namespace)) throw new InternalError(`applyTableRename: namespace "${id}" is not a materialized SQL namespace`);
|
|
709
|
+
materialized[id] = namespace;
|
|
710
|
+
}
|
|
711
|
+
return {
|
|
712
|
+
...contract,
|
|
713
|
+
storage: new SqlStorage({
|
|
714
|
+
storageHash: contract.storage.storageHash,
|
|
715
|
+
...contract.storage.types === void 0 ? {} : { types: contract.storage.types },
|
|
716
|
+
namespaces: materialized
|
|
717
|
+
})
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* Resolves the table a migration renames against its start and end contracts and returns the start contract with that table under its new name, so a diff against the end contract sees the table under one name. The table must exist in the start contract (in exactly one namespace when the namespace is not given), and the new name must exist in the end contract and not in the start contract; otherwise the rename is refused with `MIGRATION.TABLE_RENAME_UNMATCHED`.
|
|
722
|
+
*
|
|
723
|
+
* Foreign keys that name the renamed table on either side are retargeted. Index, unique, check and primary-key names are carried unchanged. Target entity kinds that name the table are renamed by the target's `renameTableReferences`.
|
|
724
|
+
*/
|
|
725
|
+
function applyTableRename(input) {
|
|
726
|
+
if (input.startContract === null) return notOk(unmatched(input.rename, "the migration has no start contract"));
|
|
727
|
+
const resolved = resolveTableRename(input.rename, input.startContract, input.endContract);
|
|
728
|
+
if (!resolved.ok) return resolved;
|
|
729
|
+
return ok({
|
|
730
|
+
contract: renameTableInContract(input.startContract, resolved.value, input.renameTableReferences),
|
|
731
|
+
rename: resolved.value
|
|
732
|
+
});
|
|
733
|
+
}
|
|
622
734
|
function convertColumn(name, column, storageTypes, expandNativeType, renderDefault, resolveDefault, dataTypeOf) {
|
|
623
735
|
const resolved = resolveColumnTypeMetadata(column, storageTypes);
|
|
624
736
|
const baseNativeType = expandNativeType ? expandNativeType({
|
|
@@ -1311,6 +1423,11 @@ function plannedTable(node, namespaceId) {
|
|
|
1311
1423
|
tableName: node.name
|
|
1312
1424
|
};
|
|
1313
1425
|
}
|
|
1426
|
+
function renameNeedsNamespace(drop, dropped, contract, defaultNamespaceId) {
|
|
1427
|
+
if (drop.namespaceId !== UNBOUND_NAMESPACE_ID && drop.namespaceId !== defaultNamespaceId) return true;
|
|
1428
|
+
const declaredElsewhere = (namespaceId, tableName) => namespaceId !== drop.namespaceId && tableName === drop.tableName;
|
|
1429
|
+
return dropped.some((other) => declaredElsewhere(other.namespaceId, other.tableName)) || Object.values(contract.storage.namespaces).some((namespace) => Object.keys(namespace.entries.table ?? {}).some((tableName) => declaredElsewhere(namespace.id, tableName)));
|
|
1430
|
+
}
|
|
1314
1431
|
/**
|
|
1315
1432
|
* Finds every (drop `X`, create `Y`) pair in the same namespace where `X` is
|
|
1316
1433
|
* `Y` with its first letter lowered. That shape is the signature of a schema
|
|
@@ -1336,10 +1453,19 @@ function detectTableNameCaseChanges(input) {
|
|
|
1336
1453
|
for (const create of created) {
|
|
1337
1454
|
const drop = dropped.find((candidate) => candidate.namespaceId === create.namespaceId && candidate.tableName === lowerFirst(create.tableName));
|
|
1338
1455
|
if (drop === void 0) continue;
|
|
1456
|
+
const renameCall = input.renameTableCall({
|
|
1457
|
+
namespaceId: renameNeedsNamespace(drop, dropped, input.contract, input.defaultNamespaceId) ? drop.namespaceId : void 0,
|
|
1458
|
+
from: drop.tableName,
|
|
1459
|
+
to: create.tableName
|
|
1460
|
+
});
|
|
1339
1461
|
conflicts.push({
|
|
1340
1462
|
kind: "tableNameCaseChanged",
|
|
1341
1463
|
summary: `${TABLE_NAME_CASE_CHANGED_CODE}: table "${create.tableName}" would be created and table "${drop.tableName}" dropped. Prisma 8 changed the default table name: a model with no @@map now names its table verbatim, so model ${create.tableName} points at "${create.tableName}" instead of "${drop.tableName}".`,
|
|
1342
|
-
why: `To keep table "${drop.tableName}" and its rows, add @@map("${drop.tableName}") to model ${create.tableName} (or run the add-model-map codemod over the schema) and plan again.
|
|
1464
|
+
why: `To keep table "${drop.tableName}" and its rows, add @@map("${drop.tableName}") to model ${create.tableName} (or run the add-model-map codemod over the schema) and plan again. To rename the table and keep its rows instead: in a project with migration history, make the rename its own schema change, create its migration with prisma migration new --from <hash of the migration the database is at>, and add ${renameCall} to the migration's operations, which renames the table and the objects named after it; in a project that uses db update, rename it by hand with ${input.renameByHandStatements({
|
|
1465
|
+
namespaceId: create.namespaceId,
|
|
1466
|
+
from: drop.tableName,
|
|
1467
|
+
to: create.tableName
|
|
1468
|
+
}).join("; ")}, then run db update again.`,
|
|
1343
1469
|
location: {
|
|
1344
1470
|
namespaceId: create.namespaceId,
|
|
1345
1471
|
entityKind: "table",
|
|
@@ -1403,6 +1529,6 @@ function temporalCodecPresetWithPrecision(input) {
|
|
|
1403
1529
|
}
|
|
1404
1530
|
var control_default = new SqlFamilyDescriptor();
|
|
1405
1531
|
//#endregion
|
|
1406
|
-
export {
|
|
1532
|
+
export { temporalStringAuthoringPresets as S, plannerFailure as _, buildDataTypeResolver as a, runnerSuccess as b, contractToSchemaIR as c, createMigrationPlan as d, detectDestructiveChanges as f, planFieldEventOperations as g, partitionIssuesByControlPolicy as h, assembleAuthoringContributions as i, controlPolicyForCall as l, partitionCallsByControlPolicy as m, TABLE_NAME_CASE_CHANGED_CODE as n, buildNativeTypeExpander as o, detectTableNameCaseChanges as p, applyTableRename as r, contractNamespaceToSchemaIR as s, INIT_ADDITIVE_POLICY as t, control_default as u, plannerSuccess as v, temporalCodecPresetWithPrecision as x, runnerFailure as y };
|
|
1407
1533
|
|
|
1408
|
-
//# sourceMappingURL=control-
|
|
1534
|
+
//# sourceMappingURL=control-D7yb7l7O.mjs.map
|