okmodel 0.8.0 → 0.9.0
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/README.md +14 -0
- package/dist/dialects/pg/ext/btree-gin.d.ts +26 -0
- package/dist/dialects/pg/ext/btree-gin.js +20 -0
- package/dist/dialects/pg/ext/btree-gist.d.ts +26 -0
- package/dist/dialects/pg/ext/btree-gist.js +20 -0
- package/dist/dialects/pg/ext/call.d.ts +53 -0
- package/dist/dialects/pg/ext/citext.js +1 -1
- package/dist/dialects/pg/ext/feature.d.ts +26 -0
- package/dist/dialects/pg/ext/fuzzystrmatch.d.ts +34 -0
- package/dist/dialects/pg/ext/fuzzystrmatch.js +33 -0
- package/dist/dialects/pg/ext/hstore.d.ts +41 -0
- package/dist/dialects/pg/ext/hstore.js +29 -0
- package/dist/dialects/pg/ext/index.d.ts +56 -0
- package/dist/dialects/pg/ext/index.js +1 -1
- package/dist/dialects/pg/ext/ltree.d.ts +41 -0
- package/dist/dialects/pg/ext/ltree.js +29 -0
- package/dist/dialects/pg/ext/pg-trgm.js +4 -13
- package/dist/dialects/pg/ext/pgcrypto.d.ts +33 -0
- package/dist/dialects/pg/ext/pgcrypto.js +33 -0
- package/dist/dialects/pg/ext/unaccent.d.ts +26 -0
- package/dist/dialects/pg/ext/unaccent.js +21 -0
- package/dist/dialects/pg/ext/using.d.ts +23 -0
- package/dist/dialects/pg/ext/versions.d.ts +36 -0
- package/dist/dialects/pg/external.d.ts +19 -0
- package/dist/dialects/pg/fn/index.js +4 -4
- package/dist/dialects/pg/index.d.ts +1 -0
- package/dist/dialects/pg/index.js +16 -11
- package/dist/dialects/pg/view/index.js +5 -5
- package/dist/dialects/pg/view/scratch.d.ts +4 -1
- package/dist/runtime/artifact-file.d.ts +22 -0
- package/dist/runtime/client.d.ts +10 -0
- package/dist/runtime/drift-detail.d.ts +2 -1
- package/dist/runtime/drift.d.ts +3 -10
- package/dist/runtime/pg/bun.js +4 -4
- package/dist/runtime/pg/neon.js +4 -4
- package/dist/runtime/pg/pg.js +4 -4
- package/dist/runtime/pg/pglite.js +4 -4
- package/dist/runtime/pg/postgresjs.js +4 -4
- package/dist/runtime/server-check.d.ts +36 -6
- package/dist/runtime/traits/index.js +5 -5
- package/dist/runtime/validate/index.js +1 -1
- package/dist/shared/{4m6hskg8.js → 0j6qe91y.js} +4 -4
- package/dist/shared/{14x60fbf.js → 1mxm04fy.js} +5 -5
- package/dist/shared/{b6d6p0zc.js → 2szgv6yj.js} +5 -5
- package/dist/shared/{f4jy1j7x.js → 2zdxkt7b.js} +909 -100
- package/dist/shared/{mnvjvqyp.js → 3456242y.js} +17 -17
- package/dist/shared/3t6kw83m.js +1 -1
- package/dist/shared/{6m78c8ss.js → 5kyb3tqx.js} +1 -1
- package/dist/shared/61bmrmhr.js +35 -0
- package/dist/shared/{zbqbmmrp.js → 62b603gr.js} +8 -8
- package/dist/shared/{jgqj11w4.js → 6f0z3hzh.js} +4 -0
- package/dist/shared/{dpc2r7rb.js → 6nae0spm.js} +150 -89
- package/dist/shared/{0wrea3jq.js → 71n0jmhc.js} +1 -1
- package/dist/shared/7ba5h6pb.js +17 -0
- package/dist/shared/{k86n8vq3.js → 8jesqsrk.js} +1 -1
- package/dist/shared/{qd9hhd8f.js → 8n688yjg.js} +1 -1
- package/dist/shared/{zgex00fd.js → 8qzkd9f3.js} +5 -5
- package/dist/shared/{mkrn359n.js → 90sg0w5a.js} +159 -31
- package/dist/shared/{7ghwamrf.js → 99qp9vtg.js} +1 -1
- package/dist/shared/{bxas03mq.js → 9dtgn1z2.js} +1 -1
- package/dist/shared/{p5nh3r8q.js → aksb89mn.js} +2 -2
- package/dist/shared/{wcrheftc.js → bphrgwz9.js} +2 -2
- package/dist/shared/{wz2a78mp.js → c3mvnq7a.js} +1 -1
- package/dist/shared/{pan0370z.js → ccsmhv9r.js} +24 -6
- package/dist/shared/{n0jmpgj1.js → cexb7z6b.js} +1 -1
- package/dist/shared/{wvdjznah.js → cf8zdz5p.js} +5 -5
- package/dist/shared/{3449rcae.js → ckz05z15.js} +4 -4
- package/dist/shared/{35q0n9tz.js → dd5pmnky.js} +7 -7
- package/dist/shared/{e8zyaqvj.js → ds229x4r.js} +1 -1
- package/dist/{tooling/shared/yw30vnq2.js → shared/e275q7sd.js} +1 -1
- package/dist/shared/{mfedzr74.js → ebhz8vh6.js} +4 -4
- package/dist/shared/{z581d7ny.js → fdsz3w80.js} +2 -2
- package/dist/shared/{sjk86yrx.js → fk9vef30.js} +84 -73
- package/dist/shared/{needfe47.js → g89fmz5s.js} +1 -1
- package/dist/shared/{m4xff2a6.js → ghqzdp94.js} +2 -2
- package/dist/shared/h9811jjm.js +17 -0
- package/dist/shared/{kj9d8maq.js → jpybhf98.js} +1 -1
- package/dist/shared/kzgrnckd.js +29 -0
- package/dist/shared/{agsfb86s.js → mazpbcdj.js} +4 -4
- package/dist/shared/{195pzzzz.js → mgaq2sd3.js} +10 -7
- package/dist/shared/{5mtf6cj3.js → mvmm3xpb.js} +5 -2
- package/dist/shared/{p3xbdcvt.js → myk8fswx.js} +55 -6
- package/dist/shared/{njga14v4.js → n306gqkd.js} +8 -8
- package/dist/shared/n5whk3mt.js +665 -0
- package/dist/shared/{bah9nbg3.js → npdftanb.js} +12 -20
- package/dist/shared/{16kvjebh.js → pg4ezgyf.js} +7 -26
- package/dist/{tooling/shared/08kemxjd.js → shared/pgsak1yw.js} +1 -1
- package/dist/shared/{jp36k7dp.js → qvwwp1mp.js} +61 -40
- package/dist/shared/rbxt795q.js +1766 -0
- package/dist/shared/{g5yc06ka.js → s7he5e5d.js} +1 -1
- package/dist/shared/{hfqmpasr.js → ss2kv2rs.js} +5 -5
- package/dist/shared/stfa9xcw.js +450 -0
- package/dist/{tooling/shared/rs1jb051.js → shared/tr64w5p0.js} +1 -1
- package/dist/shared/{jebgrkeq.js → tw1nvvfj.js} +2 -2
- package/dist/shared/{v1wad97q.js → wvtjg5m3.js} +1 -1
- package/dist/shared/xqacq37x.js +61 -0
- package/dist/shared/{n05z9nwz.js → xtsydxjg.js} +1 -1
- package/dist/shared/{jx2m62cs.js → xv8qj97g.js} +5 -5
- package/dist/shared/{63f4ksbz.js → xwhdcrm4.js} +1 -1
- package/dist/shared/{hm5f8jby.js → yvabyg9k.js} +6 -6
- package/dist/shared/yybhre6n.js +136 -0
- package/dist/shared/zdqf8k5d.js +8 -0
- package/dist/tooling/cli.js +94 -22
- package/dist/tooling/driver-run.js +15 -332
- package/dist/tooling/github/comment.d.ts +50 -0
- package/dist/tooling/github/post-comment.d.ts +17 -0
- package/dist/tooling/migrate/commands.d.ts +2 -1
- package/dist/tooling/migrate/config.d.ts +13 -0
- package/dist/tooling/migrate/export.d.ts +165 -0
- package/dist/tooling/migrate/ext-surface.d.ts +80 -0
- package/dist/tooling/migrate/ext.d.ts +31 -4
- package/dist/tooling/migrate/import-drizzle.d.ts +40 -0
- package/dist/tooling/migrate/index.d.ts +3 -0
- package/dist/tooling/migrate/index.js +55 -10
- package/dist/tooling/migrate/lint-rules.d.ts +18 -1
- package/dist/tooling/migrate/lint.d.ts +14 -1
- package/dist/tooling/migrate/place.d.ts +18 -0
- package/dist/tooling/migrate/plan-json.d.ts +65 -0
- package/dist/tooling/migrate/project.d.ts +10 -1
- package/dist/tooling/migrate/pull-emit.d.ts +98 -0
- package/dist/tooling/migrate/pull-routines.d.ts +126 -0
- package/dist/tooling/migrate/pull-verify.d.ts +26 -0
- package/dist/tooling/migrate/pull.d.ts +62 -0
- package/dist/tooling/migrate/reprint.d.ts +32 -0
- package/dist/tooling/migrate/sandbox.d.ts +8 -2
- package/dist/tooling/migrate/schema-api.d.ts +43 -0
- package/dist/tooling/migrate/sql-lex.d.ts +18 -0
- package/dist/tooling/shared/{3m1hkg7z.js → 04svnxxj.js} +4 -4
- package/dist/tooling/shared/{ppnnnvj8.js → 0j0jtse1.js} +1 -1
- package/dist/tooling/shared/{z8d7ptht.js → 0r05zhyq.js} +5 -5
- package/dist/tooling/shared/{a6pp9d12.js → 1800eymw.js} +3 -3
- package/dist/tooling/shared/{cmptmb4f.js → 35zemrmf.js} +1 -1
- package/dist/tooling/shared/{w7qe8sj1.js → 3rmaz3pq.js} +1 -1
- package/dist/{shared/q0cqt2sp.js → tooling/shared/3yn79q5m.js} +1 -1
- package/dist/tooling/shared/{2revefqt.js → 57btdkgm.js} +2 -2
- package/dist/tooling/shared/{ma2340rx.js → 5bmksndh.js} +2 -2
- package/dist/tooling/shared/{9xzm7hjg.js → 5p8km5jb.js} +3 -3
- package/dist/tooling/shared/{xhrnjch9.js → 5x3pf400.js} +3 -3
- package/dist/tooling/shared/{wwnekq5n.js → 5zrzffnk.js} +1 -1
- package/dist/tooling/shared/{p7f08ktn.js → 62fxpc1p.js} +7 -7
- package/dist/tooling/shared/{7ae7rjmn.js → 68tf18v4.js} +2 -2
- package/dist/tooling/shared/{rf83gr2d.js → 6vk28rjp.js} +7 -3
- package/dist/tooling/shared/76pv6qff.js +9 -0
- package/dist/tooling/shared/{bz2dqhab.js → 7aews1zg.js} +3 -3
- package/dist/tooling/shared/{9kazs5p6.js → 7b3xp9gc.js} +3 -3
- package/dist/tooling/shared/{4d2w25vw.js → 7pxncnzs.js} +2 -2
- package/dist/tooling/shared/{zvnhh1n0.js → 829fjxyw.js} +2 -2
- package/dist/tooling/shared/{dzx85q70.js → 8m5znpdt.js} +1 -1
- package/dist/tooling/shared/{g9ad4n80.js → 8yr7ges1.js} +7 -7
- package/dist/tooling/shared/{tn8gay14.js → 9qr9rkbh.js} +6 -6
- package/dist/tooling/shared/{8sqrsw3s.js → 9sfbtwsk.js} +3 -3
- package/dist/{shared/bnby0esn.js → tooling/shared/9wsnsvbf.js} +1 -1
- package/dist/tooling/shared/{aftb2mwr.js → a2xe04bm.js} +1 -1
- package/dist/tooling/shared/{nf7jmhfa.js → a4pzghha.js} +2 -2
- package/dist/tooling/shared/{y5656f0e.js → am04v8na.js} +5 -5
- package/dist/tooling/shared/{417zdsk7.js → asgr07mp.js} +5 -5
- package/dist/tooling/shared/{pqy21k24.js → c0xevn1h.js} +4 -4
- package/dist/tooling/shared/dhatassp.js +134 -0
- package/dist/tooling/shared/{spk1jg3r.js → ezqn88nj.js} +8 -8
- package/dist/tooling/shared/{6nyfyw70.js → f77nnfqy.js} +2 -2
- package/dist/tooling/shared/{wt7j7nf6.js → fh07z1dt.js} +1 -1
- package/dist/tooling/shared/{3rrw5w8f.js → gqwevek4.js} +1 -1
- package/dist/tooling/shared/{f9mphxej.js → hfq3n3bd.js} +346 -19
- package/dist/tooling/shared/{vs0t6qt8.js → j664qjrt.js} +2 -2
- package/dist/tooling/shared/{733a1tq3.js → jpgmjsx3.js} +3 -3
- package/dist/tooling/shared/{mtrqn2hn.js → jr2nmr81.js} +22 -30
- package/dist/{shared/mtw6jz76.js → tooling/shared/jsjjz875.js} +1 -1
- package/dist/tooling/shared/{2wtvc7rw.js → kbqnrs1x.js} +2 -2
- package/dist/tooling/shared/{gfvtj6d0.js → kz715295.js} +7 -7
- package/dist/tooling/shared/{a7q7t4n3.js → m3xt8b1h.js} +2 -2
- package/dist/tooling/shared/{dw08f3m8.js → m4hhb8aa.js} +2 -2
- package/dist/tooling/shared/{y031jct9.js → mw5npye0.js} +2 -2
- package/dist/tooling/shared/{vraj6d74.js → nxq95eb6.js} +3 -3
- package/dist/tooling/shared/{fb9k2qwd.js → qartgazh.js} +11 -30
- package/dist/tooling/shared/{xjs6zqtc.js → rcywj2w8.js} +9 -9
- package/dist/tooling/shared/{dy672fz6.js → s6qha57m.js} +2 -2
- package/dist/tooling/shared/{vx86qjv8.js → shjs0379.js} +3 -3
- package/dist/tooling/shared/{345tbc2k.js → sjwkt1pg.js} +1 -1
- package/dist/tooling/shared/{rq5kk8j6.js → stebqyyd.js} +3 -3
- package/dist/tooling/shared/{yk9mp7vb.js → t4xveemq.js} +4 -4
- package/dist/tooling/shared/{djydjpqt.js → t6zjeake.js} +5 -5
- package/dist/tooling/shared/{zhwnfyb2.js → tcwpjvxe.js} +1 -1
- package/dist/tooling/shared/{72fyg4zv.js → tpssp7ac.js} +1 -1
- package/dist/tooling/shared/{jne7b93p.js → v6j1ep6w.js} +3 -3
- package/dist/tooling/shared/{ec71zqgt.js → vwr2y833.js} +2 -2
- package/dist/tooling/shared/{j9t5s12a.js → w17sj05d.js} +2 -2
- package/dist/tooling/shared/{3tq8pnb8.js → w5d89rb4.js} +1 -1
- package/dist/tooling/shared/{smn6kz1p.js → wbwq1jsa.js} +2 -2
- package/dist/tooling/shared/{pwsytxm5.js → wezxf3h8.js} +1 -1
- package/dist/tooling/shared/{5bvw2nev.js → yb4kd19s.js} +1 -1
- package/dist/tooling/shared/{gmcf9cxf.js → ybdew6j7.js} +2 -2
- package/dist/tooling/shared/{ep8zh3bk.js → yfedr1zb.js} +1 -1
- package/dist/tooling/shared/{ddjtfgnx.js → yhp829bx.js} +3 -3
- package/dist/tooling/shared/{yfr8hzhm.js → ytk1tjs0.js} +1 -1
- package/dist/tooling/shared/{03k6res6.js → zs9aymcp.js} +1 -1
- package/dist/tooling/shared/zx3v9phv.js +8 -0
- package/dist/tooling/testing/index.js +2 -2
- package/package.json +38 -9
- package/dist/shared/fjpnhqan.js +0 -71
- package/dist/shared/n41w4fbz.js +0 -113
- package/dist/tooling/shared/pw8fgahx.js +0 -69
- /package/dist/shared/{ae4j5f42.js → mfvx6kjx.js} +0 -0
package/dist/shared/fjpnhqan.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
POSTGRES_FLOOR,
|
|
3
|
-
isPostgresMajor,
|
|
4
|
-
parsePostgresFloor,
|
|
5
|
-
serverNeedsPostgres
|
|
6
|
-
} from "./ga9j92qj.js";
|
|
7
|
-
import {
|
|
8
|
-
withHttp,
|
|
9
|
-
attachHttp
|
|
10
|
-
} from "./bah9nbg3.js";
|
|
11
|
-
import {
|
|
12
|
-
OkmError2
|
|
13
|
-
} from "./52szzakm.js";
|
|
14
|
-
|
|
15
|
-
// src/runtime/server-check.ts
|
|
16
|
-
var versionQuery = "select current_setting('server_version_num'), version(), (select (xpath('//catalog_hash/text()', query_to_xml('select catalog_hash from okm_meta where id = ''head''', true, false, '')))[1]::text where to_regclass('okm_meta') is not null)";
|
|
17
|
-
async function acceptServer(pool, schema, rows, http, requireMeta, options, source) {
|
|
18
|
-
for (const name in schema.model) {
|
|
19
|
-
if (schema.model[name]?.presets !== undefined) {
|
|
20
|
-
(await import("./m7n9h2a5.js")).checkSchema(schema);
|
|
21
|
-
break;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
const version = rows[0]?.[1];
|
|
25
|
-
if (version === null || version === undefined || !version.startsWith("PostgreSQL")) {
|
|
26
|
-
throw new OkmError2("OKM1801", "The server is not PostgreSQL. The schema dialect is postgres.", withHttp(http, {
|
|
27
|
-
fix: { summary: "Open the schema with the Postgres driver that matches it." }
|
|
28
|
-
}));
|
|
29
|
-
}
|
|
30
|
-
const recorded = rows[0]?.[2];
|
|
31
|
-
if (recorded === null || recorded === undefined || recorded.length === 0) {
|
|
32
|
-
if (requireMeta) {
|
|
33
|
-
throw new OkmError2("OKM1520", "okm_meta has no catalog hash.", withHttp(http, {
|
|
34
|
-
fix: {
|
|
35
|
-
summary: "Apply migrations so okm_meta records the catalog, or omit requireMeta to adopt this database."
|
|
36
|
-
}
|
|
37
|
-
}));
|
|
38
|
-
}
|
|
39
|
-
} else {
|
|
40
|
-
const { assertCompatible } = await import("./16kvjebh.js");
|
|
41
|
-
try {
|
|
42
|
-
await assertCompatible(pool, schema, recorded, source, options);
|
|
43
|
-
} catch (error) {
|
|
44
|
-
if (error instanceof OkmError2)
|
|
45
|
-
throw attachHttp(http, error);
|
|
46
|
-
throw error;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
const major = Math.floor(Number(rows[0]?.[0] ?? "0") / 1e4);
|
|
50
|
-
const raw = schema.requires?.postgres;
|
|
51
|
-
if (raw === undefined) {
|
|
52
|
-
if (major < POSTGRES_FLOOR) {
|
|
53
|
-
throw new OkmError2("OKM1803", serverNeedsPostgres(major, POSTGRES_FLOOR), withHttp(http, {
|
|
54
|
-
fix: {
|
|
55
|
-
summary: `Upgrade to PostgreSQL ${String(POSTGRES_FLOOR)} or higher.`
|
|
56
|
-
}
|
|
57
|
-
}));
|
|
58
|
-
}
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const need = parsePostgresFloor(raw);
|
|
62
|
-
if (!isPostgresMajor(need) || major < need) {
|
|
63
|
-
throw new OkmError2("OKM1802", serverNeedsPostgres(major, isPostgresMajor(need) ? need : POSTGRES_FLOOR), withHttp(http, {
|
|
64
|
-
fix: { summary: "Upgrade the server, or lower minPostgres to a major the server meets." }
|
|
65
|
-
}));
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
export {
|
|
69
|
-
acceptServer,
|
|
70
|
-
versionQuery
|
|
71
|
-
};
|
package/dist/shared/n41w4fbz.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
open2
|
|
3
|
-
} from "./35q0n9tz.js";
|
|
4
|
-
import"./12z7aznj.js";
|
|
5
|
-
import"./n442h54c.js";
|
|
6
|
-
import {
|
|
7
|
-
openProject
|
|
8
|
-
} from "./f4jy1j7x.js";
|
|
9
|
-
import {
|
|
10
|
-
sessionFailure,
|
|
11
|
-
finishQuiet,
|
|
12
|
-
assertTargetPolicy,
|
|
13
|
-
selectTarget
|
|
14
|
-
} from "./dpc2r7rb.js";
|
|
15
|
-
import"./sjk86yrx.js";
|
|
16
|
-
import {
|
|
17
|
-
isExactVersion,
|
|
18
|
-
compareExtensionVersions
|
|
19
|
-
} from "./r3j8s5y0.js";
|
|
20
|
-
import {
|
|
21
|
-
OkmError2
|
|
22
|
-
} from "./52szzakm.js";
|
|
23
|
-
|
|
24
|
-
// src/tooling/migrate/ext.ts
|
|
25
|
-
async function extProject(cwd, command, flags) {
|
|
26
|
-
const opened = await openProject(cwd);
|
|
27
|
-
const target = selectTarget(opened.config, flags.target);
|
|
28
|
-
assertTargetPolicy(target, "check", flags.allowProtected);
|
|
29
|
-
const pool = open2({ url: target.url, max: 1 });
|
|
30
|
-
try {
|
|
31
|
-
if (command === "list")
|
|
32
|
-
return formatList(await readExtensions(pool));
|
|
33
|
-
return formatCheck(opened.built.catalog.objects, await readExtensions(pool));
|
|
34
|
-
} catch (error) {
|
|
35
|
-
throw sessionFailure(error) ?? error;
|
|
36
|
-
} finally {
|
|
37
|
-
await finishQuiet(() => pool.close());
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
var LIST_SQL = `
|
|
41
|
-
select a.name, a.default_version, e.extversion, n.nspname
|
|
42
|
-
from pg_available_extensions a
|
|
43
|
-
left join pg_extension e on e.extname = a.name
|
|
44
|
-
left join pg_namespace n on n.oid = e.extnamespace
|
|
45
|
-
order by a.name
|
|
46
|
-
`;
|
|
47
|
-
async function readExtensions(pool) {
|
|
48
|
-
const result = await pool.execute(LIST_SQL);
|
|
49
|
-
return result.rows.map((row) => ({
|
|
50
|
-
name: cell(row[0]),
|
|
51
|
-
defaultVersion: cell(row[1]),
|
|
52
|
-
installedVersion: cell(row[2]),
|
|
53
|
-
schema: cell(row[3])
|
|
54
|
-
}));
|
|
55
|
-
}
|
|
56
|
-
function cell(value) {
|
|
57
|
-
return typeof value === "string" ? value : "";
|
|
58
|
-
}
|
|
59
|
-
function formatList(rows) {
|
|
60
|
-
const lines = ["name\tdefault\tinstalled\tschema"];
|
|
61
|
-
for (const row of rows) {
|
|
62
|
-
lines.push([row.name, row.defaultVersion, row.installedVersion, row.schema].join("\t"));
|
|
63
|
-
}
|
|
64
|
-
return `${lines.join(`
|
|
65
|
-
`)}
|
|
66
|
-
`;
|
|
67
|
-
}
|
|
68
|
-
function formatCheck(objects, server) {
|
|
69
|
-
const declared = objects.filter((object) => object.kind === "extension");
|
|
70
|
-
if (declared.length === 0)
|
|
71
|
-
return `no extensions
|
|
72
|
-
`;
|
|
73
|
-
const installed = new Map(server.map((row) => [row.name, row.installedVersion]));
|
|
74
|
-
const lines = ["name\tdeclared\tinstalled"];
|
|
75
|
-
for (const object of [...declared].sort((left, right) => left.identity.name < right.identity.name ? -1 : 1)) {
|
|
76
|
-
const name = object.identity.name;
|
|
77
|
-
const have = installed.get(name) ?? "";
|
|
78
|
-
if (have.length === 0) {
|
|
79
|
-
throw new OkmError2("OKM1811", `Extension ${name} is not installed on the server.`, {
|
|
80
|
-
fix: { summary: "Install the extension, or remove the declaration." }
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
const want = object.definition.version;
|
|
84
|
-
if (!versionAccepted(want, have)) {
|
|
85
|
-
throw new OkmError2("OKM1812", extensionNeeds(name, want ?? "", have), {
|
|
86
|
-
fix: { summary: "Install a version the declaration accepts, or change the pin." }
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
lines.push([name, want ?? "-", have].join("\t"));
|
|
90
|
-
}
|
|
91
|
-
return `${lines.join(`
|
|
92
|
-
`)}
|
|
93
|
-
`;
|
|
94
|
-
}
|
|
95
|
-
function extensionNeeds(name, want, have) {
|
|
96
|
-
const floor = /^>=(\d+(?:\.\d+)*)$/.exec(want);
|
|
97
|
-
const need = floor?.[1] ?? want;
|
|
98
|
-
const higher = floor === null ? "" : " or higher";
|
|
99
|
-
return `Extension ${name} needs ${need}${higher}. The server has ${have}. Install a version the declaration accepts, or change the pin.`;
|
|
100
|
-
}
|
|
101
|
-
function versionAccepted(declared, installed) {
|
|
102
|
-
if (declared === undefined)
|
|
103
|
-
return true;
|
|
104
|
-
const floor = /^>=(\d+(?:\.\d+)*)$/.exec(declared);
|
|
105
|
-
const minimum = floor?.[1];
|
|
106
|
-
if (minimum !== undefined) {
|
|
107
|
-
return isExactVersion(installed) && compareExtensionVersions(installed, minimum) >= 0;
|
|
108
|
-
}
|
|
109
|
-
return declared === installed;
|
|
110
|
-
}
|
|
111
|
-
export {
|
|
112
|
-
extProject
|
|
113
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
withHttp,
|
|
3
|
-
attachHttp
|
|
4
|
-
} from "./mtrqn2hn.js";
|
|
5
|
-
import {
|
|
6
|
-
OkmError,
|
|
7
|
-
POSTGRES_FLOOR,
|
|
8
|
-
isPostgresMajor,
|
|
9
|
-
parsePostgresFloor,
|
|
10
|
-
serverNeedsPostgres
|
|
11
|
-
} from "./f9mphxej.js";
|
|
12
|
-
|
|
13
|
-
// src/runtime/server-check.ts
|
|
14
|
-
var versionQuery = "select current_setting('server_version_num'), version(), (select (xpath('//catalog_hash/text()', query_to_xml('select catalog_hash from okm_meta where id = ''head''', true, false, '')))[1]::text where to_regclass('okm_meta') is not null)";
|
|
15
|
-
async function acceptServer(pool, schema, rows, http, requireMeta, options, source) {
|
|
16
|
-
for (const name in schema.model) {
|
|
17
|
-
if (schema.model[name]?.presets !== undefined) {
|
|
18
|
-
(await import("./ma2340rx.js")).checkSchema(schema);
|
|
19
|
-
break;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
const version = rows[0]?.[1];
|
|
23
|
-
if (version === null || version === undefined || !version.startsWith("PostgreSQL")) {
|
|
24
|
-
throw new OkmError("OKM1801", "The server is not PostgreSQL. The schema dialect is postgres.", withHttp(http, {
|
|
25
|
-
fix: { summary: "Open the schema with the Postgres driver that matches it." }
|
|
26
|
-
}));
|
|
27
|
-
}
|
|
28
|
-
const recorded = rows[0]?.[2];
|
|
29
|
-
if (recorded === null || recorded === undefined || recorded.length === 0) {
|
|
30
|
-
if (requireMeta) {
|
|
31
|
-
throw new OkmError("OKM1520", "okm_meta has no catalog hash.", withHttp(http, {
|
|
32
|
-
fix: {
|
|
33
|
-
summary: "Apply migrations so okm_meta records the catalog, or omit requireMeta to adopt this database."
|
|
34
|
-
}
|
|
35
|
-
}));
|
|
36
|
-
}
|
|
37
|
-
} else {
|
|
38
|
-
const { assertCompatible } = await import("./fb9k2qwd.js");
|
|
39
|
-
try {
|
|
40
|
-
await assertCompatible(pool, schema, recorded, source, options);
|
|
41
|
-
} catch (error) {
|
|
42
|
-
if (error instanceof OkmError)
|
|
43
|
-
throw attachHttp(http, error);
|
|
44
|
-
throw error;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const major = Math.floor(Number(rows[0]?.[0] ?? "0") / 1e4);
|
|
48
|
-
const raw = schema.requires?.postgres;
|
|
49
|
-
if (raw === undefined) {
|
|
50
|
-
if (major < POSTGRES_FLOOR) {
|
|
51
|
-
throw new OkmError("OKM1803", serverNeedsPostgres(major, POSTGRES_FLOOR), withHttp(http, {
|
|
52
|
-
fix: {
|
|
53
|
-
summary: `Upgrade to PostgreSQL ${String(POSTGRES_FLOOR)} or higher.`
|
|
54
|
-
}
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const need = parsePostgresFloor(raw);
|
|
60
|
-
if (!isPostgresMajor(need) || major < need) {
|
|
61
|
-
throw new OkmError("OKM1802", serverNeedsPostgres(major, isPostgresMajor(need) ? need : POSTGRES_FLOOR), withHttp(http, {
|
|
62
|
-
fix: { summary: "Upgrade the server, or lower minPostgres to a major the server meets." }
|
|
63
|
-
}));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
export {
|
|
67
|
-
acceptServer,
|
|
68
|
-
versionQuery
|
|
69
|
-
};
|
|
File without changes
|