@prisma/orm-target-postgres 8.0.0-rc.19-dev.4 → 8.0.0-rc.19-dev.5
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-DLPamqZO.d.mts → adapter-CVkrJLWQ.d.mts} +3 -3
- package/dist/{adapter-DLPamqZO.d.mts.map → adapter-CVkrJLWQ.d.mts.map} +1 -1
- package/dist/{adapter-BLduF4bR-clgZ076o.mjs → adapter-svGTIjA2-DDDsFolD.mjs} +3 -3
- package/dist/{adapter-BLduF4bR-clgZ076o.mjs.map → adapter-svGTIjA2-DDDsFolD.mjs.map} +1 -1
- package/dist/adapter.d.mts +2 -2
- package/dist/adapter.mjs +2 -2
- package/dist/adapter__adapter.d.mts +1 -1
- package/dist/adapter__adapter.mjs +2 -2
- package/dist/adapter__control.d.mts +1 -1
- package/dist/adapter__control.mjs +2 -2
- package/dist/adapter__control.mjs.map +1 -1
- package/dist/adapter__runtime.mjs +2 -2
- package/dist/adapter__runtime.mjs.map +1 -1
- package/dist/{contract-contributions-CRCEK7Dx-DQWxpLgr.mjs → contract-contributions-Xz2FpyfI-3anGCDno.mjs} +25 -4
- package/dist/{contract-contributions-CRCEK7Dx-DQWxpLgr.mjs.map → contract-contributions-Xz2FpyfI-3anGCDno.mjs.map} +1 -1
- package/dist/{contract-free-CN4hGOBI.mjs → contract-free-2xXXmS01.mjs} +2 -2
- package/dist/{contract-free-CN4hGOBI.mjs.map → contract-free-2xXXmS01.mjs.map} +1 -1
- package/dist/{contract-free-D1JEZVpQ.d.mts → contract-free-DCPNGs2e.d.mts} +2 -2
- package/dist/{contract-free-D1JEZVpQ.d.mts.map → contract-free-DCPNGs2e.d.mts.map} +1 -1
- package/dist/{control-kRer3n4t.d.mts → control-Dqf8WaSU.d.mts} +3 -3
- package/dist/{control-kRer3n4t.d.mts.map → control-Dqf8WaSU.d.mts.map} +1 -1
- package/dist/{control-policy-NpK0183H-DB8b5bNu.mjs → control-policy--gQ-4PQU-BrMfgXQY.mjs} +35 -7
- package/dist/control-policy--gQ-4PQU-BrMfgXQY.mjs.map +1 -0
- package/dist/{ddl-BrIDeRCe-ojLIc02T.mjs → ddl-B7Rqlz6D-BcwCMSB7.mjs} +52 -4
- package/dist/ddl-B7Rqlz6D-BcwCMSB7.mjs.map +1 -0
- package/dist/ddl-DC1--N63.d.mts +1 -0
- package/dist/{descriptor-meta-Cb7RcgEQ-qfcXndlR.mjs → descriptor-meta-BkD3nXF_-CnmmCqRU.mjs} +3 -3
- package/dist/{descriptor-meta-Cb7RcgEQ-qfcXndlR.mjs.map → descriptor-meta-BkD3nXF_-CnmmCqRU.mjs.map} +1 -1
- package/dist/{diff-database-schema-N-ftS4iF.d.mts → diff-database-schema-DPZdkysF.d.mts} +6 -1
- package/dist/{diff-database-schema-N-ftS4iF.d.mts.map → diff-database-schema-DPZdkysF.d.mts.map} +1 -1
- package/dist/{diff-database-schema-O45Q-UNo-6YARJ8Qu.mjs → diff-database-schema-tF8RnCMt-Bx_6en7R.mjs} +6 -5
- package/dist/{diff-database-schema-O45Q-UNo-6YARJ8Qu.mjs.map → diff-database-schema-tF8RnCMt-Bx_6en7R.mjs.map} +1 -1
- package/dist/{indexes-c2U6QZ4P-DgZWG_iu.d.mts → indexes-BYf6nXVv-DznOOzlT.d.mts} +3 -3
- package/dist/{indexes-c2U6QZ4P-DgZWG_iu.d.mts.map → indexes-BYf6nXVv-DznOOzlT.d.mts.map} +1 -1
- package/dist/{issue-planner-BrOqWTg5.d.mts → issue-planner-vL0kmTVI.d.mts} +2 -2
- package/dist/{issue-planner-BrOqWTg5.d.mts.map → issue-planner-vL0kmTVI.d.mts.map} +1 -1
- package/dist/{migration-cxHhDEGa.d.mts → migration-7VvUEoYO.d.mts} +3 -3
- package/dist/{migration-cxHhDEGa.d.mts.map → migration-7VvUEoYO.d.mts.map} +1 -1
- package/dist/migration-CbOh59ZJ.mjs.map +1 -1
- package/dist/{nodes-BYKl6zt_-BoUacQ_3.mjs → nodes-G8VTh4PM-D5t0nLdZ.mjs} +46 -3
- package/dist/{nodes-BYKl6zt_-BoUacQ_3.mjs.map → nodes-G8VTh4PM-D5t0nLdZ.mjs.map} +1 -1
- package/dist/{nodes-DOXes-fG-BifJqoRd.d.mts → nodes-s0Oe37jT-DY3kMSce.d.mts} +38 -4
- package/dist/nodes-s0Oe37jT-DY3kMSce.d.mts.map +1 -0
- package/dist/op-factory-call-C2r4PNO_.d.mts +1 -0
- package/dist/{op-factory-call-CtHJKITc-BMwiP_p7.mjs → op-factory-call-Dg9wUfmo-OAo-HYAA.mjs} +205 -4
- package/dist/op-factory-call-Dg9wUfmo-OAo-HYAA.mjs.map +1 -0
- package/dist/{op-factory-call-BAmu21qK-DjHPE4DG.d.mts → op-factory-call-nLHvNx0O-CGQ3bNN5.d.mts} +42 -6
- package/dist/{op-factory-call-BAmu21qK-DjHPE4DG.d.mts.map → op-factory-call-nLHvNx0O-CGQ3bNN5.d.mts.map} +1 -1
- package/dist/{planner-BQQdHpAs.d.mts → planner-CNG8pGm7.d.mts} +5 -4
- package/dist/planner-CNG8pGm7.d.mts.map +1 -0
- package/dist/{planner-produced-postgres-migration-CHFWM40q-DEXCOdWT.mjs → planner-produced-postgres-migration-BG9VdiLq-B0rps48X.mjs} +4 -4
- package/dist/{planner-produced-postgres-migration-CHFWM40q-DEXCOdWT.mjs.map → planner-produced-postgres-migration-BG9VdiLq-B0rps48X.mjs.map} +1 -1
- package/dist/planner-produced-postgres-migration-DEfRhvVl.d.mts +1 -0
- package/dist/{planner-produced-postgres-migration-C60Pid87-CFops3Az.d.mts → planner-produced-postgres-migration-DyIXJ3MR-CvH0IEvz.d.mts} +3 -3
- package/dist/planner-produced-postgres-migration-DyIXJ3MR-CvH0IEvz.d.mts.map +1 -0
- package/dist/{planner-DD0z05v--ByV38sBF.mjs → planner-t4DrkQjZ-DhoUJJSe.mjs} +144 -22
- package/dist/planner-t4DrkQjZ-DhoUJJSe.mjs.map +1 -0
- package/dist/{postgres-migration-C3HdYUMt-DPWn_-7n.d.mts → postgres-migration-C5deJ3Ne-BBt4uBYb.d.mts} +29 -3
- package/dist/{postgres-migration-C3HdYUMt-DPWn_-7n.d.mts.map → postgres-migration-C5deJ3Ne-BBt4uBYb.d.mts.map} +1 -1
- package/dist/{postgres-migration-CliSGXur-BQsla3Y9.mjs → postgres-migration-DPHUi8l7-AGl5Cbhu.mjs} +160 -8
- package/dist/postgres-migration-DPHUi8l7-AGl5Cbhu.mjs.map +1 -0
- package/dist/{render-ops-CrYiS0XA-Bkqye2yB.mjs → render-ops-BoFTJ9D1-BsFhuMdE.mjs} +3 -3
- package/dist/{render-ops-CrYiS0XA-Bkqye2yB.mjs.map → render-ops-BoFTJ9D1-BsFhuMdE.mjs.map} +1 -1
- package/dist/target.d.mts +13 -13
- package/dist/target.mjs +11 -11
- package/dist/target__contract-free.d.mts +1 -1
- package/dist/target__contract-free.mjs +2 -2
- package/dist/target__control.mjs +60 -17
- package/dist/target__control.mjs.map +1 -1
- package/dist/target__ddl.d.mts +3 -3
- package/dist/target__ddl.mjs +2 -2
- package/dist/target__diff-database-schema.d.mts +1 -1
- package/dist/target__diff-database-schema.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 +2 -2
- package/dist/target__migration.mjs +2 -2
- package/dist/target__op-factory-call.d.mts +3 -3
- package/dist/target__op-factory-call.mjs +2 -2
- 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.d.mts +1 -1
- package/dist/target__planner.mjs +2 -2
- package/dist/target__render-ops.mjs +1 -1
- package/package.json +9 -9
- package/dist/control-policy-NpK0183H-DB8b5bNu.mjs.map +0 -1
- package/dist/ddl-BrIDeRCe-ojLIc02T.mjs.map +0 -1
- package/dist/ddl-D_JWHRzo.d.mts +0 -1
- package/dist/nodes-DOXes-fG-BifJqoRd.d.mts.map +0 -1
- package/dist/op-factory-call-CDxHGgzs.d.mts +0 -1
- package/dist/op-factory-call-CtHJKITc-BMwiP_p7.mjs.map +0 -1
- package/dist/planner-BQQdHpAs.d.mts.map +0 -1
- package/dist/planner-DD0z05v--ByV38sBF.mjs.map +0 -1
- package/dist/planner-produced-postgres-migration-C60Pid87-CFops3Az.d.mts.map +0 -1
- package/dist/planner-produced-postgres-migration-Ch-pBAnV.d.mts +0 -1
- package/dist/postgres-migration-CliSGXur-BQsla3Y9.mjs.map +0 -1
package/dist/{op-factory-call-CtHJKITc-BMwiP_p7.mjs → op-factory-call-Dg9wUfmo-OAo-HYAA.mjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as postgresError } from "./errors-BrhQYgdL-D_lIrddD.mjs";
|
|
2
2
|
import { a as quoteQualifiedName, i as quoteIdentifier, n as escapeLiteral, o as validateEnumValueLength, t as POSTGRES_QUOTING } from "./sql-utils-Bnw3JbWf-zvWDkyrr.mjs";
|
|
3
3
|
import { t as DEFAULT_NAMESPACE_ID } from "./namespace-ids-xtp_ZY86-Cpp8PTxD.mjs";
|
|
4
|
-
import { A as
|
|
4
|
+
import { A as indexDefinitionAst, B as schemaHoldsNoObjectsAst, C as disableRowLevelSecurity$1, D as dropSchema$1, E as dropPolicy, F as relationKindAst, H as sequenceValuesFitAst, I as rlsEnabledAst, L as rlsPolicyDefinitionAst, M as nativeEnumTypeExistsAst, N as nativeEnumValueExistsAst, O as dropType, P as noNullValuesAst, R as rlsPolicyExistsAst, S as createType, T as dropIndex$1, U as tableExistsAst, V as sequenceNameAvailableAst, W as tableIsEmptyAst, _ as constraintExistsAst, a as alterPolicyRename, b as createSchema, c as alterTableSetSchema, d as columnExistsAst, f as columnNullabilityAst, g as constraintDefinitionAst, h as columnTypeOidAst, i as alterIndexRename, j as indexExistsAst, k as extensionExistsAst, l as columnDefaultAst, m as columnTypeAst, n as addConstraintAction, o as alterSchemaRename, p as columnOwnsSequenceAst, q as unboundTableMovedAst, r as alterColumnTypeAction, s as alterTable, t as addColumnAction, u as columnDefaultSequenceAst, v as createIndex$1, w as dropDefaultAction, x as createTable, y as createPolicy, z as schemaExistsAst } from "./ddl-B7Rqlz6D-BcwCMSB7.mjs";
|
|
5
5
|
import { i as policyRoleList, t as POLICY_COMMAND_SQL } from "./canonicalize-RdxoUHao-DK_M6HU-.mjs";
|
|
6
6
|
import { r as autoincrementWidthOfPseudoType, t as autoincrementWidth } from "./autoincrement-widths-O1bL_G0T-B7F3b4oU.mjs";
|
|
7
7
|
import { t as postgresObjectName } from "./postgres-object-name-FPikIvOw-BNs44hTu.mjs";
|
|
@@ -10,6 +10,7 @@ import { t as buildTargetDetails } from "./planner-target-details-CUEF0s90-COTks
|
|
|
10
10
|
import { DdlColumn, FunctionColumnDefault, LiteralColumnDefault, opaqueSql } from "@prisma/orm-family-sql/relational-core/ast";
|
|
11
11
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
12
12
|
import { InternalError, assertNever } from "@prisma/orm-framework/utils/internal-error";
|
|
13
|
+
import { type } from "arktype";
|
|
13
14
|
import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
|
|
14
15
|
import { expectAbsent, expectPresent } from "@prisma/orm-framework/components/control";
|
|
15
16
|
import { namingOf } from "@prisma/orm-family-sql/schema-ir/naming";
|
|
@@ -19,7 +20,7 @@ import { checkSqlDefaultText, checkSqlExpressionText, convertedColumnMeta, creat
|
|
|
19
20
|
import { unfilledPlaceholderOperation } from "@prisma/orm-framework/errors/migration";
|
|
20
21
|
import { TsExpression, jsonToTsSource, tsObjectSource } from "@prisma/orm-framework/ts-render";
|
|
21
22
|
import { REFERENTIAL_ACTION_SQL } from "@prisma/orm-family-sql/contract/referential-action-sql";
|
|
22
|
-
//#region ../../../3-targets/3-targets/postgres/dist/op-factory-call-
|
|
23
|
+
//#region ../../../3-targets/3-targets/postgres/dist/op-factory-call-Dg9wUfmo.mjs
|
|
23
24
|
/**
|
|
24
25
|
* Maps a planner schema name to the contract-free DDL builder's optional
|
|
25
26
|
* `schema` field: the unbound sentinel becomes `undefined` (the builder omits
|
|
@@ -970,6 +971,126 @@ async function renameRlsPolicy(schemaName, tableName, oldPolicyName, newPolicyNa
|
|
|
970
971
|
postcheck: [step(`verify RLS policy "${newPolicyName}" exists`, newPresent.sql, newPresent.params, expectPresent(`RLS policy "${newPolicyName}" on "${tableName}"`)), step(`verify RLS policy "${oldPolicyName}" no longer exists`, oldAbsent.sql, oldAbsent.params, expectAbsent(`RLS policy "${oldPolicyName}" on "${tableName}"`))]
|
|
971
972
|
};
|
|
972
973
|
}
|
|
974
|
+
const SchemaContentsMeta = type({ schemaContents: { schema: "string" } });
|
|
975
|
+
/** The meta of a step that fails while a schema still holds objects; the runner then names them. */
|
|
976
|
+
function schemaContentsMeta(schema) {
|
|
977
|
+
return { schemaContents: { schema } };
|
|
978
|
+
}
|
|
979
|
+
function schemaContentsOf(step) {
|
|
980
|
+
const meta = SchemaContentsMeta(step.meta ?? {});
|
|
981
|
+
return meta instanceof type.errors ? void 0 : meta.schemaContents.schema;
|
|
982
|
+
}
|
|
983
|
+
const SCHEMA_OBJECTS_SQL = `SELECT kind, name FROM (
|
|
984
|
+
SELECT CASE c.relkind
|
|
985
|
+
WHEN 'v' THEN 'view'
|
|
986
|
+
WHEN 'm' THEN 'materialized view'
|
|
987
|
+
WHEN 'S' THEN 'sequence'
|
|
988
|
+
WHEN 'f' THEN 'foreign table'
|
|
989
|
+
WHEN 'c' THEN 'type'
|
|
990
|
+
ELSE 'table'
|
|
991
|
+
END AS kind, c.relname::text AS name
|
|
992
|
+
FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
|
993
|
+
WHERE n.nspname = $1 AND c.relkind IN ('r', 'p', 'v', 'm', 'S', 'f', 'c')
|
|
994
|
+
UNION ALL
|
|
995
|
+
SELECT 'type', t.typname::text
|
|
996
|
+
FROM pg_catalog.pg_type t JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace
|
|
997
|
+
WHERE n.nspname = $1 AND t.typrelid = 0 AND t.typelem = 0
|
|
998
|
+
UNION ALL
|
|
999
|
+
SELECT 'function', p.proname::text
|
|
1000
|
+
FROM pg_catalog.pg_proc p JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
|
|
1001
|
+
WHERE n.nspname = $1
|
|
1002
|
+
) AS objects ORDER BY name, kind`;
|
|
1003
|
+
const NAMED_OBJECTS = 10;
|
|
1004
|
+
function listed(items) {
|
|
1005
|
+
if (items.length === 1) return items[0] ?? "";
|
|
1006
|
+
return `${items.slice(0, -1).join(", ")} and ${items.at(-1)}`;
|
|
1007
|
+
}
|
|
1008
|
+
const UNQUOTED_IDENTIFIER = /^[a-z_][a-z0-9_$]*$/;
|
|
1009
|
+
/** An identifier as Postgres writes it in its messages: quoted only where it must be. */
|
|
1010
|
+
function identifierText(identifier) {
|
|
1011
|
+
return UNQUOTED_IDENTIFIER.test(identifier) ? identifier : `"${identifier.replaceAll("\"", "\"\"")}"`;
|
|
1012
|
+
}
|
|
1013
|
+
/**
|
|
1014
|
+
* The objects a schema query found, each named with its schema as Postgres names objects in its
|
|
1015
|
+
* messages, such as a view that depends on a table: the form a blocked drop reports everywhere.
|
|
1016
|
+
*/
|
|
1017
|
+
function schemaBlockingObjects(schema, objects) {
|
|
1018
|
+
return objects.map(({ kind, name }) => ({
|
|
1019
|
+
kind,
|
|
1020
|
+
name: `${identifierText(schema)}.${identifierText(name)}`
|
|
1021
|
+
}));
|
|
1022
|
+
}
|
|
1023
|
+
/** What a runner failure says of the objects that keep a schema from being dropped. */
|
|
1024
|
+
function schemaObjectsSummary(schema, objects) {
|
|
1025
|
+
const named = objects.slice(0, NAMED_OBJECTS).map(({ kind, name }) => `${kind} ${name}`);
|
|
1026
|
+
const more = objects.length - named.length;
|
|
1027
|
+
return `Schema "${schema}" still holds ${listed(more > 0 ? [...named, `${more} more`] : named)}, so it cannot be dropped.`;
|
|
1028
|
+
}
|
|
1029
|
+
async function setTableSchema(schemaName, tableName, toSchemaName, lowerer) {
|
|
1030
|
+
const from = tableExistsAst(schemaName, tableName);
|
|
1031
|
+
const to = tableExistsAst(toSchemaName, tableName);
|
|
1032
|
+
const fromPresent = await lowerer.lowerToExecuteRequest(from.tablePresent());
|
|
1033
|
+
const toSchemaPresent = await lowerer.lowerToExecuteRequest(schemaExistsAst(toSchemaName).schemaPresent());
|
|
1034
|
+
const toAbsent = await lowerer.lowerToExecuteRequest(to.tableAbsent());
|
|
1035
|
+
const statement = await lowerer.lowerToExecuteRequest(alterTableSetSchema({
|
|
1036
|
+
schema: boundSchema(schemaName),
|
|
1037
|
+
table: tableName,
|
|
1038
|
+
to: toSchemaName
|
|
1039
|
+
}));
|
|
1040
|
+
const toPresent = await lowerer.lowerToExecuteRequest(to.tablePresent());
|
|
1041
|
+
const fromAbsent = await lowerer.lowerToExecuteRequest(schemaName === UNBOUND_NAMESPACE_ID ? unboundTableMovedAst(tableName, toSchemaName) : from.tableAbsent());
|
|
1042
|
+
return {
|
|
1043
|
+
id: `setTableSchema.${tableName}`,
|
|
1044
|
+
label: `Move table "${tableName}" to schema "${toSchemaName}"`,
|
|
1045
|
+
operationClass: "widening",
|
|
1046
|
+
target: targetDetails("table", tableName, toSchemaName),
|
|
1047
|
+
precheck: [
|
|
1048
|
+
step(`ensure table "${tableName}" exists`, fromPresent.sql, fromPresent.params),
|
|
1049
|
+
step(`ensure schema "${toSchemaName}" exists`, toSchemaPresent.sql, toSchemaPresent.params),
|
|
1050
|
+
step(`ensure schema "${toSchemaName}" has no table "${tableName}"`, toAbsent.sql, toAbsent.params)
|
|
1051
|
+
],
|
|
1052
|
+
execute: [step(`move table "${tableName}" to schema "${toSchemaName}"`, statement.sql, statement.params)],
|
|
1053
|
+
postcheck: [step(`verify table "${tableName}" exists in schema "${toSchemaName}"`, toPresent.sql, toPresent.params), step(`verify table "${tableName}" no longer exists where it was`, fromAbsent.sql, fromAbsent.params)]
|
|
1054
|
+
};
|
|
1055
|
+
}
|
|
1056
|
+
async function renameSchema(schemaName, toSchemaName, lowerer) {
|
|
1057
|
+
const from = schemaExistsAst(schemaName);
|
|
1058
|
+
const to = schemaExistsAst(toSchemaName);
|
|
1059
|
+
const fromPresent = await lowerer.lowerToExecuteRequest(from.schemaPresent());
|
|
1060
|
+
const toAbsent = await lowerer.lowerToExecuteRequest(to.schemaAbsent());
|
|
1061
|
+
const statement = await lowerer.lowerToExecuteRequest(alterSchemaRename({
|
|
1062
|
+
schema: schemaName,
|
|
1063
|
+
to: toSchemaName
|
|
1064
|
+
}));
|
|
1065
|
+
const toPresent = await lowerer.lowerToExecuteRequest(to.schemaPresent());
|
|
1066
|
+
const fromAbsent = await lowerer.lowerToExecuteRequest(from.schemaAbsent());
|
|
1067
|
+
return {
|
|
1068
|
+
id: `renameSchema.${schemaName}`,
|
|
1069
|
+
label: `Rename schema "${schemaName}" to "${toSchemaName}"`,
|
|
1070
|
+
operationClass: "widening",
|
|
1071
|
+
target: { id: "postgres" },
|
|
1072
|
+
precheck: [step(`ensure schema "${schemaName}" exists`, fromPresent.sql, fromPresent.params), step(`ensure schema "${toSchemaName}" does not exist`, toAbsent.sql, toAbsent.params)],
|
|
1073
|
+
execute: [step(`rename schema "${schemaName}" to "${toSchemaName}"`, statement.sql, statement.params)],
|
|
1074
|
+
postcheck: [step(`verify schema "${toSchemaName}" exists`, toPresent.sql, toPresent.params), step(`verify schema "${schemaName}" no longer exists`, fromAbsent.sql, fromAbsent.params)]
|
|
1075
|
+
};
|
|
1076
|
+
}
|
|
1077
|
+
async function dropSchema(schemaName, lowerer) {
|
|
1078
|
+
const empty = await lowerer.lowerToExecuteRequest(schemaHoldsNoObjectsAst(schemaName));
|
|
1079
|
+
const statement = await lowerer.lowerToExecuteRequest(dropSchema$1({ schema: schemaName }));
|
|
1080
|
+
const absent = await lowerer.lowerToExecuteRequest(schemaExistsAst(schemaName).schemaAbsent());
|
|
1081
|
+
return {
|
|
1082
|
+
id: `dropSchema.${schemaName}`,
|
|
1083
|
+
label: `Drop schema "${schemaName}"`,
|
|
1084
|
+
operationClass: "widening",
|
|
1085
|
+
target: { id: "postgres" },
|
|
1086
|
+
precheck: [{
|
|
1087
|
+
...step(`ensure schema "${schemaName}" holds no tables, views, sequences, types or functions`, empty.sql, empty.params),
|
|
1088
|
+
meta: schemaContentsMeta(schemaName)
|
|
1089
|
+
}],
|
|
1090
|
+
execute: [step(`drop schema "${schemaName}"`, statement.sql, statement.params)],
|
|
1091
|
+
postcheck: [step(`verify schema "${schemaName}" does not exist`, absent.sql, absent.params)]
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
973
1094
|
async function dropTable(schemaName, tableName, lowerer) {
|
|
974
1095
|
const qualified = qualifyTableName(schemaName, tableName);
|
|
975
1096
|
const checks = tableExistsAst(schemaName, tableName);
|
|
@@ -2249,6 +2370,7 @@ var CreateSchemaCall = class extends PostgresOpFactoryCallNode {
|
|
|
2249
2370
|
operationClass = "additive";
|
|
2250
2371
|
schemaName;
|
|
2251
2372
|
label;
|
|
2373
|
+
companions = [];
|
|
2252
2374
|
constructor(schemaName) {
|
|
2253
2375
|
super();
|
|
2254
2376
|
this.schemaName = schemaName;
|
|
@@ -2284,6 +2406,85 @@ var CreateSchemaCall = class extends PostgresOpFactoryCallNode {
|
|
|
2284
2406
|
return [];
|
|
2285
2407
|
}
|
|
2286
2408
|
};
|
|
2409
|
+
function requireLowerer(lowerer, factory, subject) {
|
|
2410
|
+
if (lowerer === void 0) throw postgresError("MIGRATION.POSTGRES_CONTROL_STACK_MISSING", `${factory}.toOp: a lowerer is required on the Postgres planner path (${subject}). Pass the control adapter to createPostgresMigrationPlanner.`, { meta: { factory } });
|
|
2411
|
+
return lowerer;
|
|
2412
|
+
}
|
|
2413
|
+
var SetTableSchemaCall = class extends PostgresOpFactoryCallNode {
|
|
2414
|
+
factoryName = "setTableSchema";
|
|
2415
|
+
operationClass = "widening";
|
|
2416
|
+
schemaName;
|
|
2417
|
+
tableName;
|
|
2418
|
+
toSchemaName;
|
|
2419
|
+
label;
|
|
2420
|
+
companions = [];
|
|
2421
|
+
constructor(schemaName, tableName, toSchemaName) {
|
|
2422
|
+
super();
|
|
2423
|
+
this.schemaName = schemaName;
|
|
2424
|
+
this.tableName = tableName;
|
|
2425
|
+
this.toSchemaName = toSchemaName;
|
|
2426
|
+
this.label = `Move table "${tableName}" to schema "${toSchemaName}"`;
|
|
2427
|
+
this.freeze();
|
|
2428
|
+
}
|
|
2429
|
+
async toOp(lowerer) {
|
|
2430
|
+
return setTableSchema(this.schemaName, this.tableName, this.toSchemaName, requireLowerer(lowerer, "SetTableSchemaCall", `table "${this.tableName}"`));
|
|
2431
|
+
}
|
|
2432
|
+
renderTypeScript() {
|
|
2433
|
+
const opts = [];
|
|
2434
|
+
if (this.schemaName !== UNBOUND_NAMESPACE_ID) opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);
|
|
2435
|
+
opts.push(`table: ${jsonToTsSource(this.tableName)}`);
|
|
2436
|
+
opts.push(`to: ${jsonToTsSource(this.toSchemaName)}`);
|
|
2437
|
+
return `this.setTableSchema({ ${opts.join(", ")} })`;
|
|
2438
|
+
}
|
|
2439
|
+
importRequirements() {
|
|
2440
|
+
return [];
|
|
2441
|
+
}
|
|
2442
|
+
};
|
|
2443
|
+
var RenameSchemaCall = class extends PostgresOpFactoryCallNode {
|
|
2444
|
+
factoryName = "renameSchema";
|
|
2445
|
+
operationClass = "widening";
|
|
2446
|
+
schemaName;
|
|
2447
|
+
toSchemaName;
|
|
2448
|
+
label;
|
|
2449
|
+
companions = [];
|
|
2450
|
+
constructor(schemaName, toSchemaName) {
|
|
2451
|
+
super();
|
|
2452
|
+
this.schemaName = schemaName;
|
|
2453
|
+
this.toSchemaName = toSchemaName;
|
|
2454
|
+
this.label = `Rename schema "${schemaName}" to "${toSchemaName}"`;
|
|
2455
|
+
this.freeze();
|
|
2456
|
+
}
|
|
2457
|
+
async toOp(lowerer) {
|
|
2458
|
+
return renameSchema(this.schemaName, this.toSchemaName, requireLowerer(lowerer, "RenameSchemaCall", `schema "${this.schemaName}"`));
|
|
2459
|
+
}
|
|
2460
|
+
renderTypeScript() {
|
|
2461
|
+
return `this.renameSchema({ schema: ${jsonToTsSource(this.schemaName)}, to: ${jsonToTsSource(this.toSchemaName)} })`;
|
|
2462
|
+
}
|
|
2463
|
+
importRequirements() {
|
|
2464
|
+
return [];
|
|
2465
|
+
}
|
|
2466
|
+
};
|
|
2467
|
+
var DropSchemaCall = class extends PostgresOpFactoryCallNode {
|
|
2468
|
+
factoryName = "dropSchema";
|
|
2469
|
+
operationClass = "widening";
|
|
2470
|
+
schemaName;
|
|
2471
|
+
label;
|
|
2472
|
+
constructor(schemaName) {
|
|
2473
|
+
super();
|
|
2474
|
+
this.schemaName = schemaName;
|
|
2475
|
+
this.label = `Drop schema "${schemaName}"`;
|
|
2476
|
+
this.freeze();
|
|
2477
|
+
}
|
|
2478
|
+
async toOp(lowerer) {
|
|
2479
|
+
return dropSchema(this.schemaName, requireLowerer(lowerer, "DropSchemaCall", `schema "${this.schemaName}"`));
|
|
2480
|
+
}
|
|
2481
|
+
renderTypeScript() {
|
|
2482
|
+
return `this.dropSchema({ schema: ${jsonToTsSource(this.schemaName)} })`;
|
|
2483
|
+
}
|
|
2484
|
+
importRequirements() {
|
|
2485
|
+
return [];
|
|
2486
|
+
}
|
|
2487
|
+
};
|
|
2287
2488
|
var CreateNativeEnumTypeCall = class extends PostgresOpFactoryCallNode {
|
|
2288
2489
|
factoryName = "createNativeEnumType";
|
|
2289
2490
|
operationClass = "additive";
|
|
@@ -2612,6 +2813,6 @@ function columnNameOfCall(call) {
|
|
|
2612
2813
|
if ("column" in call && call.column instanceof DdlColumn) return call.column.name;
|
|
2613
2814
|
}
|
|
2614
2815
|
//#endregion
|
|
2615
|
-
export {
|
|
2816
|
+
export { RenameColumnCall as A, alterColumnTypeCallText as B, DropNativeEnumTypeCall as C, DropTableCall as D, DropSchemaCall as E, RenameTableCall as F, postgresDefaultToDdlColumnDefault as G, createExtension as H, SCHEMA_OBJECTS_SQL as I, schemaContentsOf as J, renameTableStatement as K, SetDefaultCall as L, RenameIndexCall as M, RenamePostgresRlsPolicyCall as N, EnableRowLevelSecurityCall as O, RenameSchemaCall as P, SetNotNullCall as R, DropIndexCall as S, DropPostgresRlsPolicyCall as T, installExtension as U, columnNameOfCall as V, isPostgresOpFactoryCall as W, schemaObjectsSummary as Y, DisableRowLevelSecurityCall as _, AddNativeEnumValueCall as a, DropConstraintCall as b, AddUniqueCall as c, CreateIndexCall as d, CreateNativeEnumTypeCall as f, DataTransformCall as g, CreateTableCall as h, AddForeignKeyCall as i, RenameConstraintCall as j, RawSqlCall as k, AlterColumnTypeCall as l, CreateSchemaCall as m, AddColumnCall as n, AddPrimaryKeyCall as o, CreatePostgresRlsPolicyCall as p, schemaBlockingObjects as q, AddColumnWithTemporaryDefaultCall as r, AddRequiredColumnToEmptyTableCall as s, AddCheckConstraintCall as t, CreateExtensionCall as u, DropCheckConstraintCall as v, DropNotNullCall as w, DropDefaultCall as x, DropColumnCall as y, SetTableSchemaCall as z };
|
|
2616
2817
|
|
|
2617
|
-
//# sourceMappingURL=op-factory-call-
|
|
2818
|
+
//# sourceMappingURL=op-factory-call-Dg9wUfmo-OAo-HYAA.mjs.map
|