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
|
@@ -3,6 +3,10 @@ import {
|
|
|
3
3
|
viewObject,
|
|
4
4
|
materializedViewObject
|
|
5
5
|
} from "./12z7aznj.js";
|
|
6
|
+
import {
|
|
7
|
+
quoteIdent2,
|
|
8
|
+
createObjectSql2
|
|
9
|
+
} from "./fk9vef30.js";
|
|
6
10
|
import {
|
|
7
11
|
cellText,
|
|
8
12
|
VIEW_DEPENDENCIES,
|
|
@@ -10,18 +14,14 @@ import {
|
|
|
10
14
|
PUBLIC,
|
|
11
15
|
introspectSchema,
|
|
12
16
|
atomicBody
|
|
13
|
-
} from "./
|
|
17
|
+
} from "./myk8fswx.js";
|
|
14
18
|
import {
|
|
15
19
|
planMigration,
|
|
16
20
|
sessionFailure,
|
|
17
21
|
finishQuiet,
|
|
18
22
|
assertDirectConnection,
|
|
19
23
|
assertStableBackend
|
|
20
|
-
} from "./
|
|
21
|
-
import {
|
|
22
|
-
quoteIdent,
|
|
23
|
-
createObjectSql
|
|
24
|
-
} from "./sjk86yrx.js";
|
|
24
|
+
} from "./6nae0spm.js";
|
|
25
25
|
import {
|
|
26
26
|
catalog
|
|
27
27
|
} from "./ywspezzx.js";
|
|
@@ -54,7 +54,7 @@ async function sealViews(runner, source) {
|
|
|
54
54
|
if (views.length === 0 && !hasAtomic)
|
|
55
55
|
return source;
|
|
56
56
|
await dropScratch(runner);
|
|
57
|
-
await runner.query(`create schema ${
|
|
57
|
+
await runner.query(`create schema ${quoteIdent2(SCRATCH)}`);
|
|
58
58
|
const previous = await runner.query(`select current_setting('search_path') as path`);
|
|
59
59
|
const saved = cellText(previous[0]?.path);
|
|
60
60
|
const path = await scratchSearchPath(runner, source);
|
|
@@ -141,44 +141,53 @@ async function scratchSearchPath(runner, source) {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
extra.sort();
|
|
144
|
-
return [SCRATCH, ...extra, "public"].map((name) =>
|
|
144
|
+
return [SCRATCH, ...extra, "public"].map((name) => quoteIdent2(name)).join(", ");
|
|
145
145
|
}
|
|
146
146
|
async function createObjects(runner, source, kind) {
|
|
147
147
|
for (const object of source.objects) {
|
|
148
148
|
if (object.kind !== kind)
|
|
149
149
|
continue;
|
|
150
|
-
const statement =
|
|
150
|
+
const statement = createObjectSql2(object, SCRATCH);
|
|
151
151
|
if (statement !== undefined)
|
|
152
152
|
await runner.query(statement);
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
var FUNCTION_DEFS = `
|
|
156
|
-
select
|
|
156
|
+
select p.proname as name,
|
|
157
|
+
pg_get_function_identity_arguments(p.oid) as args,
|
|
158
|
+
pg_get_functiondef(p.oid) as definition
|
|
157
159
|
from pg_proc p
|
|
158
160
|
join pg_namespace n on n.oid = p.pronamespace
|
|
159
161
|
where n.nspname = $1 and p.prokind = 'f'
|
|
160
|
-
order by p.oid
|
|
161
162
|
`;
|
|
162
163
|
async function reprintAtomicBodies(runner, source) {
|
|
163
164
|
const created = source.objects.filter((object) => object.kind === "function");
|
|
164
165
|
if (!created.some((object) => object.definition.atomic === true))
|
|
165
166
|
return source;
|
|
166
167
|
const rows = await runner.query(FUNCTION_DEFS, [SCRATCH]);
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
168
|
+
const printed = rows.map((row) => ({
|
|
169
|
+
name: cellText(row.name),
|
|
170
|
+
args: splitIdentityArguments(cellText(row.args)),
|
|
171
|
+
body: atomicBody(cellText(row.definition))
|
|
172
|
+
}));
|
|
173
|
+
const byName = new Map;
|
|
174
|
+
for (let index = 0;index < printed.length; index += 1) {
|
|
175
|
+
const name = printed[index]?.name ?? "";
|
|
176
|
+
const list = byName.get(name);
|
|
177
|
+
if (list === undefined)
|
|
178
|
+
byName.set(name, [index]);
|
|
179
|
+
else
|
|
180
|
+
list.push(index);
|
|
176
181
|
}
|
|
182
|
+
const used = new Set;
|
|
177
183
|
let changed = false;
|
|
178
184
|
const objects = source.objects.map((object) => {
|
|
179
|
-
if (object.kind !== "function")
|
|
185
|
+
if (object.kind !== "function" || object.definition.atomic !== true)
|
|
180
186
|
return object;
|
|
181
|
-
const
|
|
187
|
+
const named = byName.get(object.identity.name) ?? [];
|
|
188
|
+
const index = chooseReprint(object, printed, named, used);
|
|
189
|
+
used.add(index);
|
|
190
|
+
const body = printed[index]?.body;
|
|
182
191
|
if (body === undefined || body === object.definition.body)
|
|
183
192
|
return object;
|
|
184
193
|
changed = true;
|
|
@@ -186,6 +195,111 @@ async function reprintAtomicBodies(runner, source) {
|
|
|
186
195
|
});
|
|
187
196
|
return changed ? catalog(objects) : source;
|
|
188
197
|
}
|
|
198
|
+
function chooseReprint(object, printed, named, used) {
|
|
199
|
+
const only = named[0];
|
|
200
|
+
if (named.length === 1 && only !== undefined && !used.has(only))
|
|
201
|
+
return only;
|
|
202
|
+
const matches = named.filter((index) => {
|
|
203
|
+
const row = printed[index];
|
|
204
|
+
return row !== undefined && !used.has(index) && identityMatches(object, row.args);
|
|
205
|
+
});
|
|
206
|
+
const index = matches[0];
|
|
207
|
+
if (named.length > 1 && matches.length === 1 && index !== undefined)
|
|
208
|
+
return index;
|
|
209
|
+
throw reprintMiss(object, named.map((index) => printed[index]).filter((row) => row !== undefined));
|
|
210
|
+
}
|
|
211
|
+
function reprintMiss(object, rows) {
|
|
212
|
+
const catalog = object.identity.argTypes.join(", ");
|
|
213
|
+
const scratch = rows.length === 0 ? "(none)" : rows.map((row) => row.args.length === 0 ? "(no arguments)" : row.args.join(", ")).join("; ");
|
|
214
|
+
return new OkmError2("OKM1020", `Function ${object.identity.name}(${catalog}) was not created in the scratch schema. Catalog arguments: ${catalog}. Scratch arguments: ${scratch}.`, { fix: { summary: "The function body has to run against the tables in this schema." } });
|
|
215
|
+
}
|
|
216
|
+
function identityMatches(object, args) {
|
|
217
|
+
if (args.length !== object.identity.argTypes.length)
|
|
218
|
+
return false;
|
|
219
|
+
return args.every((printed, index) => printedHasType(object.identity.argTypes[index] ?? "", printed));
|
|
220
|
+
}
|
|
221
|
+
function splitIdentityArguments(args) {
|
|
222
|
+
const trimmed = args.trim();
|
|
223
|
+
if (trimmed.length === 0)
|
|
224
|
+
return [];
|
|
225
|
+
const parts = [];
|
|
226
|
+
let current = "";
|
|
227
|
+
let depth = 0;
|
|
228
|
+
for (const char of trimmed) {
|
|
229
|
+
if (char === "(")
|
|
230
|
+
depth += 1;
|
|
231
|
+
else if (char === ")" && depth > 0)
|
|
232
|
+
depth -= 1;
|
|
233
|
+
if (char === "," && depth === 0) {
|
|
234
|
+
parts.push(current.trim());
|
|
235
|
+
current = "";
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
current += char;
|
|
239
|
+
}
|
|
240
|
+
parts.push(current.trim());
|
|
241
|
+
return parts;
|
|
242
|
+
}
|
|
243
|
+
var ARG_TYPE_ALIASES = {
|
|
244
|
+
int: "integer",
|
|
245
|
+
int2: "smallint",
|
|
246
|
+
int4: "integer",
|
|
247
|
+
int8: "bigint",
|
|
248
|
+
bool: "boolean",
|
|
249
|
+
decimal: "numeric",
|
|
250
|
+
char: "character",
|
|
251
|
+
float4: "real",
|
|
252
|
+
float8: "double precision",
|
|
253
|
+
varchar: "character varying",
|
|
254
|
+
time: "time without time zone",
|
|
255
|
+
timetz: "time with time zone",
|
|
256
|
+
timestamp: "timestamp without time zone",
|
|
257
|
+
timestamptz: "timestamp with time zone"
|
|
258
|
+
};
|
|
259
|
+
function printedHasType(author, printed) {
|
|
260
|
+
const want = canonicalArgType(author);
|
|
261
|
+
const got = printed.trim().replaceAll(/\s+/g, " ").toLowerCase();
|
|
262
|
+
if (canonicalArgType(got) === want)
|
|
263
|
+
return true;
|
|
264
|
+
const space = got.indexOf(" ");
|
|
265
|
+
if (space < 0)
|
|
266
|
+
return false;
|
|
267
|
+
const name = got.slice(0, space);
|
|
268
|
+
if (!/^[a-z_][a-z0-9_]*$/.test(name))
|
|
269
|
+
return false;
|
|
270
|
+
return canonicalArgType(got.slice(space + 1)) === want;
|
|
271
|
+
}
|
|
272
|
+
function canonicalArgType(type) {
|
|
273
|
+
let compact = type.trim().replaceAll(/\s+/g, " ").toLowerCase();
|
|
274
|
+
const dot = compact.lastIndexOf(".");
|
|
275
|
+
if (dot >= 0)
|
|
276
|
+
compact = compact.slice(dot + 1);
|
|
277
|
+
compact = stripTypmods(compact).replaceAll(/\s+/g, " ").trim();
|
|
278
|
+
let arrays = 0;
|
|
279
|
+
while (compact.endsWith("[]")) {
|
|
280
|
+
arrays += 1;
|
|
281
|
+
compact = compact.slice(0, -2).trim();
|
|
282
|
+
}
|
|
283
|
+
const aliased = ARG_TYPE_ALIASES[compact] ?? compact;
|
|
284
|
+
return arrays === 0 ? aliased : `${aliased}${"[]".repeat(arrays)}`;
|
|
285
|
+
}
|
|
286
|
+
function stripTypmods(type) {
|
|
287
|
+
let out = "";
|
|
288
|
+
let depth = 0;
|
|
289
|
+
for (const char of type) {
|
|
290
|
+
if (char === "(") {
|
|
291
|
+
depth += 1;
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
if (char === ")" && depth > 0) {
|
|
295
|
+
depth -= 1;
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
if (depth === 0)
|
|
299
|
+
out += char;
|
|
300
|
+
}
|
|
301
|
+
return out;
|
|
302
|
+
}
|
|
189
303
|
async function createViews(runner, views) {
|
|
190
304
|
const pending = [...views];
|
|
191
305
|
let last = "";
|
|
@@ -193,7 +307,7 @@ async function createViews(runner, views) {
|
|
|
193
307
|
const failed = [];
|
|
194
308
|
let created = 0;
|
|
195
309
|
for (const object of pending) {
|
|
196
|
-
const sql = object.kind === "materializedView" ? `create materialized view ${
|
|
310
|
+
const sql = object.kind === "materializedView" ? `create materialized view ${quoteIdent2(object.identity.name)} as ${object.definition.query} with no data` : `create view ${quoteIdent2(object.identity.name)} as ${object.definition.query}`;
|
|
197
311
|
try {
|
|
198
312
|
await runner.query(sql);
|
|
199
313
|
created += 1;
|
|
@@ -213,8 +327,8 @@ async function createViews(runner, views) {
|
|
|
213
327
|
}
|
|
214
328
|
function stubTable(object, source) {
|
|
215
329
|
const columns = source.objects.filter((item) => item.kind === "column" && item.identity.parent.name === object.identity.name);
|
|
216
|
-
const lines = columns.map((column) => `${
|
|
217
|
-
return `create table ${
|
|
330
|
+
const lines = columns.map((column) => `${quoteIdent2(column.identity.name)} ${column.definition.dataType}`);
|
|
331
|
+
return `create table ${quoteIdent2(object.identity.name)} (${lines.join(", ")})`;
|
|
218
332
|
}
|
|
219
333
|
function readColumns(object, printed) {
|
|
220
334
|
const live = printed.length === 0 ? [] : printed.split(`
|
|
@@ -260,20 +374,20 @@ async function dropScratch(runner) {
|
|
|
260
374
|
for (const row of views) {
|
|
261
375
|
const kind = cellText(row.kind) === "m" ? "materialized view" : "view";
|
|
262
376
|
try {
|
|
263
|
-
await runner.query(`drop ${kind} if exists ${
|
|
377
|
+
await runner.query(`drop ${kind} if exists ${quoteIdent2(SCRATCH)}.${quoteIdent2(cellText(row.name))}`);
|
|
264
378
|
} catch {}
|
|
265
379
|
}
|
|
266
380
|
}
|
|
267
381
|
for (const row of routines) {
|
|
268
382
|
const args = cellText(row.args);
|
|
269
|
-
await runner.query(`drop function if exists ${
|
|
383
|
+
await runner.query(`drop function if exists ${quoteIdent2(SCRATCH)}.${quoteIdent2(cellText(row.name))}(${args})`);
|
|
270
384
|
}
|
|
271
385
|
for (const row of rows) {
|
|
272
386
|
if (cellText(row.kind) !== "r")
|
|
273
387
|
continue;
|
|
274
|
-
await runner.query(`drop table if exists ${
|
|
388
|
+
await runner.query(`drop table if exists ${quoteIdent2(SCRATCH)}.${quoteIdent2(cellText(row.name))}`);
|
|
275
389
|
}
|
|
276
|
-
await runner.query(`drop schema if exists ${
|
|
390
|
+
await runner.query(`drop schema if exists ${quoteIdent2(SCRATCH)} cascade`);
|
|
277
391
|
}
|
|
278
392
|
|
|
279
393
|
// src/tooling/migrate/drift.ts
|
|
@@ -290,14 +404,15 @@ async function assertAuthorDrift2(url, author, roles, allowPooler = false) {
|
|
|
290
404
|
const rows = await sql`select pg_backend_pid()::text as pid`;
|
|
291
405
|
return rows[0]?.pid ?? "";
|
|
292
406
|
}, allowPooler);
|
|
407
|
+
const schema = authorSchema(author);
|
|
293
408
|
const present = await sql`
|
|
294
|
-
select to_regclass(
|
|
409
|
+
select to_regclass(${metaReg(schema)})::text as reg
|
|
295
410
|
`;
|
|
296
411
|
if (present[0]?.reg == null)
|
|
297
412
|
return;
|
|
298
413
|
const runner = catalogQuery2(sql);
|
|
299
414
|
const authorOnServer = await sealViews(runner, author);
|
|
300
|
-
const live = await introspectSchema(runner,
|
|
415
|
+
const live = await introspectSchema(runner, schema, schema, managedRoleOptions2(roles));
|
|
301
416
|
const plan = planMigration({ before: live, after: authorOnServer, name: "check" });
|
|
302
417
|
if (plan.steps.length === 0)
|
|
303
418
|
return;
|
|
@@ -334,6 +449,19 @@ function managedRoleOptions2(roles) {
|
|
|
334
449
|
...roles?.reporting !== undefined ? { reportingRole: roles.reporting } : {}
|
|
335
450
|
};
|
|
336
451
|
}
|
|
452
|
+
function authorSchema(author) {
|
|
453
|
+
for (const object of author.objects) {
|
|
454
|
+
if (object.kind === "table" && object.owner !== "external" && object.identity.namespace.form === "static") {
|
|
455
|
+
return object.identity.namespace.name;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
return "public";
|
|
459
|
+
}
|
|
460
|
+
function metaReg(schema) {
|
|
461
|
+
if (schema === "public")
|
|
462
|
+
return "public.okm_meta";
|
|
463
|
+
return `${quoteIdent2(schema)}.okm_meta`;
|
|
464
|
+
}
|
|
337
465
|
function managedRoleNames(roles) {
|
|
338
466
|
if (roles === undefined)
|
|
339
467
|
return;
|
|
@@ -244,7 +244,7 @@ async function planInsert(table, input, options, mods, generators, scope, tenanc
|
|
|
244
244
|
keyColumns: undefined
|
|
245
245
|
};
|
|
246
246
|
}
|
|
247
|
-
const conflictMod = options.onConflict === undefined || options.onConflict === "error" ? undefined : await import("./
|
|
247
|
+
const conflictMod = options.onConflict === undefined || options.onConflict === "error" ? undefined : await import("./xwhdcrm4.js");
|
|
248
248
|
const conflict = conflictMod?.readConflict(table, options.onConflict, allow, tenantKeyList(tenancy));
|
|
249
249
|
if (conflict?.kind === "update" && traitNamed(table, "versioned")) {
|
|
250
250
|
fail2("OKM1120", `onConflict update on ${table.model.name} does not check the version you read.`, "Read the row and update. ignore and return do not change the existing row.");
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
identityColumn2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./s7he5e5d.js";
|
|
4
4
|
import {
|
|
5
5
|
runWrite
|
|
6
6
|
} from "./n4jqhpqz.js";
|
|
7
7
|
import {
|
|
8
8
|
queryHandle,
|
|
9
9
|
settleCall
|
|
10
|
-
} from "./
|
|
10
|
+
} from "./npdftanb.js";
|
|
11
11
|
import {
|
|
12
12
|
withRowFilters,
|
|
13
13
|
archiveRules,
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./cm3w0ywp.js";
|
|
5
5
|
import {
|
|
6
6
|
PgSession
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./dd5pmnky.js";
|
|
8
8
|
import {
|
|
9
9
|
isConnectionLost
|
|
10
10
|
} from "./cnkky55j.js";
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
runCall,
|
|
16
16
|
rowsFrom,
|
|
17
17
|
resultFrom
|
|
18
|
-
} from "./
|
|
18
|
+
} from "./mfvx6kjx.js";
|
|
19
19
|
|
|
20
20
|
// src/adapters/pg/postgres-extra.ts
|
|
21
21
|
var RESET_ALL = "RESET ALL";
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
open2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./dd5pmnky.js";
|
|
4
4
|
import {
|
|
5
5
|
startupHash2
|
|
6
6
|
} from "./12z7aznj.js";
|
|
7
|
+
import {
|
|
8
|
+
quoteIdent2
|
|
9
|
+
} from "./fk9vef30.js";
|
|
7
10
|
import {
|
|
8
11
|
runTarget,
|
|
9
12
|
assumeRole,
|
|
@@ -14,12 +17,12 @@ import {
|
|
|
14
17
|
provisionMark,
|
|
15
18
|
expandProvisioned,
|
|
16
19
|
installSnapshot
|
|
17
|
-
} from "./
|
|
20
|
+
} from "./3456242y.js";
|
|
18
21
|
import {
|
|
19
22
|
assertCreateRole,
|
|
20
23
|
currentUser,
|
|
21
24
|
roleExists
|
|
22
|
-
} from "./
|
|
25
|
+
} from "./jpybhf98.js";
|
|
23
26
|
import {
|
|
24
27
|
projectPath,
|
|
25
28
|
loadMigrations,
|
|
@@ -30,7 +33,7 @@ import {
|
|
|
30
33
|
projectHead,
|
|
31
34
|
loadBuiltSchema,
|
|
32
35
|
loadConfig
|
|
33
|
-
} from "./
|
|
36
|
+
} from "./2zdxkt7b.js";
|
|
34
37
|
import {
|
|
35
38
|
changesRole,
|
|
36
39
|
batchSizeField,
|
|
@@ -41,7 +44,7 @@ import {
|
|
|
41
44
|
assertDirectConnection,
|
|
42
45
|
assertStableBackend,
|
|
43
46
|
selectTarget
|
|
44
|
-
} from "./
|
|
47
|
+
} from "./6nae0spm.js";
|
|
45
48
|
import {
|
|
46
49
|
UUIDV7_POSTGRES,
|
|
47
50
|
uuidv7NeedsPostgres
|
|
@@ -198,6 +201,7 @@ async function applyTarget2(request) {
|
|
|
198
201
|
await prepareMigrationRole(connection, request, session);
|
|
199
202
|
await assertExtensionsAvailable(connection, request.migrations);
|
|
200
203
|
await assertUuidV7Available(connection, request.migrations);
|
|
204
|
+
await enterCatalogSchema(connection, request.schema ?? "public");
|
|
201
205
|
const state = request.snapshot === undefined ? undefined : await targetState(connection);
|
|
202
206
|
if (request.snapshot !== undefined && state !== undefined) {
|
|
203
207
|
if (state.kind === "empty") {
|
|
@@ -273,6 +277,7 @@ nothing to apply
|
|
|
273
277
|
reference: built === undefined ? [] : readReference(built.tables, built.casing, head.catalog)
|
|
274
278
|
},
|
|
275
279
|
...config.roles !== undefined ? { migrationRole: config.roles.migration, appRole: config.roles.app } : {},
|
|
280
|
+
...catalogSchema(config.namespace),
|
|
276
281
|
lintDirectory: directory,
|
|
277
282
|
onProgress: (line) => {
|
|
278
283
|
if (write !== undefined)
|
|
@@ -299,6 +304,7 @@ async function pushProject2(cwd, flags) {
|
|
|
299
304
|
after: head.catalog,
|
|
300
305
|
renames: head.renames,
|
|
301
306
|
name: "push",
|
|
307
|
+
...catalogSchema(config.namespace),
|
|
302
308
|
...batchSizeField(config.backfill?.batchSize)
|
|
303
309
|
});
|
|
304
310
|
if (plan.steps.length === 0)
|
|
@@ -319,7 +325,8 @@ no changes
|
|
|
319
325
|
steps: plan.steps
|
|
320
326
|
}
|
|
321
327
|
],
|
|
322
|
-
...config.roles !== undefined ? { migrationRole: config.roles.migration, appRole: config.roles.app } : {}
|
|
328
|
+
...config.roles !== undefined ? { migrationRole: config.roles.migration, appRole: config.roles.app } : {},
|
|
329
|
+
...catalogSchema(config.namespace)
|
|
323
330
|
});
|
|
324
331
|
return formatReport(report);
|
|
325
332
|
}
|
|
@@ -514,6 +521,17 @@ async function insertReference(connection, request) {
|
|
|
514
521
|
function concreteSchema(request) {
|
|
515
522
|
return request.searchPath ?? request.schema ?? "public";
|
|
516
523
|
}
|
|
524
|
+
function catalogSchema(namespace) {
|
|
525
|
+
if (namespace === undefined || namespace === "public")
|
|
526
|
+
return;
|
|
527
|
+
return { schema: namespace };
|
|
528
|
+
}
|
|
529
|
+
async function enterCatalogSchema(connection, schema) {
|
|
530
|
+
if (schema === "public")
|
|
531
|
+
return;
|
|
532
|
+
await connection.execute(`create schema if not exists ${quoteIdent2(schema)}`);
|
|
533
|
+
await connection.execute(`set search_path to ${quoteIdent2(schema)}`);
|
|
534
|
+
}
|
|
517
535
|
async function targetState(connection) {
|
|
518
536
|
const meta = await connection.execute(`select to_regclass('okm_meta') is not null
|
|
519
537
|
or to_regclass('okm_history') is not null
|
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
send2,
|
|
6
6
|
reserve,
|
|
7
7
|
park
|
|
8
|
-
} from "./
|
|
8
|
+
} from "./62b603gr.js";
|
|
9
9
|
import {
|
|
10
10
|
resetSession2,
|
|
11
11
|
refuseWhenLost2
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./99qp9vtg.js";
|
|
13
13
|
import {
|
|
14
14
|
cursorStream
|
|
15
15
|
} from "./7kms6fvj.js";
|
|
@@ -18,14 +18,14 @@ import {
|
|
|
18
18
|
} from "./cnkky55j.js";
|
|
19
19
|
import {
|
|
20
20
|
noTimeout
|
|
21
|
-
} from "./
|
|
21
|
+
} from "./tr64w5p0.js";
|
|
22
22
|
import {
|
|
23
23
|
WireSession
|
|
24
|
-
} from "./
|
|
24
|
+
} from "./e275q7sd.js";
|
|
25
25
|
import {
|
|
26
26
|
rejectClosed,
|
|
27
27
|
runCall
|
|
28
|
-
} from "./
|
|
28
|
+
} from "./mfvx6kjx.js";
|
|
29
29
|
|
|
30
30
|
// src/adapters/pg/bunsql-extra.ts
|
|
31
31
|
async function recover(sql, error, text, depth, clientRead, closedDuring, again) {
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
assertAuthorDrift2,
|
|
3
3
|
catalogQuery2,
|
|
4
4
|
managedRoleOptions2
|
|
5
|
-
} from "./
|
|
6
|
-
import"./
|
|
7
|
-
import"./
|
|
8
|
-
import"./
|
|
5
|
+
} from "./90sg0w5a.js";
|
|
6
|
+
import"./myk8fswx.js";
|
|
7
|
+
import"./6nae0spm.js";
|
|
8
|
+
import"./fk9vef30.js";
|
|
9
9
|
import"./12z7aznj.js";
|
|
10
10
|
export {
|
|
11
11
|
assertAuthorDrift2 as assertAuthorDrift,
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
runCall,
|
|
7
7
|
EMPTY_NOTICES,
|
|
8
8
|
resultFrom
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./mfvx6kjx.js";
|
|
10
10
|
|
|
11
11
|
// src/adapters/pg/postgresjs.ts
|
|
12
12
|
import net from "node:net";
|
|
@@ -118,17 +118,17 @@ function open2(config) {
|
|
|
118
118
|
return sockets.occupy(() => runCall(closed, options, (watch) => root.query(text, params, watch)));
|
|
119
119
|
},
|
|
120
120
|
batch(statements, options) {
|
|
121
|
-
return sockets.occupy(() => import("./
|
|
121
|
+
return sockets.occupy(() => import("./fdsz3w80.js").then((mod) => mod.runBatch(held, statements, options)));
|
|
122
122
|
},
|
|
123
123
|
reserve() {
|
|
124
124
|
const gate = sockets.busyGate();
|
|
125
125
|
gate.enter();
|
|
126
|
-
return import("./
|
|
126
|
+
return import("./fdsz3w80.js").then((mod) => mod.holdCheckout(gate, () => mod.checkout(held)), (error) => {
|
|
127
127
|
gate.leave();
|
|
128
128
|
throw error;
|
|
129
129
|
});
|
|
130
130
|
},
|
|
131
|
-
describe: (text, params) => sockets.occupy(() => import("./
|
|
131
|
+
describe: (text, params) => sockets.occupy(() => import("./fdsz3w80.js").then((mod) => mod.describe(sql, text, params))),
|
|
132
132
|
stream(text, params) {
|
|
133
133
|
const gate = sockets.busyGate();
|
|
134
134
|
return async function* () {
|
|
@@ -143,7 +143,7 @@ function open2(config) {
|
|
|
143
143
|
listen(channel, onNotify) {
|
|
144
144
|
const gate = sockets.listenerGate();
|
|
145
145
|
gate.enter();
|
|
146
|
-
return import("./
|
|
146
|
+
return import("./fdsz3w80.js").then((mod) => mod.holdListener(gate, async () => {
|
|
147
147
|
const listening = await sql.listen(channel, onNotify);
|
|
148
148
|
return async () => {
|
|
149
149
|
await listening.unlisten();
|
|
@@ -213,7 +213,7 @@ class PgSession {
|
|
|
213
213
|
onAbort();
|
|
214
214
|
else
|
|
215
215
|
watch.signal.addEventListener("abort", onAbort, { once: true });
|
|
216
|
-
return import("./
|
|
216
|
+
return import("./fdsz3w80.js").then((mod) => mod.watchQuery(pending, watch, onAbort, {
|
|
217
217
|
start,
|
|
218
218
|
text,
|
|
219
219
|
notices: this.notices,
|
|
@@ -265,7 +265,7 @@ class PgSession {
|
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
267
|
async function* loadStream(sql, text, params) {
|
|
268
|
-
const { stream } = await import("./
|
|
268
|
+
const { stream } = await import("./fdsz3w80.js");
|
|
269
269
|
yield* stream(sql, text, params);
|
|
270
270
|
}
|
|
271
271
|
function send(sql, text, params, named) {
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
armDriverError,
|
|
6
6
|
send,
|
|
7
7
|
connectClient
|
|
8
|
-
} from "./
|
|
8
|
+
} from "./1mxm04fy.js";
|
|
9
9
|
import {
|
|
10
10
|
resetSession2
|
|
11
|
-
} from "./
|
|
11
|
+
} from "./99qp9vtg.js";
|
|
12
12
|
import {
|
|
13
13
|
cursorStream
|
|
14
14
|
} from "./7kms6fvj.js";
|
|
@@ -17,11 +17,11 @@ import {
|
|
|
17
17
|
} from "./cnkky55j.js";
|
|
18
18
|
import {
|
|
19
19
|
WireSession
|
|
20
|
-
} from "./
|
|
20
|
+
} from "./e275q7sd.js";
|
|
21
21
|
import {
|
|
22
22
|
rejectClosed,
|
|
23
23
|
runCall
|
|
24
|
-
} from "./
|
|
24
|
+
} from "./mfvx6kjx.js";
|
|
25
25
|
|
|
26
26
|
// src/adapters/pg/nodepostgres-extra.ts
|
|
27
27
|
async function checkout(held) {
|