@prisma/orm-target-mysql 0.0.0-stage → 8.0.0-rc.21-dev.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +20 -2
- package/dist/adapter-_WBomuTw.d.mts +27 -0
- package/dist/adapter-_WBomuTw.d.mts.map +1 -0
- package/dist/adapter.d.mts +6 -0
- package/dist/adapter.mjs +3 -0
- package/dist/adapter__adapter.d.mts +2 -0
- package/dist/adapter__adapter.mjs +2 -0
- package/dist/adapter__codec-types.d.mts +3 -0
- package/dist/adapter__codec-types.mjs +1 -0
- package/dist/adapter__control.d.mts +2 -0
- package/dist/adapter__control.mjs +2 -0
- package/dist/adapter__runtime.d.mts +2 -0
- package/dist/adapter__runtime.mjs +417 -0
- package/dist/adapter__runtime.mjs.map +1 -0
- package/dist/codec-descriptor-DXyubAS6-siA0R8Ow.d.mts +43 -0
- package/dist/codec-descriptor-DXyubAS6-siA0R8Ow.d.mts.map +1 -0
- package/dist/codec-descriptor-Du6DSz-3-ytBCu_mq.mjs +93 -0
- package/dist/codec-descriptor-Du6DSz-3-ytBCu_mq.mjs.map +1 -0
- package/dist/codec-descriptor-J3TP08l8-ekLvUVxW.d.mts +1 -0
- package/dist/codec-descriptor-oLRh9E29.d.mts +2 -0
- package/dist/codec-ids-BHUwoNOM.d.mts +2 -0
- package/dist/codec-ids-C00hAFkc.mjs +2 -0
- package/dist/codec-ids-cjxtOcLM-vFeQhgPm.mjs +10 -0
- package/dist/codec-ids-cjxtOcLM-vFeQhgPm.mjs.map +1 -0
- package/dist/codec-ids-sMOU8F-B-BQbCq2dr.d.mts +10 -0
- package/dist/codec-ids-sMOU8F-B-BQbCq2dr.d.mts.map +1 -0
- package/dist/codec-types-Bd7DL1Mr-CZWNfnp9.d.mts +21 -0
- package/dist/codec-types-Bd7DL1Mr-CZWNfnp9.d.mts.map +1 -0
- package/dist/codec-types-Bo3Jfilx.d.mts +1 -0
- package/dist/codec-types-Ja2kLzLS.d.mts +1 -0
- package/dist/codecs-C00kjHgh.mjs +282 -0
- package/dist/codecs-C00kjHgh.mjs.map +1 -0
- package/dist/codecs-CO_VNEYU-CwAnKzRs.d.mts +102 -0
- package/dist/codecs-CO_VNEYU-CwAnKzRs.d.mts.map +1 -0
- package/dist/codecs-DM61agRr.d.mts +21 -0
- package/dist/codecs-DM61agRr.d.mts.map +1 -0
- package/dist/contract-contributions-B9njRJbt-ClEtrK2L.mjs +14 -0
- package/dist/contract-contributions-B9njRJbt-ClEtrK2L.mjs.map +1 -0
- package/dist/contract-free-BvCdx_Ee.mjs +71 -0
- package/dist/contract-free-BvCdx_Ee.mjs.map +1 -0
- package/dist/contract-free-Cw9Mjcro.d.mts +22 -0
- package/dist/contract-free-Cw9Mjcro.d.mts.map +1 -0
- package/dist/control-C9zxRXNN.mjs +74 -0
- package/dist/control-C9zxRXNN.mjs.map +1 -0
- package/dist/control-DHkZbo58.d.mts +25 -0
- package/dist/control-DHkZbo58.d.mts.map +1 -0
- package/dist/control-Ez_PtlFI.d.mts +121 -0
- package/dist/control-Ez_PtlFI.d.mts.map +1 -0
- package/dist/control-WTY7Jpxk.mjs +577 -0
- package/dist/control-WTY7Jpxk.mjs.map +1 -0
- package/dist/control-_4epnrIW.d.mts +27 -0
- package/dist/control-_4epnrIW.d.mts.map +1 -0
- package/dist/control-tables-CHw2F-rg.d.mts +9 -0
- package/dist/control-tables-CHw2F-rg.d.mts.map +1 -0
- package/dist/control-tables-CcQ77JE7-CxTQYoQJ.mjs +9 -0
- package/dist/control-tables-CcQ77JE7-CxTQYoQJ.mjs.map +1 -0
- package/dist/data-type-entries-B0AoBozh-f9AEUIUQ.mjs +42 -0
- package/dist/data-type-entries-B0AoBozh-f9AEUIUQ.mjs.map +1 -0
- package/dist/data-types-BpihGKoK-BMW-m4EN.d.mts +52 -0
- package/dist/data-types-BpihGKoK-BMW-m4EN.d.mts.map +1 -0
- package/dist/data-types-Dv9gwVRV-BZPzCWZk.mjs +181 -0
- package/dist/data-types-Dv9gwVRV-BZPzCWZk.mjs.map +1 -0
- package/dist/data-types-SXrh0Lou.d.mts +8 -0
- package/dist/data-types-SXrh0Lou.d.mts.map +1 -0
- package/dist/ddl-CT6DPEqg.d.mts +1 -0
- package/dist/ddl-DDmMHyA_-Bb8sXoS0.mjs +12 -0
- package/dist/ddl-DDmMHyA_-Bb8sXoS0.mjs.map +1 -0
- package/dist/default-normalizer-BBhGpw7r.d.mts +27 -0
- package/dist/default-normalizer-BBhGpw7r.d.mts.map +1 -0
- package/dist/default-normalizer-BDUgHXUn-Xk7HQJuI.mjs +90 -0
- package/dist/default-normalizer-BDUgHXUn-Xk7HQJuI.mjs.map +1 -0
- package/dist/descriptor-meta-BurjcSiU-Cbk2L1jf.mjs +82 -0
- package/dist/descriptor-meta-BurjcSiU-Cbk2L1jf.mjs.map +1 -0
- package/dist/descriptor-meta-runtime-Bk_00UrX-BLN4Ahpj.mjs +17 -0
- package/dist/descriptor-meta-runtime-Bk_00UrX-BLN4Ahpj.mjs.map +1 -0
- package/dist/driver.d.mts +3 -0
- package/dist/driver.mjs +2 -0
- package/dist/driver__control.d.mts +2 -0
- package/dist/driver__control.mjs +2 -0
- package/dist/driver__runtime.d.mts +2 -0
- package/dist/driver__runtime.mjs +325 -0
- package/dist/driver__runtime.mjs.map +1 -0
- package/dist/errors-BYhjQT7y.d.mts +10 -0
- package/dist/errors-BYhjQT7y.d.mts.map +1 -0
- package/dist/errors-rvH_F2Yj-BQrO_--u.mjs +20 -0
- package/dist/errors-rvH_F2Yj-BQrO_--u.mjs.map +1 -0
- package/dist/marker-lock-CmGvN4hw-Com29AtQ.mjs +51 -0
- package/dist/marker-lock-CmGvN4hw-Com29AtQ.mjs.map +1 -0
- package/dist/marker-lock-su6IxinO.d.mts +18 -0
- package/dist/marker-lock-su6IxinO.d.mts.map +1 -0
- package/dist/marker-read-aEaHihYj-Cyg16yn1.mjs +78 -0
- package/dist/marker-read-aEaHihYj-Cyg16yn1.mjs.map +1 -0
- package/dist/migration-DmlblTTw.d.mts +284 -0
- package/dist/migration-DmlblTTw.d.mts.map +1 -0
- package/dist/migration-tFuoN9GB.mjs +5 -0
- package/dist/mysql-contract-serializer-DLv0uW_f-Cg4A43Ry.mjs +160 -0
- package/dist/mysql-contract-serializer-DLv0uW_f-Cg4A43Ry.mjs.map +1 -0
- package/dist/nodes-CvcX47ot-B-ZaUYRj.mjs +25 -0
- package/dist/nodes-CvcX47ot-B-ZaUYRj.mjs.map +1 -0
- package/dist/nodes-xc0cR0_c-2YbhgEjb.d.mts +27 -0
- package/dist/nodes-xc0cR0_c-2YbhgEjb.d.mts.map +1 -0
- package/dist/pack-YVG-iBMQ.d.mts +1073 -0
- package/dist/pack-YVG-iBMQ.d.mts.map +1 -0
- package/dist/planner-target-details-D6g2uSp--C5NKHmCc.d.mts +12 -0
- package/dist/planner-target-details-D6g2uSp--C5NKHmCc.d.mts.map +1 -0
- package/dist/runner-C4r6yEd1-BWQrxW9q.mjs +1644 -0
- package/dist/runner-C4r6yEd1-BWQrxW9q.mjs.map +1 -0
- package/dist/runtime-BGyTXcQH.d.mts +36 -0
- package/dist/runtime-BGyTXcQH.d.mts.map +1 -0
- package/dist/runtime-CeuRr9nE.d.mts +29 -0
- package/dist/runtime-CeuRr9nE.d.mts.map +1 -0
- package/dist/runtime-Cl0BbTZq.d.mts +22 -0
- package/dist/runtime-Cl0BbTZq.d.mts.map +1 -0
- package/dist/sql-utils-BOS1c2QT.d.mts +30 -0
- package/dist/sql-utils-BOS1c2QT.d.mts.map +1 -0
- package/dist/sql-utils-Db0IQO_B-PaULnfrE.mjs +30 -0
- package/dist/sql-utils-Db0IQO_B-PaULnfrE.mjs.map +1 -0
- package/dist/sql-utils-RW0vJvDl.mjs +94 -0
- package/dist/sql-utils-RW0vJvDl.mjs.map +1 -0
- package/dist/statement-A6bbPBf1-q61iHQLb.mjs +483 -0
- package/dist/statement-A6bbPBf1-q61iHQLb.mjs.map +1 -0
- package/dist/target.d.mts +24 -0
- package/dist/target.mjs +19 -0
- package/dist/target__codec-descriptor.d.mts +3 -0
- package/dist/target__codec-descriptor.mjs +2 -0
- package/dist/target__codec-ids.d.mts +3 -0
- package/dist/target__codec-ids.mjs +3 -0
- package/dist/target__codec-types.d.mts +3 -0
- package/dist/target__codec-types.mjs +1 -0
- package/dist/target__codecs.d.mts +3 -0
- package/dist/target__codecs.mjs +2 -0
- package/dist/target__contract-free.d.mts +2 -0
- package/dist/target__contract-free.mjs +3 -0
- package/dist/target__control-tables.d.mts +2 -0
- package/dist/target__control-tables.mjs +2 -0
- package/dist/target__control.d.mts +3 -0
- package/dist/target__control.mjs +58 -0
- package/dist/target__control.mjs.map +1 -0
- package/dist/target__data-types.d.mts +3 -0
- package/dist/target__data-types.mjs +3 -0
- package/dist/target__ddl.d.mts +3 -0
- package/dist/target__ddl.mjs +2 -0
- package/dist/target__default-normalizer.d.mts +2 -0
- package/dist/target__default-normalizer.mjs +2 -0
- package/dist/target__errors.d.mts +2 -0
- package/dist/target__errors.mjs +2 -0
- package/dist/target__marker-lock.d.mts +2 -0
- package/dist/target__marker-lock.mjs +2 -0
- package/dist/target__migration.d.mts +2 -0
- package/dist/target__migration.mjs +3 -0
- package/dist/target__pack.d.mts +2 -0
- package/dist/target__pack.mjs +2 -0
- package/dist/target__runtime.d.mts +2 -0
- package/dist/target__runtime.mjs +17 -0
- package/dist/target__runtime.mjs.map +1 -0
- package/dist/target__sql-utils.d.mts +2 -0
- package/dist/target__sql-utils.mjs +3 -0
- package/package.json +71 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-rvH_F2Yj-BQrO_--u.mjs","names":[],"sources":["../../../../3-targets/mysql/1-target/dist/errors-rvH_F2Yj.mjs"],"sourcesContent":["import { structuredError } from \"@internal/utils/structured-error\";\n//#region src/core/errors.ts\nfunction mysqlError(code, message, options) {\n\treturn structuredError(code, message, options);\n}\n/** The refusal of a query a later slice of the MySQL target can render: `what` names the feature, as in `Lowering queries`. */\nfunction mysqlQueryNotYetSupported(what) {\n\treturn mysqlError(\"RUNTIME.AST_UNSUPPORTED\", `${what} is not yet supported on MySQL.`, {\n\t\twhy: \"The MySQL target renders reads; writes and some query forms are not built yet.\",\n\t\tfix: \"Use a Postgres or SQLite target for this query until the MySQL target supports it.\",\n\t\tmeta: {\n\t\t\ttarget: \"mysql\",\n\t\t\tfeature: what\n\t\t}\n\t});\n}\n//#endregion\nexport { mysqlQueryNotYetSupported as n, mysqlError as t };\n\n//# sourceMappingURL=errors-rvH_F2Yj.mjs.map"],"mappings":";;AAEA,SAAS,WAAW,MAAM,SAAS,SAAS;CAC3C,OAAO,gBAAgB,MAAM,SAAS,OAAO;AAC9C;;AAEA,SAAS,0BAA0B,MAAM;CACxC,OAAO,WAAW,2BAA2B,GAAG,KAAK,kCAAkC;EACtF,KAAK;EACL,KAAK;EACL,MAAM;GACL,QAAQ;GACR,SAAS;EACV;CACD,CAAC;AACF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { t as mysqlError } from "./errors-rvH_F2Yj-BQrO_--u.mjs";
|
|
2
|
+
//#region ../../../3-targets/mysql/1-target/dist/marker-lock-CmGvN4hw.mjs
|
|
3
|
+
/** How long a migration runner or `db sign` waits for another one to release the marker lock. */
|
|
4
|
+
const MARKER_LOCK_TIMEOUT_SECONDS = 60;
|
|
5
|
+
/** `GET_LOCK` names are global to the server, so the name carries a hash of the connection's database: two databases on one server never wait on each other. */
|
|
6
|
+
const LOCK_NAME = "CONCAT('prisma_marker_', LEFT(SHA2(DATABASE(), 256), 50))";
|
|
7
|
+
function lockResult(rows) {
|
|
8
|
+
const value = rows[0]?.["acquired"];
|
|
9
|
+
return value === null || value === void 0 ? void 0 : String(value);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Takes the marker lock on the connection `driver` holds. MySQL holds a `GET_LOCK` lock for the session, not for a transaction, so the caller releases it with {@link releaseMarkerLock} on the same connection when the work it guards ends.
|
|
13
|
+
*/
|
|
14
|
+
async function acquireMarkerLock(driver, timeoutSeconds = 60) {
|
|
15
|
+
const { rows } = await driver.query(`SELECT GET_LOCK(${LOCK_NAME}, ?) AS acquired`, [timeoutSeconds]);
|
|
16
|
+
if (lockResult(rows) !== "1") throw mysqlError("MIGRATION.MARKER_LOCK_TIMEOUT", `Another process held the migration marker lock for ${timeoutSeconds} seconds.`, {
|
|
17
|
+
why: "A migration or db sign on this database is still running, and they write the contract markers one at a time.",
|
|
18
|
+
fix: "Wait for the other process to finish, then run the command again.",
|
|
19
|
+
meta: { timeoutSeconds }
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/** Releases the marker lock {@link acquireMarkerLock} took on this connection. */
|
|
23
|
+
async function releaseMarkerLock(driver) {
|
|
24
|
+
await driver.query(`SELECT RELEASE_LOCK(${LOCK_NAME}) AS released`);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Releases the marker lock after work that failed, keeping that failure: a release that fails too is dropped. MySQL frees a session's locks when the session ends, which is the usual reason a release fails.
|
|
28
|
+
*/
|
|
29
|
+
async function releaseMarkerLockAfterFailure(driver) {
|
|
30
|
+
await releaseMarkerLock(driver).catch(() => void 0);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The one way MySQL holds the marker lock: takes it on the connection `driver` holds, runs `work`, and releases it on the same connection when `work` ends. A failed release is reported only when `work` succeeded; when `work` throws, or `succeeded` says its result is a failure, that outcome is what comes back.
|
|
34
|
+
*/
|
|
35
|
+
async function withMarkerLock(driver, work, succeeded = () => true) {
|
|
36
|
+
await acquireMarkerLock(driver);
|
|
37
|
+
let result;
|
|
38
|
+
try {
|
|
39
|
+
result = await work();
|
|
40
|
+
} catch (error) {
|
|
41
|
+
await releaseMarkerLockAfterFailure(driver);
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
if (succeeded(result)) await releaseMarkerLock(driver);
|
|
45
|
+
else await releaseMarkerLockAfterFailure(driver);
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { withMarkerLock as i, acquireMarkerLock as n, releaseMarkerLock as r, MARKER_LOCK_TIMEOUT_SECONDS as t };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=marker-lock-CmGvN4hw-Com29AtQ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marker-lock-CmGvN4hw-Com29AtQ.mjs","names":[],"sources":["../../../../3-targets/mysql/1-target/dist/marker-lock-CmGvN4hw.mjs"],"sourcesContent":["import { t as mysqlError } from \"./errors-rvH_F2Yj.mjs\";\n//#region src/core/marker-lock.ts\n/** How long a migration runner or `db sign` waits for another one to release the marker lock. */\nconst MARKER_LOCK_TIMEOUT_SECONDS = 60;\n/** `GET_LOCK` names are global to the server, so the name carries a hash of the connection's database: two databases on one server never wait on each other. */\nconst LOCK_NAME = \"CONCAT('prisma_marker_', LEFT(SHA2(DATABASE(), 256), 50))\";\nfunction lockResult(rows) {\n\tconst value = rows[0]?.[\"acquired\"];\n\treturn value === null || value === void 0 ? void 0 : String(value);\n}\n/**\n* Takes the marker lock on the connection `driver` holds. MySQL holds a `GET_LOCK` lock for the session, not for a transaction, so the caller releases it with {@link releaseMarkerLock} on the same connection when the work it guards ends.\n*/\nasync function acquireMarkerLock(driver, timeoutSeconds = 60) {\n\tconst { rows } = await driver.query(`SELECT GET_LOCK(${LOCK_NAME}, ?) AS acquired`, [timeoutSeconds]);\n\tif (lockResult(rows) !== \"1\") throw mysqlError(\"MIGRATION.MARKER_LOCK_TIMEOUT\", `Another process held the migration marker lock for ${timeoutSeconds} seconds.`, {\n\t\twhy: \"A migration or db sign on this database is still running, and they write the contract markers one at a time.\",\n\t\tfix: \"Wait for the other process to finish, then run the command again.\",\n\t\tmeta: { timeoutSeconds }\n\t});\n}\n/** Releases the marker lock {@link acquireMarkerLock} took on this connection. */\nasync function releaseMarkerLock(driver) {\n\tawait driver.query(`SELECT RELEASE_LOCK(${LOCK_NAME}) AS released`);\n}\n/**\n* Releases the marker lock after work that failed, keeping that failure: a release that fails too is dropped. MySQL frees a session's locks when the session ends, which is the usual reason a release fails.\n*/\nasync function releaseMarkerLockAfterFailure(driver) {\n\tawait releaseMarkerLock(driver).catch(() => void 0);\n}\n/**\n* The one way MySQL holds the marker lock: takes it on the connection `driver` holds, runs `work`, and releases it on the same connection when `work` ends. A failed release is reported only when `work` succeeded; when `work` throws, or `succeeded` says its result is a failure, that outcome is what comes back.\n*/\nasync function withMarkerLock(driver, work, succeeded = () => true) {\n\tawait acquireMarkerLock(driver);\n\tlet result;\n\ttry {\n\t\tresult = await work();\n\t} catch (error) {\n\t\tawait releaseMarkerLockAfterFailure(driver);\n\t\tthrow error;\n\t}\n\tif (succeeded(result)) await releaseMarkerLock(driver);\n\telse await releaseMarkerLockAfterFailure(driver);\n\treturn result;\n}\n//#endregion\nexport { withMarkerLock as i, acquireMarkerLock as n, releaseMarkerLock as r, MARKER_LOCK_TIMEOUT_SECONDS as t };\n\n//# sourceMappingURL=marker-lock-CmGvN4hw.mjs.map"],"mappings":";;;AAGA,MAAM,8BAA8B;;AAEpC,MAAM,YAAY;AAClB,SAAS,WAAW,MAAM;CACzB,MAAM,QAAQ,KAAK,EAAE,GAAG;CACxB,OAAO,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,OAAO,KAAK;AAClE;;;;AAIA,eAAe,kBAAkB,QAAQ,iBAAiB,IAAI;CAC7D,MAAM,EAAE,SAAS,MAAM,OAAO,MAAM,mBAAmB,UAAU,mBAAmB,CAAC,cAAc,CAAC;CACpG,IAAI,WAAW,IAAI,MAAM,KAAK,MAAM,WAAW,iCAAiC,sDAAsD,eAAe,YAAY;EAChK,KAAK;EACL,KAAK;EACL,MAAM,EAAE,eAAe;CACxB,CAAC;AACF;;AAEA,eAAe,kBAAkB,QAAQ;CACxC,MAAM,OAAO,MAAM,uBAAuB,UAAU,cAAc;AACnE;;;;AAIA,eAAe,8BAA8B,QAAQ;CACpD,MAAM,kBAAkB,MAAM,CAAC,CAAC,YAAY,KAAK,CAAC;AACnD;;;;AAIA,eAAe,eAAe,QAAQ,MAAM,kBAAkB,MAAM;CACnE,MAAM,kBAAkB,MAAM;CAC9B,IAAI;CACJ,IAAI;EACH,SAAS,MAAM,KAAK;CACrB,SAAS,OAAO;EACf,MAAM,8BAA8B,MAAM;EAC1C,MAAM;CACP;CACA,IAAI,UAAU,MAAM,GAAG,MAAM,kBAAkB,MAAM;MAChD,MAAM,8BAA8B,MAAM;CAC/C,OAAO;AACR"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SqlControlDriverInstance } from "@prisma/orm-family-sql/contract/types";
|
|
2
|
+
//#region ../../../3-targets/mysql/1-target/dist/marker-lock.d.mts
|
|
3
|
+
//#region src/core/marker-lock.d.ts
|
|
4
|
+
/** How long a migration runner or `db sign` waits for another one to release the marker lock. */
|
|
5
|
+
declare const MARKER_LOCK_TIMEOUT_SECONDS = 60;
|
|
6
|
+
/**
|
|
7
|
+
* Takes the marker lock on the connection `driver` holds. MySQL holds a `GET_LOCK` lock for the session, not for a transaction, so the caller releases it with {@link releaseMarkerLock} on the same connection when the work it guards ends.
|
|
8
|
+
*/
|
|
9
|
+
declare function acquireMarkerLock(driver: SqlControlDriverInstance<string>, timeoutSeconds?: number): Promise<void>;
|
|
10
|
+
/** Releases the marker lock {@link acquireMarkerLock} took on this connection. */
|
|
11
|
+
declare function releaseMarkerLock(driver: SqlControlDriverInstance<string>): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* The one way MySQL holds the marker lock: takes it on the connection `driver` holds, runs `work`, and releases it on the same connection when `work` ends. A failed release is reported only when `work` succeeded; when `work` throws, or `succeeded` says its result is a failure, that outcome is what comes back.
|
|
14
|
+
*/
|
|
15
|
+
declare function withMarkerLock<T>(driver: SqlControlDriverInstance<string>, work: () => Promise<T>, succeeded?: (result: T) => boolean): Promise<T>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { withMarkerLock as i, acquireMarkerLock as n, releaseMarkerLock as r, MARKER_LOCK_TIMEOUT_SECONDS as t };
|
|
18
|
+
//# sourceMappingURL=marker-lock-su6IxinO.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marker-lock-su6IxinO.d.mts","names":[],"sources":["../../../../3-targets/mysql/1-target/dist/marker-lock.d.mts"],"mappings":";;;;cAGc;;;;iBAIG,kBAAkB,QAAQ,kCAAkC,0BAA0B;;iBAEtF,kBAAkB,QAAQ,mCAAmC;;;;iBAI7D,eAAe,GAAG,QAAQ,kCAAkC,YAAY,QAAQ,IAAI,aAAa,QAAQ,gBAAgB,QAAQ"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { n as quoteIdentifier } from "./sql-utils-Db0IQO_B-PaULnfrE.mjs";
|
|
2
|
+
import { o as mysqlCodecRegistry, r as decodeMysqlDatetime } from "./codecs-C00kjHgh.mjs";
|
|
3
|
+
import { r as MARKER_TABLE_NAME } from "./control-tables-CcQ77JE7-CxTQYoQJ.mjs";
|
|
4
|
+
import { n as mysqlAdapterContractContributions } from "./contract-contributions-B9njRJbt-ClEtrK2L.mjs";
|
|
5
|
+
import { structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
6
|
+
import { withMarkerReadErrorHandling } from "@prisma/orm-framework/errors/execution";
|
|
7
|
+
import { parseContractMarkerRow } from "@prisma/orm-family-sql/family/verify";
|
|
8
|
+
//#region ../../../3-targets/mysql/2-adapter/dist/marker-read-aEaHihYj.mjs
|
|
9
|
+
const mysqlAdapterDescriptorMeta = {
|
|
10
|
+
kind: "adapter",
|
|
11
|
+
familyId: "sql",
|
|
12
|
+
targetId: "mysql",
|
|
13
|
+
id: "mysql",
|
|
14
|
+
version: "0.0.1",
|
|
15
|
+
capabilities: mysqlAdapterContractContributions.capabilities,
|
|
16
|
+
types: { codecTypes: {
|
|
17
|
+
codecDescriptors: Array.from(mysqlCodecRegistry.values()),
|
|
18
|
+
import: {
|
|
19
|
+
package: "@internal/adapter-mysql/codec-types",
|
|
20
|
+
named: "CodecTypes",
|
|
21
|
+
alias: "MysqlTypes"
|
|
22
|
+
}
|
|
23
|
+
} }
|
|
24
|
+
};
|
|
25
|
+
const MARKER_COLUMNS = "space, core_hash, profile_hash, contract_json, canonical_version, updated_at, app_tag, meta, invariants";
|
|
26
|
+
/** Whether the connection's database has the table `name`. */
|
|
27
|
+
async function tableExists(driver, name) {
|
|
28
|
+
const { rows } = await driver.query("SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ?", [name]);
|
|
29
|
+
return rows.length > 0;
|
|
30
|
+
}
|
|
31
|
+
function parseJsonColumn(column, text) {
|
|
32
|
+
if (typeof text !== "string") return text;
|
|
33
|
+
try {
|
|
34
|
+
return JSON.parse(text);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
37
|
+
throw structuredError("CONTRACT.MARKER_ROW_CORRUPT", `Invalid contract marker row: ${column} is not valid JSON: ${detail}`, {
|
|
38
|
+
meta: { detail },
|
|
39
|
+
cause: error
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** A marker row as MySQL's text arrives, in the shape the family's marker parser reads. */
|
|
44
|
+
function decodeMysqlMarkerRow(row) {
|
|
45
|
+
const canonicalVersion = row["canonical_version"];
|
|
46
|
+
const updatedAt = row["updated_at"];
|
|
47
|
+
return parseContractMarkerRow({
|
|
48
|
+
...row,
|
|
49
|
+
canonical_version: typeof canonicalVersion === "string" ? Number(canonicalVersion) : canonicalVersion,
|
|
50
|
+
updated_at: typeof updatedAt === "string" ? decodeMysqlDatetime(updatedAt) : updatedAt,
|
|
51
|
+
invariants: parseJsonColumn("invariants", row["invariants"])
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
async function readMarkerRows(driver, space) {
|
|
55
|
+
if (!await tableExists(driver, "_prisma_marker")) return void 0;
|
|
56
|
+
const select = `SELECT ${MARKER_COLUMNS} FROM ${quoteIdentifier(MARKER_TABLE_NAME)}`;
|
|
57
|
+
const { rows } = space === void 0 ? await driver.query(select) : await driver.query(`${select} WHERE space = ?`, [space]);
|
|
58
|
+
return rows;
|
|
59
|
+
}
|
|
60
|
+
/** The marker of `space`, or whether the marker table or the space's row is missing. */
|
|
61
|
+
async function readMarkerResult(driver, space) {
|
|
62
|
+
return withMarkerReadErrorHandling(async () => {
|
|
63
|
+
const rows = await readMarkerRows(driver, space);
|
|
64
|
+
if (rows === void 0) return { kind: "no-table" };
|
|
65
|
+
const [row] = rows;
|
|
66
|
+
return row === void 0 ? { kind: "absent" } : {
|
|
67
|
+
kind: "present",
|
|
68
|
+
record: decodeMysqlMarkerRow(row)
|
|
69
|
+
};
|
|
70
|
+
}, {
|
|
71
|
+
space,
|
|
72
|
+
markerLocation: MARKER_TABLE_NAME
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
export { readMarkerRows as a, readMarkerResult as i, mysqlAdapterDescriptorMeta as n, tableExists as o, parseJsonColumn as r, decodeMysqlMarkerRow as t };
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=marker-read-aEaHihYj-Cyg16yn1.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marker-read-aEaHihYj-Cyg16yn1.mjs","names":[],"sources":["../../../../3-targets/mysql/2-adapter/dist/marker-read-aEaHihYj.mjs"],"sourcesContent":["import { t as mysqlAdapterContractContributions } from \"./contract-contributions-B9njRJbt.mjs\";\nimport { decodeMysqlDatetime, mysqlCodecRegistry } from \"@internal/target-mysql/codecs\";\nimport { withMarkerReadErrorHandling } from \"@internal/errors/execution\";\nimport { MARKER_TABLE_NAME } from \"@internal/target-mysql/control-tables\";\nimport { structuredError } from \"@internal/utils/structured-error\";\nimport { parseContractMarkerRow } from \"@internal/family-sql/verify\";\nimport { quoteIdentifier } from \"@internal/target-mysql/sql-utils\";\n//#region src/core/descriptor-meta.ts\nconst mysqlAdapterDescriptorMeta = {\n\tkind: \"adapter\",\n\tfamilyId: \"sql\",\n\ttargetId: \"mysql\",\n\tid: \"mysql\",\n\tversion: \"0.0.1\",\n\tcapabilities: mysqlAdapterContractContributions.capabilities,\n\ttypes: { codecTypes: {\n\t\tcodecDescriptors: Array.from(mysqlCodecRegistry.values()),\n\t\timport: {\n\t\t\tpackage: \"@internal/adapter-mysql/codec-types\",\n\t\t\tnamed: \"CodecTypes\",\n\t\t\talias: \"MysqlTypes\"\n\t\t}\n\t} }\n};\n//#endregion\n//#region src/core/marker-read.ts\nconst MARKER_COLUMNS = \"space, core_hash, profile_hash, contract_json, canonical_version, updated_at, app_tag, meta, invariants\";\n/** Whether the connection's database has the table `name`. */\nasync function tableExists(driver, name) {\n\tconst { rows } = await driver.query(\"SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ?\", [name]);\n\treturn rows.length > 0;\n}\nfunction parseJsonColumn(column, text) {\n\tif (typeof text !== \"string\") return text;\n\ttry {\n\t\treturn JSON.parse(text);\n\t} catch (error) {\n\t\tconst detail = error instanceof Error ? error.message : String(error);\n\t\tthrow structuredError(\"CONTRACT.MARKER_ROW_CORRUPT\", `Invalid contract marker row: ${column} is not valid JSON: ${detail}`, {\n\t\t\tmeta: { detail },\n\t\t\tcause: error\n\t\t});\n\t}\n}\n/** A marker row as MySQL's text arrives, in the shape the family's marker parser reads. */\nfunction decodeMysqlMarkerRow(row) {\n\tconst canonicalVersion = row[\"canonical_version\"];\n\tconst updatedAt = row[\"updated_at\"];\n\treturn parseContractMarkerRow({\n\t\t...row,\n\t\tcanonical_version: typeof canonicalVersion === \"string\" ? Number(canonicalVersion) : canonicalVersion,\n\t\tupdated_at: typeof updatedAt === \"string\" ? decodeMysqlDatetime(updatedAt) : updatedAt,\n\t\tinvariants: parseJsonColumn(\"invariants\", row[\"invariants\"])\n\t});\n}\nasync function readMarkerRows(driver, space) {\n\tif (!await tableExists(driver, MARKER_TABLE_NAME)) return void 0;\n\tconst select = `SELECT ${MARKER_COLUMNS} FROM ${quoteIdentifier(MARKER_TABLE_NAME)}`;\n\tconst { rows } = space === void 0 ? await driver.query(select) : await driver.query(`${select} WHERE space = ?`, [space]);\n\treturn rows;\n}\n/** The marker of `space`, or whether the marker table or the space's row is missing. */\nasync function readMarkerResult(driver, space) {\n\treturn withMarkerReadErrorHandling(async () => {\n\t\tconst rows = await readMarkerRows(driver, space);\n\t\tif (rows === void 0) return { kind: \"no-table\" };\n\t\tconst [row] = rows;\n\t\treturn row === void 0 ? { kind: \"absent\" } : {\n\t\t\tkind: \"present\",\n\t\t\trecord: decodeMysqlMarkerRow(row)\n\t\t};\n\t}, {\n\t\tspace,\n\t\tmarkerLocation: MARKER_TABLE_NAME\n\t});\n}\n//#endregion\nexport { tableExists as a, readMarkerRows as i, parseJsonColumn as n, mysqlAdapterDescriptorMeta as o, readMarkerResult as r, decodeMysqlMarkerRow as t };\n\n//# sourceMappingURL=marker-read-aEaHihYj.mjs.map"],"mappings":";;;;;;;;AAQA,MAAM,6BAA6B;CAClC,MAAM;CACN,UAAU;CACV,UAAU;CACV,IAAI;CACJ,SAAS;CACT,cAAc,kCAAkC;CAChD,OAAO,EAAE,YAAY;EACpB,kBAAkB,MAAM,KAAK,mBAAmB,OAAO,CAAC;EACxD,QAAQ;GACP,SAAS;GACT,OAAO;GACP,OAAO;EACR;CACD,EAAE;AACH;AAGA,MAAM,iBAAiB;;AAEvB,eAAe,YAAY,QAAQ,MAAM;CACxC,MAAM,EAAE,SAAS,MAAM,OAAO,MAAM,uGAAuG,CAAC,IAAI,CAAC;CACjJ,OAAO,KAAK,SAAS;AACtB;AACA,SAAS,gBAAgB,QAAQ,MAAM;CACtC,IAAI,OAAO,SAAS,UAAU,OAAO;CACrC,IAAI;EACH,OAAO,KAAK,MAAM,IAAI;CACvB,SAAS,OAAO;EACf,MAAM,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EACpE,MAAM,gBAAgB,+BAA+B,gCAAgC,OAAO,sBAAsB,UAAU;GAC3H,MAAM,EAAE,OAAO;GACf,OAAO;EACR,CAAC;CACF;AACD;;AAEA,SAAS,qBAAqB,KAAK;CAClC,MAAM,mBAAmB,IAAI;CAC7B,MAAM,YAAY,IAAI;CACtB,OAAO,uBAAuB;EAC7B,GAAG;EACH,mBAAmB,OAAO,qBAAqB,WAAW,OAAO,gBAAgB,IAAI;EACrF,YAAY,OAAO,cAAc,WAAW,oBAAoB,SAAS,IAAI;EAC7E,YAAY,gBAAgB,cAAc,IAAI,aAAa;CAC5D,CAAC;AACF;AACA,eAAe,eAAe,QAAQ,OAAO;CAC5C,IAAI,CAAC,MAAM,YAAY,QAAA,gBAAyB,GAAG,OAAO,KAAK;CAC/D,MAAM,SAAS,UAAU,eAAe,QAAQ,gBAAgB,iBAAiB;CACjF,MAAM,EAAE,SAAS,UAAU,KAAK,IAAI,MAAM,OAAO,MAAM,MAAM,IAAI,MAAM,OAAO,MAAM,GAAG,OAAO,mBAAmB,CAAC,KAAK,CAAC;CACxH,OAAO;AACR;;AAEA,eAAe,iBAAiB,QAAQ,OAAO;CAC9C,OAAO,4BAA4B,YAAY;EAC9C,MAAM,OAAO,MAAM,eAAe,QAAQ,KAAK;EAC/C,IAAI,SAAS,KAAK,GAAG,OAAO,EAAE,MAAM,WAAW;EAC/C,MAAM,CAAC,OAAO;EACd,OAAO,QAAQ,KAAK,IAAI,EAAE,MAAM,SAAS,IAAI;GAC5C,MAAM;GACN,QAAQ,qBAAqB,GAAG;EACjC;CACD,GAAG;EACF;EACA,gBAAgB;CACjB,CAAC;AACF"}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { t as MysqlPlanTargetDetails } from "./planner-target-details-D6g2uSp--C5NKHmCc.mjs";
|
|
2
|
+
import { DdlColumn, DdlTableConstraint } from "@prisma/orm-family-sql/relational-core/ast";
|
|
3
|
+
import { ControlStack, MigrationAccessChange, MigrationDataLoss, MigrationPlanWithAuthoringSurface, MigrationPlanner, MigrationScaffoldContext, MigrationTemporaryValue, OpFactoryCall, PlanOrigin, ResolvedMigrationStatement, SchemaOwnership } from "@prisma/orm-framework/components/control";
|
|
4
|
+
import { col as col$1, fn as fn$1, lit as lit$1, primaryKey, unique } from "@prisma/orm-family-sql/relational-core/contract-free";
|
|
5
|
+
import { TargetBoundComponentDescriptor } from "@prisma/orm-framework/components/components";
|
|
6
|
+
import { ReferentialAction, SqlStorage } from "@prisma/orm-family-sql/contract/types";
|
|
7
|
+
import { MigrationOperationClass, MigrationOperationPolicy, SqlControlFamilyInstance, SqlMigrationPlanOperation, SqlMigrationPlanner, SqlMigrationRunner, SqlPlannerFailureResult } from "@prisma/orm-family-sql/family/control";
|
|
8
|
+
import { ImportRequirement, TsExpression } from "@prisma/orm-framework/ts-render";
|
|
9
|
+
import { Migration } from "@prisma/orm-family-sql/family/migration";
|
|
10
|
+
import { ImportSpecifierResolver } from "@prisma/orm-framework/components/emission";
|
|
11
|
+
import { MigrationCLI } from "@prisma/orm-toolchain/cli/migration-cli";
|
|
12
|
+
import { placeholder } from "@prisma/orm-framework/errors/migration";
|
|
13
|
+
import { sql } from "@prisma/orm-family-sql/contract/sql-expression";
|
|
14
|
+
import { ExecuteRequestLowerer, SqlControlAdapter } from "@prisma/orm-family-sql/family/control-adapter";
|
|
15
|
+
import { Contract } from "@prisma/orm-framework/contract/types";
|
|
16
|
+
import { MigrationMeta } from "@prisma/orm-toolchain/migration-tools/migration";
|
|
17
|
+
//#region ../../../3-targets/mysql/1-target/dist/migration.d.mts
|
|
18
|
+
//#region src/core/migrations/operations.d.ts
|
|
19
|
+
type Op = SqlMigrationPlanOperation<MysqlPlanTargetDetails>;
|
|
20
|
+
/** An operation written out in full in `migration.ts`, such as a table rename made by hand. */
|
|
21
|
+
declare function rawSql(op: Op): Op;
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/core/migrations/mysql-migration.d.ts
|
|
24
|
+
/**
|
|
25
|
+
* The base class of a MySQL `migration.ts`. Each protected method returns the operation its name says, rendered through the MySQL control adapter the migration CLI builds from `prisma.config.ts`.
|
|
26
|
+
*/
|
|
27
|
+
declare abstract class MysqlMigration<Start extends Contract<SqlStorage> = Contract<SqlStorage>, End extends Contract<SqlStorage> = Contract<SqlStorage>> extends Migration<MysqlPlanTargetDetails, 'mysql', Start, End> {
|
|
28
|
+
readonly targetId: "mysql";
|
|
29
|
+
protected readonly controlAdapter: SqlControlAdapter<'mysql'> | undefined;
|
|
30
|
+
constructor(stack?: ControlStack<'sql', 'mysql'>);
|
|
31
|
+
private adapterFor;
|
|
32
|
+
protected createTable(options: {
|
|
33
|
+
readonly table: string;
|
|
34
|
+
readonly columns: readonly DdlColumn[];
|
|
35
|
+
readonly constraints?: readonly DdlTableConstraint[];
|
|
36
|
+
}): Promise<Op>;
|
|
37
|
+
protected dropTable(options: {
|
|
38
|
+
readonly table: string;
|
|
39
|
+
}): Op;
|
|
40
|
+
protected addColumn(options: {
|
|
41
|
+
readonly table: string;
|
|
42
|
+
readonly column: DdlColumn;
|
|
43
|
+
}): Promise<Op>;
|
|
44
|
+
protected dropColumn(options: {
|
|
45
|
+
readonly table: string;
|
|
46
|
+
readonly column: string;
|
|
47
|
+
}): Op;
|
|
48
|
+
protected createIndex(options: {
|
|
49
|
+
readonly table: string;
|
|
50
|
+
readonly index: string;
|
|
51
|
+
readonly columns: readonly string[];
|
|
52
|
+
readonly unique?: boolean;
|
|
53
|
+
}): Op;
|
|
54
|
+
protected dropIndex(options: {
|
|
55
|
+
readonly table: string;
|
|
56
|
+
readonly index: string;
|
|
57
|
+
}): Op;
|
|
58
|
+
protected addUnique(options: {
|
|
59
|
+
readonly table: string;
|
|
60
|
+
readonly name: string;
|
|
61
|
+
readonly columns: readonly string[];
|
|
62
|
+
}): Op;
|
|
63
|
+
protected dropUnique(options: {
|
|
64
|
+
readonly table: string;
|
|
65
|
+
readonly name: string;
|
|
66
|
+
}): Op;
|
|
67
|
+
protected addForeignKey(options: {
|
|
68
|
+
readonly table: string;
|
|
69
|
+
readonly name: string;
|
|
70
|
+
readonly columns: readonly string[];
|
|
71
|
+
readonly references: {
|
|
72
|
+
readonly table: string;
|
|
73
|
+
readonly columns: readonly string[];
|
|
74
|
+
};
|
|
75
|
+
readonly onDelete?: ReferentialAction;
|
|
76
|
+
readonly onUpdate?: ReferentialAction;
|
|
77
|
+
}): Op;
|
|
78
|
+
protected dropForeignKey(options: {
|
|
79
|
+
readonly table: string;
|
|
80
|
+
readonly name: string;
|
|
81
|
+
}): Op;
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/core/migrations/op-factory-call.d.ts
|
|
85
|
+
declare abstract class MysqlOpFactoryCallNode extends TsExpression implements OpFactoryCall {
|
|
86
|
+
abstract readonly factoryName: string;
|
|
87
|
+
abstract readonly operationClass: MigrationOperationClass;
|
|
88
|
+
abstract readonly label: string;
|
|
89
|
+
abstract toOp(lowerer?: ExecuteRequestLowerer): Op | Promise<Op>;
|
|
90
|
+
importRequirements(): readonly ImportRequirement[];
|
|
91
|
+
protected freeze(): void;
|
|
92
|
+
protected lowererFor(lowerer: ExecuteRequestLowerer | undefined): ExecuteRequestLowerer;
|
|
93
|
+
}
|
|
94
|
+
declare class CreateTableCall extends MysqlOpFactoryCallNode {
|
|
95
|
+
#private;
|
|
96
|
+
readonly tableName: string;
|
|
97
|
+
readonly factoryName: "createTable";
|
|
98
|
+
readonly operationClass: "additive";
|
|
99
|
+
readonly label: string;
|
|
100
|
+
readonly columns: readonly DdlColumn[];
|
|
101
|
+
readonly constraints: readonly DdlTableConstraint[];
|
|
102
|
+
constructor(tableName: string, columns: readonly DdlColumn[], constraints: readonly DdlTableConstraint[]);
|
|
103
|
+
toOp(lowerer?: ExecuteRequestLowerer): Promise<Op>;
|
|
104
|
+
renderTypeScript(): string;
|
|
105
|
+
importRequirements(): readonly ImportRequirement[];
|
|
106
|
+
}
|
|
107
|
+
declare class DropTableCall extends MysqlOpFactoryCallNode {
|
|
108
|
+
readonly tableName: string;
|
|
109
|
+
readonly factoryName: "dropTable";
|
|
110
|
+
readonly operationClass: "destructive";
|
|
111
|
+
readonly label: string;
|
|
112
|
+
constructor(tableName: string);
|
|
113
|
+
toOp(): Op;
|
|
114
|
+
renderTypeScript(): string;
|
|
115
|
+
}
|
|
116
|
+
declare class AddColumnCall extends MysqlOpFactoryCallNode {
|
|
117
|
+
#private;
|
|
118
|
+
readonly tableName: string;
|
|
119
|
+
readonly column: DdlColumn;
|
|
120
|
+
readonly factoryName: "addColumn";
|
|
121
|
+
readonly operationClass: "additive";
|
|
122
|
+
readonly label: string;
|
|
123
|
+
readonly columnName: string;
|
|
124
|
+
constructor(tableName: string, column: DdlColumn);
|
|
125
|
+
toOp(lowerer?: ExecuteRequestLowerer): Promise<Op>;
|
|
126
|
+
renderTypeScript(): string;
|
|
127
|
+
importRequirements(): readonly ImportRequirement[];
|
|
128
|
+
}
|
|
129
|
+
declare class DropColumnCall extends MysqlOpFactoryCallNode {
|
|
130
|
+
readonly tableName: string;
|
|
131
|
+
readonly columnName: string;
|
|
132
|
+
readonly factoryName: "dropColumn";
|
|
133
|
+
readonly operationClass: "destructive";
|
|
134
|
+
readonly label: string;
|
|
135
|
+
constructor(tableName: string, columnName: string);
|
|
136
|
+
toOp(): Op;
|
|
137
|
+
renderTypeScript(): string;
|
|
138
|
+
}
|
|
139
|
+
declare class CreateIndexCall extends MysqlOpFactoryCallNode {
|
|
140
|
+
readonly tableName: string;
|
|
141
|
+
readonly indexName: string;
|
|
142
|
+
readonly columns: readonly string[];
|
|
143
|
+
readonly unique: boolean;
|
|
144
|
+
readonly factoryName: "createIndex";
|
|
145
|
+
readonly operationClass: "additive";
|
|
146
|
+
readonly label: string;
|
|
147
|
+
constructor(tableName: string, indexName: string, columns: readonly string[], unique: boolean);
|
|
148
|
+
toOp(): Op;
|
|
149
|
+
renderTypeScript(): string;
|
|
150
|
+
}
|
|
151
|
+
declare class DropIndexCall extends MysqlOpFactoryCallNode {
|
|
152
|
+
readonly tableName: string;
|
|
153
|
+
readonly indexName: string;
|
|
154
|
+
readonly factoryName: "dropIndex";
|
|
155
|
+
readonly operationClass: "widening";
|
|
156
|
+
readonly label: string;
|
|
157
|
+
constructor(tableName: string, indexName: string);
|
|
158
|
+
toOp(): Op;
|
|
159
|
+
renderTypeScript(): string;
|
|
160
|
+
}
|
|
161
|
+
declare class AddUniqueCall extends MysqlOpFactoryCallNode {
|
|
162
|
+
readonly tableName: string;
|
|
163
|
+
readonly constraintName: string;
|
|
164
|
+
readonly columns: readonly string[];
|
|
165
|
+
readonly factoryName: "addUnique";
|
|
166
|
+
readonly operationClass: "additive";
|
|
167
|
+
readonly label: string;
|
|
168
|
+
constructor(tableName: string, constraintName: string, columns: readonly string[]);
|
|
169
|
+
toOp(): Op;
|
|
170
|
+
renderTypeScript(): string;
|
|
171
|
+
}
|
|
172
|
+
declare class DropUniqueCall extends MysqlOpFactoryCallNode {
|
|
173
|
+
readonly tableName: string;
|
|
174
|
+
readonly constraintName: string;
|
|
175
|
+
readonly factoryName: "dropUnique";
|
|
176
|
+
readonly operationClass: "widening";
|
|
177
|
+
readonly label: string;
|
|
178
|
+
constructor(tableName: string, constraintName: string);
|
|
179
|
+
toOp(): Op;
|
|
180
|
+
renderTypeScript(): string;
|
|
181
|
+
}
|
|
182
|
+
/** A foreign key as `addForeignKey` takes it. */
|
|
183
|
+
interface MysqlForeignKeySpec {
|
|
184
|
+
readonly name: string;
|
|
185
|
+
readonly columns: readonly string[];
|
|
186
|
+
readonly references: {
|
|
187
|
+
readonly table: string;
|
|
188
|
+
readonly columns: readonly string[];
|
|
189
|
+
};
|
|
190
|
+
readonly onDelete?: ReferentialAction;
|
|
191
|
+
readonly onUpdate?: ReferentialAction;
|
|
192
|
+
}
|
|
193
|
+
declare class AddForeignKeyCall extends MysqlOpFactoryCallNode {
|
|
194
|
+
readonly tableName: string;
|
|
195
|
+
readonly foreignKey: MysqlForeignKeySpec;
|
|
196
|
+
readonly factoryName: "addForeignKey";
|
|
197
|
+
readonly operationClass: "additive";
|
|
198
|
+
readonly label: string;
|
|
199
|
+
constructor(tableName: string, foreignKey: MysqlForeignKeySpec);
|
|
200
|
+
toOp(): Op;
|
|
201
|
+
renderTypeScript(): string;
|
|
202
|
+
}
|
|
203
|
+
declare class DropForeignKeyCall extends MysqlOpFactoryCallNode {
|
|
204
|
+
readonly tableName: string;
|
|
205
|
+
readonly constraintName: string;
|
|
206
|
+
readonly factoryName: "dropForeignKey";
|
|
207
|
+
readonly operationClass: "widening";
|
|
208
|
+
readonly label: string;
|
|
209
|
+
constructor(tableName: string, constraintName: string);
|
|
210
|
+
toOp(): Op;
|
|
211
|
+
renderTypeScript(): string;
|
|
212
|
+
}
|
|
213
|
+
/** An operation built elsewhere, such as the table rename a user writes by hand, carried as it is and written as `rawSql({...})`. */
|
|
214
|
+
declare class RawSqlCall extends MysqlOpFactoryCallNode {
|
|
215
|
+
readonly op: Op;
|
|
216
|
+
readonly factoryName: "rawSql";
|
|
217
|
+
readonly operationClass: MigrationOperationClass;
|
|
218
|
+
readonly label: string;
|
|
219
|
+
constructor(op: Op);
|
|
220
|
+
toOp(): Op;
|
|
221
|
+
renderTypeScript(): string;
|
|
222
|
+
importRequirements(): readonly ImportRequirement[];
|
|
223
|
+
}
|
|
224
|
+
type MysqlOpFactoryCall = CreateTableCall | DropTableCall | AddColumnCall | DropColumnCall | CreateIndexCall | DropIndexCall | AddUniqueCall | DropUniqueCall | AddForeignKeyCall | DropForeignKeyCall | RawSqlCall;
|
|
225
|
+
//#endregion
|
|
226
|
+
//#region src/core/migrations/planner-produced-mysql-migration.d.ts
|
|
227
|
+
interface MysqlMigrationDestinationInfo {
|
|
228
|
+
readonly storageHash: string;
|
|
229
|
+
readonly profileHash?: string;
|
|
230
|
+
}
|
|
231
|
+
/** The plan the MySQL planner produces: its operations, and the `migration.ts` that writes them. */
|
|
232
|
+
declare class TypeScriptRenderableMysqlMigration extends MysqlMigration implements MigrationPlanWithAuthoringSurface {
|
|
233
|
+
#private;
|
|
234
|
+
constructor(options: {
|
|
235
|
+
readonly calls: readonly OpFactoryCall[];
|
|
236
|
+
readonly meta: MigrationMeta;
|
|
237
|
+
readonly spaceId: string;
|
|
238
|
+
readonly snapshotsImportPath: string;
|
|
239
|
+
readonly destination?: MysqlMigrationDestinationInfo;
|
|
240
|
+
readonly lowerer?: ExecuteRequestLowerer;
|
|
241
|
+
});
|
|
242
|
+
get operations(): readonly (Op | Promise<Op>)[];
|
|
243
|
+
describe(): MigrationMeta;
|
|
244
|
+
get destination(): MysqlMigrationDestinationInfo;
|
|
245
|
+
get spaceId(): string;
|
|
246
|
+
renderTypeScript(resolveImportSpecifier: ImportSpecifierResolver): string;
|
|
247
|
+
}
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region src/core/migrations/planner.d.ts
|
|
250
|
+
type MysqlPlanResult = {
|
|
251
|
+
readonly kind: 'success';
|
|
252
|
+
readonly plan: TypeScriptRenderableMysqlMigration;
|
|
253
|
+
readonly appliedStatements: readonly [];
|
|
254
|
+
readonly dataLoss: readonly MigrationDataLoss[];
|
|
255
|
+
readonly accessChanges: readonly MigrationAccessChange[];
|
|
256
|
+
readonly temporaryValues: readonly MigrationTemporaryValue[];
|
|
257
|
+
} | SqlPlannerFailureResult;
|
|
258
|
+
/**
|
|
259
|
+
* The MySQL migration planner. It diffs the contract's schema against the live one and plans creating and dropping tables, columns, indexes, unique constraints and foreign keys. Every other change, and every statement such as a rename, is refused with a conflict that says it is not yet supported on MySQL.
|
|
260
|
+
*/
|
|
261
|
+
declare class MysqlMigrationPlanner implements SqlMigrationPlanner<MysqlPlanTargetDetails>, MigrationPlanner<'sql', 'mysql'> {
|
|
262
|
+
#private;
|
|
263
|
+
constructor(lowerer: ExecuteRequestLowerer);
|
|
264
|
+
plan(options: {
|
|
265
|
+
readonly contract: unknown;
|
|
266
|
+
readonly schema: unknown;
|
|
267
|
+
readonly policy: MigrationOperationPolicy;
|
|
268
|
+
readonly fromContract: Contract | null;
|
|
269
|
+
readonly origin: PlanOrigin | null;
|
|
270
|
+
readonly statements: readonly ResolvedMigrationStatement[];
|
|
271
|
+
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
|
|
272
|
+
readonly spaceId: string;
|
|
273
|
+
readonly ownership?: SchemaOwnership;
|
|
274
|
+
readonly snapshotsImportPath: string;
|
|
275
|
+
}): MysqlPlanResult;
|
|
276
|
+
emptyMigration(context: MigrationScaffoldContext, spaceId: string): TypeScriptRenderableMysqlMigration;
|
|
277
|
+
}
|
|
278
|
+
declare function createMysqlMigrationPlanner(lowerer: ExecuteRequestLowerer): MysqlMigrationPlanner;
|
|
279
|
+
//#endregion
|
|
280
|
+
//#region src/core/migrations/runner.d.ts
|
|
281
|
+
declare function createMysqlMigrationRunner(family: SqlControlFamilyInstance): SqlMigrationRunner<MysqlPlanTargetDetails>;
|
|
282
|
+
//#endregion
|
|
283
|
+
export { lit$1 as C, sql as D, rawSql as E, unique as O, fn$1 as S, primaryKey as T, RawSqlCall as _, CreateTableCall as a, createMysqlMigrationPlanner as b, DropIndexCall as c, MigrationCLI as d, MysqlMigration as f, MysqlPlanResult as g, MysqlOpFactoryCall as h, CreateIndexCall as i, DropTableCall as l, MysqlMigrationPlanner as m, AddForeignKeyCall as n, DropColumnCall as o, MysqlMigrationDestinationInfo as p, AddUniqueCall as r, DropForeignKeyCall as s, AddColumnCall as t, DropUniqueCall as u, TypeScriptRenderableMysqlMigration as v, placeholder as w, createMysqlMigrationRunner as x, col$1 as y };
|
|
284
|
+
//# sourceMappingURL=migration-DmlblTTw.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-DmlblTTw.d.mts","names":[],"sources":["../../../../3-targets/mysql/1-target/dist/migration.d.mts"],"mappings":"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"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { col as col$1, fn as fn$1, lit as lit$1, primaryKey, unique } from "@prisma/orm-family-sql/relational-core/contract-free";
|
|
2
|
+
import { MigrationCLI } from "@prisma/orm-toolchain/cli/migration-cli";
|
|
3
|
+
import { placeholder } from "@prisma/orm-framework/errors/migration";
|
|
4
|
+
import { sql } from "@prisma/orm-family-sql/contract/sql-expression";
|
|
5
|
+
export { placeholder as a, unique as c, lit$1 as i, col$1 as n, primaryKey as o, fn$1 as r, sql as s, MigrationCLI as t };
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { t as mysqlError } from "./errors-rvH_F2Yj-BQrO_--u.mjs";
|
|
2
|
+
import { n as quoteIdentifier } from "./sql-utils-Db0IQO_B-PaULnfrE.mjs";
|
|
3
|
+
import { i as mysqlDataTypes } from "./data-types-Dv9gwVRV-BZPzCWZk.mjs";
|
|
4
|
+
import { createDataTypeLookup } from "@prisma/orm-framework/components/codec";
|
|
5
|
+
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
6
|
+
import { UNBOUND_NAMESPACE_ID, freezeNode, hydrateNamespaceEntities } from "@prisma/orm-framework/components/ir";
|
|
7
|
+
import { SqlNamespaceBase } from "@prisma/orm-family-sql/contract/types";
|
|
8
|
+
import { SqlContractSerializerBase } from "@prisma/orm-family-sql/family/ir";
|
|
9
|
+
import { tableEntityKind } from "@prisma/orm-family-sql/contract/entity-kinds";
|
|
10
|
+
//#region ../../../3-targets/mysql/1-target/dist/mysql-contract-serializer-DLv0uW_f.mjs
|
|
11
|
+
const MYSQL_NAMESPACE_KIND = "mysql-namespace";
|
|
12
|
+
/**
|
|
13
|
+
* The MySQL database a connection uses, as the contract's one namespace. Tables are addressed unqualified, so the contract runs against whichever database the connection names.
|
|
14
|
+
*/
|
|
15
|
+
var MysqlDatabase = class extends SqlNamespaceBase {
|
|
16
|
+
id;
|
|
17
|
+
entries;
|
|
18
|
+
constructor(input) {
|
|
19
|
+
super();
|
|
20
|
+
this.id = input.id;
|
|
21
|
+
const dispatched = hydrateNamespaceEntities(input.entries, /* @__PURE__ */ new Map([["table", tableEntityKind]]), "carry");
|
|
22
|
+
this.entries = Object.freeze(blindCast(dispatched));
|
|
23
|
+
Object.defineProperty(this, "kind", {
|
|
24
|
+
value: MYSQL_NAMESPACE_KIND,
|
|
25
|
+
writable: false,
|
|
26
|
+
enumerable: false,
|
|
27
|
+
configurable: true
|
|
28
|
+
});
|
|
29
|
+
freezeNode(this);
|
|
30
|
+
}
|
|
31
|
+
get table() {
|
|
32
|
+
return this.entries.table ?? Object.freeze({});
|
|
33
|
+
}
|
|
34
|
+
qualifier() {
|
|
35
|
+
return "";
|
|
36
|
+
}
|
|
37
|
+
qualifyTable(tableName) {
|
|
38
|
+
return quoteIdentifier(tableName);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
function isLoose(value) {
|
|
42
|
+
return typeof value === "object" && value !== null;
|
|
43
|
+
}
|
|
44
|
+
function enumMembersOf(namespace, tableName, columnName, column) {
|
|
45
|
+
const subject = `Column "${tableName}"."${columnName}"`;
|
|
46
|
+
const ref = column["valueSet"];
|
|
47
|
+
const valueSetName = isLoose(ref) && ref["namespaceId"] === namespace.id ? ref["entityName"] : void 0;
|
|
48
|
+
const valueSet = typeof valueSetName === "string" ? namespace.entries["valueSet"]?.[valueSetName] : void 0;
|
|
49
|
+
const values = isLoose(valueSet) ? valueSet["values"] : void 0;
|
|
50
|
+
if (!Array.isArray(values) || !values.every((value) => typeof value === "string")) throw mysqlError("CONTRACT.TYPE_PARAMS_INVALID", `${subject} is a MySQL enum but has no enum whose text members it can list.`, {
|
|
51
|
+
why: "A native MySQL enum column is written with its members, which come from the enum that types the column.",
|
|
52
|
+
fix: "Type the column with a PSL enum or an enumType() whose members are text.",
|
|
53
|
+
meta: {
|
|
54
|
+
table: tableName,
|
|
55
|
+
column: columnName
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return values;
|
|
59
|
+
}
|
|
60
|
+
function isEnumColumn(column) {
|
|
61
|
+
return isLoose(column) && column["codecId"] === "mysql/enum@1";
|
|
62
|
+
}
|
|
63
|
+
function sameMembers(left, right) {
|
|
64
|
+
return left.length === right.length && left.every((value, index) => value === right[index]);
|
|
65
|
+
}
|
|
66
|
+
function enumColumnWithMembers(namespace, tableName, columnName, column) {
|
|
67
|
+
const typeParams = isLoose(column["typeParams"]) ? column["typeParams"] : {};
|
|
68
|
+
const values = enumMembersOf(namespace, tableName, columnName, column);
|
|
69
|
+
const listed = typeParams["values"];
|
|
70
|
+
if (listed !== void 0 && !(Array.isArray(listed) && sameMembers(listed, values))) throw mysqlError("CONTRACT.TYPE_PARAMS_INVALID", `Column "${tableName}"."${columnName}" lists enum members that differ from the members of the enum that types it.`, {
|
|
71
|
+
why: "A MySQL enum column takes its members from its enum, in the order the enum declares them, so the database and the contract enforce the same members.",
|
|
72
|
+
fix: "Remove the column’s own members, or make them equal the enum’s members in the same order.",
|
|
73
|
+
meta: {
|
|
74
|
+
table: tableName,
|
|
75
|
+
column: columnName,
|
|
76
|
+
columnValues: listed,
|
|
77
|
+
valueSetValues: values
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
return {
|
|
81
|
+
...column,
|
|
82
|
+
typeParams: {
|
|
83
|
+
...typeParams,
|
|
84
|
+
values
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function withEnumMembers(namespace, tableName, table) {
|
|
89
|
+
if (!isLoose(table)) return table;
|
|
90
|
+
const columns = table["columns"];
|
|
91
|
+
if (!isLoose(columns) || !Object.values(columns).some(isEnumColumn)) return table;
|
|
92
|
+
const filled = Object.fromEntries(Object.entries(columns).map(([columnName, column]) => [columnName, isEnumColumn(column) ? enumColumnWithMembers(namespace, tableName, columnName, column) : column]));
|
|
93
|
+
return {
|
|
94
|
+
...table,
|
|
95
|
+
columns: filled
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Writes each MySQL enum column's members, from the value set the column names, into its type parameters, in the order the enum declares them, and refuses a column whose own members differ from them. The column's type is then `enum('A','B')`, so the database enforces the members and `db verify` sees a change to them as a change of the column's type.
|
|
100
|
+
*/
|
|
101
|
+
function fillEnumMembers(input) {
|
|
102
|
+
const tables = input.entries["table"];
|
|
103
|
+
if (tables === void 0) return input;
|
|
104
|
+
return {
|
|
105
|
+
...input,
|
|
106
|
+
entries: {
|
|
107
|
+
...input.entries,
|
|
108
|
+
table: Object.fromEntries(Object.entries(tables).map(([tableName, table]) => [tableName, withEnumMembers(input, tableName, table)]))
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The MySQL target's refusal of expression and partial indexes, which it neither writes nor introspects yet.
|
|
114
|
+
*/
|
|
115
|
+
function rejectSqlBodyIndexes(input) {
|
|
116
|
+
for (const [tableName, table] of Object.entries(input.entries["table"] ?? {})) {
|
|
117
|
+
const indexes = isLoose(table) ? table["indexes"] : void 0;
|
|
118
|
+
for (const index of Array.isArray(indexes) ? indexes : []) {
|
|
119
|
+
if (!isLoose(index)) continue;
|
|
120
|
+
if (index["expression"] !== void 0 || index["where"] !== void 0) throw mysqlError("CONTRACT.ARGUMENT_INVALID", `MySQL does not support expression or partial indexes yet: index "${String(index["name"] ?? "<unnamed>")}" on table "${tableName}" declares ${index["expression"] !== void 0 ? "an expression" : "a where predicate"}. Use a fields-only index.`, { meta: { table: tableName } });
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The namespace factory the MySQL target hands `defineContract` and the PSL interpreter. MySQL has one namespace per connection, the framework's unbound slot.
|
|
126
|
+
*/
|
|
127
|
+
function mysqlCreateNamespace(input) {
|
|
128
|
+
if (input.id !== UNBOUND_NAMESPACE_ID) throw mysqlError("CONTRACT.NAMESPACE_INVALID", `The MySQL target has one namespace, "${UNBOUND_NAMESPACE_ID}"; it received "${input.id}".`, { meta: { received: input.id } });
|
|
129
|
+
rejectSqlBodyIndexes(input);
|
|
130
|
+
return new MysqlDatabase(fillEnumMembers(input));
|
|
131
|
+
}
|
|
132
|
+
/** The MySQL target's contract serializer: the SQL family's, with each namespace built as a `MysqlDatabase`. */
|
|
133
|
+
var MysqlContractSerializer = class extends SqlContractSerializerBase {
|
|
134
|
+
constructor() {
|
|
135
|
+
super(/* @__PURE__ */ new Map(), [], createDataTypeLookup(mysqlDataTypes));
|
|
136
|
+
}
|
|
137
|
+
hydrateSqlNamespaceEntry(nsId, raw) {
|
|
138
|
+
return mysqlCreateNamespace(blindCast(super.hydrateSqlNamespaceEntry(nsId, raw)));
|
|
139
|
+
}
|
|
140
|
+
serializeContract(contract) {
|
|
141
|
+
const { storage, ...rest } = contract;
|
|
142
|
+
const namespacesJson = {};
|
|
143
|
+
for (const [nsId, ns] of Object.entries(storage.namespaces)) namespacesJson[nsId] = {
|
|
144
|
+
id: ns.id,
|
|
145
|
+
entries: this.serializeNamespaceEntries(ns.entries)
|
|
146
|
+
};
|
|
147
|
+
return blindCast({
|
|
148
|
+
...rest,
|
|
149
|
+
storage: {
|
|
150
|
+
storageHash: String(storage.storageHash),
|
|
151
|
+
namespaces: namespacesJson,
|
|
152
|
+
...storage.types !== void 0 ? { types: this.serializeJsonObject(storage.types) } : {}
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
//#endregion
|
|
158
|
+
export { MysqlDatabase as n, mysqlCreateNamespace as r, MysqlContractSerializer as t };
|
|
159
|
+
|
|
160
|
+
//# sourceMappingURL=mysql-contract-serializer-DLv0uW_f-Cg4A43Ry.mjs.map
|