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,25 +3,25 @@ import {
|
|
|
3
3
|
renameColumn2,
|
|
4
4
|
renameTable2
|
|
5
5
|
} from "./12z7aznj.js";
|
|
6
|
+
import {
|
|
7
|
+
quoteIdent2,
|
|
8
|
+
uniqueBeforeForeignKey2,
|
|
9
|
+
ownedByView2,
|
|
10
|
+
dropObjectSql2,
|
|
11
|
+
createObjectSql2,
|
|
12
|
+
functionSql2,
|
|
13
|
+
viewSql2,
|
|
14
|
+
policyCreatePlan2,
|
|
15
|
+
policyDropPlan2,
|
|
16
|
+
refreshMaterializedViewSql2,
|
|
17
|
+
alterColumnSql2,
|
|
18
|
+
identitySequence2,
|
|
19
|
+
createTableSql2,
|
|
20
|
+
qualify2
|
|
21
|
+
} from "./fk9vef30.js";
|
|
6
22
|
import {
|
|
7
23
|
isConnectionLost
|
|
8
24
|
} from "./cnkky55j.js";
|
|
9
|
-
import {
|
|
10
|
-
quoteIdent,
|
|
11
|
-
uniqueBeforeForeignKey,
|
|
12
|
-
ownedByView,
|
|
13
|
-
dropObjectSql,
|
|
14
|
-
createObjectSql,
|
|
15
|
-
functionSql,
|
|
16
|
-
viewSql,
|
|
17
|
-
policyCreatePlan,
|
|
18
|
-
policyDropPlan,
|
|
19
|
-
refreshMaterializedViewSql,
|
|
20
|
-
alterColumnSql,
|
|
21
|
-
identitySequence,
|
|
22
|
-
createTableSql,
|
|
23
|
-
qualify
|
|
24
|
-
} from "./sjk86yrx.js";
|
|
25
25
|
import {
|
|
26
26
|
isDomain,
|
|
27
27
|
sameEnumLabels
|
|
@@ -366,6 +366,67 @@ function isEscapeString(sql, index) {
|
|
|
366
366
|
return false;
|
|
367
367
|
return true;
|
|
368
368
|
}
|
|
369
|
+
function sqlIdentifiers(sql) {
|
|
370
|
+
const names = [];
|
|
371
|
+
let index = 0;
|
|
372
|
+
while (index < sql.length) {
|
|
373
|
+
if (sql.startsWith("--", index)) {
|
|
374
|
+
index = lineCommentEnd(sql, index + 2);
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
if (sql.startsWith("/*", index)) {
|
|
378
|
+
const block = blockComment(sql, index + 2);
|
|
379
|
+
index = block.index;
|
|
380
|
+
if (block.open)
|
|
381
|
+
break;
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
const dollar = dollarAt(sql, index);
|
|
385
|
+
if (dollar !== undefined) {
|
|
386
|
+
const closed = takeDollar(sql, dollar);
|
|
387
|
+
index = closed.index;
|
|
388
|
+
if (closed.open)
|
|
389
|
+
break;
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
if (isEscapeString(sql, index)) {
|
|
393
|
+
const quote = takeQuoted(sql, index + 2, true);
|
|
394
|
+
index = quote.index;
|
|
395
|
+
if (quote.open)
|
|
396
|
+
break;
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
const char = sql[index];
|
|
400
|
+
if (char === "'") {
|
|
401
|
+
const quote = takeQuoted(sql, index + 1, false);
|
|
402
|
+
index = quote.index;
|
|
403
|
+
if (quote.open)
|
|
404
|
+
break;
|
|
405
|
+
continue;
|
|
406
|
+
}
|
|
407
|
+
if (char === '"') {
|
|
408
|
+
const quote = takeIdent(sql, index + 1);
|
|
409
|
+
if (!quote.open) {
|
|
410
|
+
names.push({ text: unescapeIdent(sql.slice(index + 1, quote.index - 1)), quoted: true });
|
|
411
|
+
}
|
|
412
|
+
index = quote.index;
|
|
413
|
+
if (quote.open)
|
|
414
|
+
break;
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
if (isIdentStart(sql.charCodeAt(index))) {
|
|
418
|
+
const word = readWord(sql, index);
|
|
419
|
+
names.push({ text: word, quoted: false });
|
|
420
|
+
index += word.length;
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
423
|
+
index += 1;
|
|
424
|
+
}
|
|
425
|
+
return names;
|
|
426
|
+
}
|
|
427
|
+
function unescapeIdent(text) {
|
|
428
|
+
return text.replaceAll('""', '"');
|
|
429
|
+
}
|
|
369
430
|
function isIdentStart(code) {
|
|
370
431
|
return code >= 65 && code <= 90 || code >= 97 && code <= 122 || code === 95;
|
|
371
432
|
}
|
|
@@ -522,10 +583,10 @@ function index(objects) {
|
|
|
522
583
|
return by;
|
|
523
584
|
}
|
|
524
585
|
function createRoleSql(object) {
|
|
525
|
-
return `create role ${
|
|
586
|
+
return `create role ${quoteIdent2(object.identity.name)} with nosuperuser nocreatedb nocreaterole ${inherit(object)} ${login(object)}`;
|
|
526
587
|
}
|
|
527
588
|
function alterRoleSql(object) {
|
|
528
|
-
return `alter role ${
|
|
589
|
+
return `alter role ${quoteIdent2(object.identity.name)} with ${inherit(object)} ${login(object)}`;
|
|
529
590
|
}
|
|
530
591
|
function login(object) {
|
|
531
592
|
return object.definition.login ? "login" : "nologin";
|
|
@@ -541,7 +602,7 @@ function tightenColumnSelect(object, after, schema) {
|
|
|
541
602
|
if (covered)
|
|
542
603
|
return;
|
|
543
604
|
return {
|
|
544
|
-
sql: `revoke select on ${grantTarget(target, schema)} from ${
|
|
605
|
+
sql: `revoke select on ${grantTarget(target, schema)} from ${quoteIdent2(object.identity.role)}`,
|
|
545
606
|
kind: "revoke"
|
|
546
607
|
};
|
|
547
608
|
}
|
|
@@ -555,7 +616,7 @@ function revokeMatviewWrites(object, after, schema) {
|
|
|
555
616
|
if (!inheritsWrites)
|
|
556
617
|
return;
|
|
557
618
|
return {
|
|
558
|
-
sql: `revoke insert, update, delete on ${grantTarget(target, schema)} from ${
|
|
619
|
+
sql: `revoke insert, update, delete on ${grantTarget(target, schema)} from ${quoteIdent2(object.identity.role)}`,
|
|
559
620
|
kind: "revoke"
|
|
560
621
|
};
|
|
561
622
|
}
|
|
@@ -565,11 +626,11 @@ function grantStatement(object, schema, revoke) {
|
|
|
565
626
|
const verb = revoke ? "revoke" : "grant";
|
|
566
627
|
const direction = revoke ? "from" : "to";
|
|
567
628
|
const target = grantTarget(object.identity.object, schema);
|
|
568
|
-
const role =
|
|
629
|
+
const role = quoteIdent2(object.identity.role);
|
|
569
630
|
const listed = column?.[2];
|
|
570
631
|
const base = column?.[1];
|
|
571
632
|
if (listed !== undefined && base !== undefined) {
|
|
572
|
-
const names = listed.split(",").filter((name) => name.length > 0).map((name) =>
|
|
633
|
+
const names = listed.split(",").filter((name) => name.length > 0).map((name) => quoteIdent2(name)).join(", ");
|
|
573
634
|
return `${verb} ${base.toLowerCase()} (${names}) on ${target} ${direction} ${role}`;
|
|
574
635
|
}
|
|
575
636
|
const keyword = privilege.toLowerCase();
|
|
@@ -581,7 +642,7 @@ function defaultStatement(object, schema, revoke) {
|
|
|
581
642
|
assertPrivilege(privilege);
|
|
582
643
|
const verb = revoke ? "revoke" : "grant";
|
|
583
644
|
const direction = revoke ? "from" : "to";
|
|
584
|
-
return `alter default privileges for role ${
|
|
645
|
+
return `alter default privileges for role ${quoteIdent2(object.identity.forRole)} in schema ${quoteIdent2(schema)} ${verb} ${privilege} on ${objectKindSql(object.identity.objectKind)} ${direction} ${quoteIdent2(object.identity.grantee)}`;
|
|
585
646
|
}
|
|
586
647
|
function grantTargetKey(object) {
|
|
587
648
|
if (object.kind === "table" || object.kind === "view" || object.kind === "materializedView" || object.kind === "sequence") {
|
|
@@ -603,20 +664,20 @@ function grantTargetKey(object) {
|
|
|
603
664
|
}
|
|
604
665
|
function grantTarget(object, schema) {
|
|
605
666
|
if (object.kind === "sequence")
|
|
606
|
-
return `sequence ${
|
|
667
|
+
return `sequence ${qualify2(schema, object.name)}`;
|
|
607
668
|
if (object.kind === "function")
|
|
608
669
|
return functionTarget(object.name, schema);
|
|
609
670
|
if (object.kind === "namespace")
|
|
610
|
-
return `schema ${
|
|
611
|
-
return `table ${
|
|
671
|
+
return `schema ${quoteIdent2(schema)}`;
|
|
672
|
+
return `table ${qualify2(schema, object.name)}`;
|
|
612
673
|
}
|
|
613
674
|
function functionTarget(name, schema) {
|
|
614
675
|
const open = name.lastIndexOf("(");
|
|
615
676
|
if (open < 0 || !name.endsWith(")"))
|
|
616
|
-
return `function ${
|
|
677
|
+
return `function ${qualify2(schema, name)}()`;
|
|
617
678
|
const fn = name.slice(0, open);
|
|
618
679
|
const args = name.slice(open + 1, -1);
|
|
619
|
-
return `function ${
|
|
680
|
+
return `function ${qualify2(schema, fn)}(${args})`;
|
|
620
681
|
}
|
|
621
682
|
function objectKindSql(kind) {
|
|
622
683
|
if (kind === "function")
|
|
@@ -713,7 +774,7 @@ function keyOn(source, table) {
|
|
|
713
774
|
if (column === undefined || column.kind !== "column") {
|
|
714
775
|
throw new OkmError2("OKM1546", `Table ${table} primary key column ${name} is not in the catalog.`, { fix: { summary: "Keep the primary key columns on the table." } });
|
|
715
776
|
}
|
|
716
|
-
columns.push({ quoted:
|
|
777
|
+
columns.push({ quoted: quoteIdent2(name), dataType: column.definition.dataType });
|
|
717
778
|
}
|
|
718
779
|
if (columns.length === 0)
|
|
719
780
|
return;
|
|
@@ -777,7 +838,7 @@ function splitKey(text) {
|
|
|
777
838
|
}
|
|
778
839
|
if (!closed)
|
|
779
840
|
return [];
|
|
780
|
-
names.push(
|
|
841
|
+
names.push(quoteIdent2(value));
|
|
781
842
|
if (text[index] === ",")
|
|
782
843
|
index += 1;
|
|
783
844
|
continue;
|
|
@@ -787,7 +848,7 @@ function splitKey(text) {
|
|
|
787
848
|
const raw = text.slice(index, end);
|
|
788
849
|
if (raw.length === 0)
|
|
789
850
|
return [];
|
|
790
|
-
names.push(
|
|
851
|
+
names.push(quoteIdent2(raw));
|
|
791
852
|
index = comma === -1 ? text.length : comma + 1;
|
|
792
853
|
}
|
|
793
854
|
return names;
|
|
@@ -961,7 +1022,7 @@ function refuseDrops(beforeBy, afterBy, dropKeys) {
|
|
|
961
1022
|
}
|
|
962
1023
|
function alterExtension(before, after) {
|
|
963
1024
|
const steps = [];
|
|
964
|
-
const name =
|
|
1025
|
+
const name = quoteIdent2(after.identity.name);
|
|
965
1026
|
if (before.definition.schema !== after.definition.schema) {
|
|
966
1027
|
if (!after.definition.relocatable) {
|
|
967
1028
|
throw new OkmError2("OKM1814", `Extension ${after.identity.name} is not relocatable, so it cannot move to ${after.definition.schema}.`, {
|
|
@@ -970,7 +1031,7 @@ function alterExtension(before, after) {
|
|
|
970
1031
|
}
|
|
971
1032
|
});
|
|
972
1033
|
}
|
|
973
|
-
steps.push(extensionStep(`alter extension ${name} set schema ${
|
|
1034
|
+
steps.push(extensionStep(`alter extension ${name} set schema ${quoteIdent2(after.definition.schema)}`, "move-extension"));
|
|
974
1035
|
}
|
|
975
1036
|
const previous = before.definition.version;
|
|
976
1037
|
const next = after.definition.version;
|
|
@@ -1151,9 +1212,9 @@ function stepsForExistingTable(object, schema, catalogs, batchSize) {
|
|
|
1151
1212
|
function notNullSteps(column, schema, setKind, catalogs) {
|
|
1152
1213
|
const tableName = column.identity.parent.name;
|
|
1153
1214
|
const columnName = column.identity.name;
|
|
1154
|
-
const table =
|
|
1155
|
-
const quotedColumn =
|
|
1156
|
-
const constraint =
|
|
1215
|
+
const table = qualify2(schema, tableName);
|
|
1216
|
+
const quotedColumn = quoteIdent2(columnName);
|
|
1217
|
+
const constraint = quoteIdent2(notNullConstraintName(tableName, columnName, catalogs));
|
|
1157
1218
|
return [
|
|
1158
1219
|
{
|
|
1159
1220
|
sql: `alter table ${table} add constraint ${constraint} check (${quotedColumn} is not null) not valid`,
|
|
@@ -1216,7 +1277,7 @@ function volatileDefault(expression, catalogs) {
|
|
|
1216
1277
|
return false;
|
|
1217
1278
|
}
|
|
1218
1279
|
function concurrentIndexStep(object, schema) {
|
|
1219
|
-
const plain =
|
|
1280
|
+
const plain = createObjectSql2(object, schema) ?? "";
|
|
1220
1281
|
return {
|
|
1221
1282
|
sql: concurrentIndexSql(plain),
|
|
1222
1283
|
kind: "create-index",
|
|
@@ -1232,13 +1293,13 @@ function constraintSteps(object, schema) {
|
|
|
1232
1293
|
return notValidSteps(object, schema);
|
|
1233
1294
|
}
|
|
1234
1295
|
function notValidSteps(object, schema) {
|
|
1235
|
-
const plain =
|
|
1296
|
+
const plain = createObjectSql2(object, schema);
|
|
1236
1297
|
if (plain === undefined)
|
|
1237
1298
|
return [];
|
|
1238
|
-
const table =
|
|
1239
|
-
const name =
|
|
1299
|
+
const table = qualify2(schema, object.identity.parent.name);
|
|
1300
|
+
const name = quoteIdent2(object.identity.name);
|
|
1240
1301
|
const referenced = object.definition.references;
|
|
1241
|
-
const referencedLock = referenced === undefined ? undefined :
|
|
1302
|
+
const referencedLock = referenced === undefined ? undefined : qualify2(schema, referenced.parent.name);
|
|
1242
1303
|
return [
|
|
1243
1304
|
{
|
|
1244
1305
|
sql: `${plain} not valid`,
|
|
@@ -1257,9 +1318,9 @@ function notValidSteps(object, schema) {
|
|
|
1257
1318
|
];
|
|
1258
1319
|
}
|
|
1259
1320
|
function usingIndexSteps(object, schema) {
|
|
1260
|
-
const table =
|
|
1261
|
-
const name =
|
|
1262
|
-
const columns = object.definition.columns.map((column) =>
|
|
1321
|
+
const table = qualify2(schema, object.identity.parent.name);
|
|
1322
|
+
const name = quoteIdent2(object.identity.name);
|
|
1323
|
+
const columns = object.definition.columns.map((column) => quoteIdent2(column)).join(", ");
|
|
1263
1324
|
const nulls = object.definition.nullsNotDistinct ? " nulls not distinct" : "";
|
|
1264
1325
|
const verb = object.definition.constraintKind === "primaryKey" ? "primary key" : "unique";
|
|
1265
1326
|
const defer = object.definition.deferrable ? ` deferrable initially ${object.definition.initially}` : "";
|
|
@@ -1282,9 +1343,9 @@ function usingIndexSteps(object, schema) {
|
|
|
1282
1343
|
}
|
|
1283
1344
|
function volatileColumnSteps(column, schema, catalogs, batchSize) {
|
|
1284
1345
|
const tableName = column.identity.parent.name;
|
|
1285
|
-
const table =
|
|
1286
|
-
const name =
|
|
1287
|
-
const collate = column.definition.collation === undefined ? "" : ` collate ${
|
|
1346
|
+
const table = qualify2(schema, tableName);
|
|
1347
|
+
const name = quoteIdent2(column.identity.name);
|
|
1348
|
+
const collate = column.definition.collation === undefined ? "" : ` collate ${quoteIdent2(column.definition.collation)}`;
|
|
1288
1349
|
const expression = column.definition.defaultExpression ?? "";
|
|
1289
1350
|
const key = primaryKeyColumns(catalogs, tableName);
|
|
1290
1351
|
const backfill = {
|
|
@@ -1539,12 +1600,12 @@ function planMigration(input) {
|
|
|
1539
1600
|
const deferred = new Set(picklists.map((change) => identityKey2(change.before.identity)));
|
|
1540
1601
|
const typeDrops = [];
|
|
1541
1602
|
const extensionDrops = [];
|
|
1542
|
-
const reverse = [...
|
|
1603
|
+
const reverse = [...uniqueBeforeForeignKey2(creationOrder2(renamed))].reverse();
|
|
1543
1604
|
const emitDrop = (object) => {
|
|
1544
1605
|
const key = identityKey2(object.identity);
|
|
1545
1606
|
if (!dropKeys.has(key) || deferred.has(key) || covered(object, droppedTables))
|
|
1546
1607
|
return;
|
|
1547
|
-
const sql =
|
|
1608
|
+
const sql = dropObjectSql2(object, schema);
|
|
1548
1609
|
const kind = dropKind(object);
|
|
1549
1610
|
if (sql === undefined || kind === undefined)
|
|
1550
1611
|
return;
|
|
@@ -1566,7 +1627,7 @@ function planMigration(input) {
|
|
|
1566
1627
|
if (object.kind === "function")
|
|
1567
1628
|
emitDrop(object);
|
|
1568
1629
|
for (const object of reverse)
|
|
1569
|
-
if (
|
|
1630
|
+
if (ownedByView2(object))
|
|
1570
1631
|
emitDrop(object);
|
|
1571
1632
|
for (const object of reverse) {
|
|
1572
1633
|
if (object.kind === "view" || object.kind === "materializedView")
|
|
@@ -1578,12 +1639,12 @@ function planMigration(input) {
|
|
|
1578
1639
|
const key = identityKey2(object.identity);
|
|
1579
1640
|
if (!dropKeys.has(key) || deferred.has(key))
|
|
1580
1641
|
continue;
|
|
1581
|
-
for (const item of
|
|
1642
|
+
for (const item of policyDropPlan2(object, schema)) {
|
|
1582
1643
|
steps.push(step(item.sql, item.kind, "ddl", ACCESS2, true, [object.identity.parent.name]));
|
|
1583
1644
|
}
|
|
1584
1645
|
}
|
|
1585
1646
|
for (const object of reverse) {
|
|
1586
|
-
if (object.kind === "trigger" || object.kind === "function" || object.kind === "view" || object.kind === "materializedView" || object.kind === "policy" ||
|
|
1647
|
+
if (object.kind === "trigger" || object.kind === "function" || object.kind === "view" || object.kind === "materializedView" || object.kind === "policy" || ownedByView2(object)) {
|
|
1587
1648
|
continue;
|
|
1588
1649
|
}
|
|
1589
1650
|
const key = identityKey2(object.identity);
|
|
@@ -1606,7 +1667,7 @@ function planMigration(input) {
|
|
|
1606
1667
|
steps.push(...extensionAlterSteps(beforeBy, afterBy, dropKeys));
|
|
1607
1668
|
for (const change of alters) {
|
|
1608
1669
|
const aligned = alignedColumnType(change.before, change.after);
|
|
1609
|
-
const statements =
|
|
1670
|
+
const statements = alterColumnSql2(aligned, change.after, schema);
|
|
1610
1671
|
const kinds = columnAlterKinds(aligned, change.after);
|
|
1611
1672
|
for (let index = 0;index < statements.length; index += 1) {
|
|
1612
1673
|
const sql = statements[index];
|
|
@@ -1636,7 +1697,7 @@ function planMigration(input) {
|
|
|
1636
1697
|
if (!createKeys.has(key) || emitted.has(key))
|
|
1637
1698
|
continue;
|
|
1638
1699
|
emitted.add(key);
|
|
1639
|
-
const sql =
|
|
1700
|
+
const sql = createObjectSql2(object, schema);
|
|
1640
1701
|
const kind = createKind(object, false);
|
|
1641
1702
|
if (sql === undefined || kind === undefined)
|
|
1642
1703
|
continue;
|
|
@@ -1649,14 +1710,14 @@ function planMigration(input) {
|
|
|
1649
1710
|
if (!createKeys.has(key) || emitted.has(key))
|
|
1650
1711
|
continue;
|
|
1651
1712
|
emitted.add(key);
|
|
1652
|
-
const sql =
|
|
1713
|
+
const sql = createObjectSql2(object, schema);
|
|
1653
1714
|
const kind = createKind(object, false);
|
|
1654
1715
|
if (sql === undefined || kind === undefined)
|
|
1655
1716
|
continue;
|
|
1656
1717
|
steps.push(step(sql, kind, "ddl", ACCESS2));
|
|
1657
1718
|
}
|
|
1658
|
-
for (const object of
|
|
1659
|
-
if (object.kind === "type" || object.kind === "extension" || object.kind === "function" || object.kind === "trigger" || object.kind === "view" || object.kind === "materializedView" || object.kind === "policy" ||
|
|
1719
|
+
for (const object of uniqueBeforeForeignKey2(creationOrder2(request.after))) {
|
|
1720
|
+
if (object.kind === "type" || object.kind === "extension" || object.kind === "function" || object.kind === "trigger" || object.kind === "view" || object.kind === "materializedView" || object.kind === "policy" || ownedByView2(object)) {
|
|
1660
1721
|
continue;
|
|
1661
1722
|
}
|
|
1662
1723
|
const key = identityKey2(object.identity);
|
|
@@ -1671,10 +1732,10 @@ function planMigration(input) {
|
|
|
1671
1732
|
continue;
|
|
1672
1733
|
emitted.add(key);
|
|
1673
1734
|
if (object.kind === "table") {
|
|
1674
|
-
steps.push(step(
|
|
1735
|
+
steps.push(step(createTableSql2(object, request.after, schema), "create-table", "ddl", ACCESS2));
|
|
1675
1736
|
continue;
|
|
1676
1737
|
}
|
|
1677
|
-
const sql =
|
|
1738
|
+
const sql = createObjectSql2(object, schema);
|
|
1678
1739
|
const kind = createKind(object, tableIsNew);
|
|
1679
1740
|
if (sql === undefined || kind === undefined)
|
|
1680
1741
|
continue;
|
|
@@ -1694,7 +1755,7 @@ function planMigration(input) {
|
|
|
1694
1755
|
if (!createKeys.has(key) || emitted.has(key))
|
|
1695
1756
|
continue;
|
|
1696
1757
|
emitted.add(key);
|
|
1697
|
-
for (const item of
|
|
1758
|
+
for (const item of policyCreatePlan2(object, schema)) {
|
|
1698
1759
|
steps.push(step(item.sql, item.kind, "ddl", ACCESS2, true, [object.identity.parent.name]));
|
|
1699
1760
|
}
|
|
1700
1761
|
}
|
|
@@ -1704,7 +1765,7 @@ function planMigration(input) {
|
|
|
1704
1765
|
const key = identityKey2(change.after.identity);
|
|
1705
1766
|
if (dropKeys.has(key) && createKeys.has(key))
|
|
1706
1767
|
continue;
|
|
1707
|
-
const sql = change.kind === "function" ?
|
|
1768
|
+
const sql = change.kind === "function" ? functionSql2(change.after, schema, true) : viewSql2(change.after, schema, true);
|
|
1708
1769
|
const kind = change.kind === "function" ? "replace-function" : "replace-view";
|
|
1709
1770
|
steps.push({
|
|
1710
1771
|
sql,
|
|
@@ -1724,7 +1785,7 @@ function planMigration(input) {
|
|
|
1724
1785
|
if (!createKeys.has(key) || emitted.has(key))
|
|
1725
1786
|
continue;
|
|
1726
1787
|
emitted.add(key);
|
|
1727
|
-
const sql =
|
|
1788
|
+
const sql = createObjectSql2(object, schema);
|
|
1728
1789
|
const created = createKind(object, false);
|
|
1729
1790
|
if (sql === undefined || created === undefined)
|
|
1730
1791
|
continue;
|
|
@@ -1732,13 +1793,13 @@ function planMigration(input) {
|
|
|
1732
1793
|
}
|
|
1733
1794
|
}
|
|
1734
1795
|
for (const object of creationOrder2(request.after)) {
|
|
1735
|
-
if (!
|
|
1796
|
+
if (!ownedByView2(object))
|
|
1736
1797
|
continue;
|
|
1737
1798
|
const key = identityKey2(object.identity);
|
|
1738
1799
|
if (!createKeys.has(key) || emitted.has(key))
|
|
1739
1800
|
continue;
|
|
1740
1801
|
emitted.add(key);
|
|
1741
|
-
const sql =
|
|
1802
|
+
const sql = createObjectSql2(object, schema);
|
|
1742
1803
|
const kind = createKind(object, false);
|
|
1743
1804
|
if (sql === undefined || kind === undefined)
|
|
1744
1805
|
continue;
|
|
@@ -1751,7 +1812,7 @@ function planMigration(input) {
|
|
|
1751
1812
|
if (!createKeys.has(key))
|
|
1752
1813
|
continue;
|
|
1753
1814
|
assertConcurrentRefresh(object, request.after);
|
|
1754
|
-
steps.push(step(
|
|
1815
|
+
steps.push(step(refreshMaterializedViewSql2(object, schema, false), "refresh-matview", "backfill", ACCESS2));
|
|
1755
1816
|
}
|
|
1756
1817
|
for (const item of privileges.grant)
|
|
1757
1818
|
steps.push(step(item.sql, item.kind, "ddl", ACCESS2));
|
|
@@ -1942,7 +2003,7 @@ function renameSteps(source, renames, schema) {
|
|
|
1942
2003
|
if (rename.kind !== "table" || !hasTable(source, rename.from))
|
|
1943
2004
|
continue;
|
|
1944
2005
|
tables.set(rename.to, rename.from);
|
|
1945
|
-
steps.push(step(`alter table ${
|
|
2006
|
+
steps.push(step(`alter table ${qualify2(schema, rename.from)} rename to ${quoteIdent2(rename.to)}`, "rename-table", "ddl", ACCESS2));
|
|
1946
2007
|
steps.push(...sequenceRenames(source, rename, schema));
|
|
1947
2008
|
}
|
|
1948
2009
|
for (const rename of renames) {
|
|
@@ -1951,7 +2012,7 @@ function renameSteps(source, renames, schema) {
|
|
|
1951
2012
|
const previousTable = tables.get(rename.table) ?? rename.table;
|
|
1952
2013
|
if (!hasColumn(source, previousTable, rename.from))
|
|
1953
2014
|
continue;
|
|
1954
|
-
steps.push(step(`alter table ${
|
|
2015
|
+
steps.push(step(`alter table ${qualify2(schema, rename.table)} rename column ${quoteIdent2(rename.from)} to ${quoteIdent2(rename.to)}`, "rename-column", "ddl", ACCESS2));
|
|
1955
2016
|
}
|
|
1956
2017
|
return steps;
|
|
1957
2018
|
}
|
|
@@ -1969,7 +2030,7 @@ function sequenceRenames(source, rename, schema) {
|
|
|
1969
2030
|
const owned = source.objects.some((item) => item.kind === "sequence" && item.identity.name === fromName);
|
|
1970
2031
|
if (!owned)
|
|
1971
2032
|
continue;
|
|
1972
|
-
steps.push(step(`alter sequence ${
|
|
2033
|
+
steps.push(step(`alter sequence ${qualify2(schema, fromName)} rename to ${quoteIdent2(toName)}`, "rename-sequence", "ddl", ACCESS2));
|
|
1973
2034
|
}
|
|
1974
2035
|
return steps;
|
|
1975
2036
|
}
|
|
@@ -2018,14 +2079,14 @@ function withoutNameKey(value) {
|
|
|
2018
2079
|
}
|
|
2019
2080
|
function renameShapeStep(pair, schema) {
|
|
2020
2081
|
if (pair.from.kind === "index" && pair.to.kind === "index") {
|
|
2021
|
-
return step(`alter index ${
|
|
2082
|
+
return step(`alter index ${qualify2(schema, pair.from.identity.name)} rename to ${quoteIdent2(pair.to.identity.name)}`, "rename-index", "ddl", SHARE_UPDATE2);
|
|
2022
2083
|
}
|
|
2023
2084
|
if (pair.from.kind !== "constraint" || pair.to.kind !== "constraint") {
|
|
2024
2085
|
throw new OkmError2("invalid", "A same-shape rename is an index or a constraint.", {
|
|
2025
2086
|
fix: { summary: "The planner only renames an index or a constraint in place." }
|
|
2026
2087
|
});
|
|
2027
2088
|
}
|
|
2028
|
-
return step(`alter table ${
|
|
2089
|
+
return step(`alter table ${qualify2(schema, pair.from.identity.parent.name)} rename constraint ${quoteIdent2(pair.from.identity.name)} to ${quoteIdent2(pair.to.identity.name)}`, "rename-constraint", "ddl", ACCESS2);
|
|
2029
2090
|
}
|
|
2030
2091
|
function assertUnambiguous(beforeBy, afterBy) {
|
|
2031
2092
|
const dropped = new Map;
|
|
@@ -2211,8 +2272,8 @@ function contractSwaps(picklists, enums, replacements, schema, catalogs, batchSi
|
|
|
2211
2272
|
const steps = [];
|
|
2212
2273
|
steps.push(...dataSteps(picklists, enums, replacements, schema, catalogs, batchSize, "contract"));
|
|
2213
2274
|
for (const change of picklists) {
|
|
2214
|
-
const table =
|
|
2215
|
-
const name =
|
|
2275
|
+
const table = qualify2(schema, change.after.identity.parent.name);
|
|
2276
|
+
const name = quoteIdent2(change.after.identity.name);
|
|
2216
2277
|
const kind = change.removed.length > 0 ? "narrow-check" : "widen-check";
|
|
2217
2278
|
steps.push(step(`alter table ${table} drop constraint ${name}`, kind, "ddl", ACCESS2));
|
|
2218
2279
|
const expression = change.after.definition.expression ?? "true";
|
|
@@ -2222,17 +2283,17 @@ function contractSwaps(picklists, enums, replacements, schema, catalogs, batchSi
|
|
|
2222
2283
|
for (const change of enums) {
|
|
2223
2284
|
if (change.kind !== "replace")
|
|
2224
2285
|
continue;
|
|
2225
|
-
const type =
|
|
2226
|
-
const old =
|
|
2286
|
+
const type = qualify2(schema, change.name);
|
|
2287
|
+
const old = quoteIdent2(`${change.name}_old`);
|
|
2227
2288
|
const labels = change.labels.map((label) => quoteLiteral(label)).join(", ");
|
|
2228
2289
|
steps.push(step(`alter type ${type} rename to ${old}`, "rename-enum", "ddl", ACCESS2));
|
|
2229
2290
|
steps.push(step(`create type ${type} as enum (${labels})`, "recreate-enum", "ddl", ACCESS2));
|
|
2230
2291
|
for (const column of change.columns) {
|
|
2231
|
-
const table =
|
|
2232
|
-
const name =
|
|
2292
|
+
const table = qualify2(schema, column.table);
|
|
2293
|
+
const name = quoteIdent2(column.column);
|
|
2233
2294
|
steps.push(step(`alter table ${table} alter column ${name} type ${type} using ${name}::text::${type}`, "set-enum-column", "ddl", ACCESS2));
|
|
2234
2295
|
}
|
|
2235
|
-
steps.push(step(`drop type ${
|
|
2296
|
+
steps.push(step(`drop type ${qualify2(schema, `${change.name}_old`)}`, "drop-enum", "ddl", ACCESS2));
|
|
2236
2297
|
}
|
|
2237
2298
|
return steps;
|
|
2238
2299
|
}
|
|
@@ -2376,9 +2437,9 @@ function domainCheckSteps(beforeBy, afterBy, schema) {
|
|
|
2376
2437
|
if (previous.definition.check === next.definition.check)
|
|
2377
2438
|
continue;
|
|
2378
2439
|
const name = next.identity.name;
|
|
2379
|
-
const type =
|
|
2380
|
-
const current =
|
|
2381
|
-
const upcoming =
|
|
2440
|
+
const type = qualify2(schema, name);
|
|
2441
|
+
const current = quoteIdent2(fitIdentifier2(`${name}_check`));
|
|
2442
|
+
const upcoming = quoteIdent2(fitIdentifier2(`${name}_check_next`));
|
|
2382
2443
|
const expression = next.definition.check;
|
|
2383
2444
|
steps.push(step(`alter domain ${type} add constraint ${upcoming} check (${expression}) not valid`, "add-domain-check", "ddl", ACCESS2));
|
|
2384
2445
|
steps.push(step(`alter domain ${type} validate constraint ${upcoming}`, "validate-domain-check", "ddl", ACCESS2));
|
|
@@ -2454,7 +2515,7 @@ function labelSubsequence(before, after) {
|
|
|
2454
2515
|
function addValueStatements(schema, name, before, after) {
|
|
2455
2516
|
const present = new Set(before);
|
|
2456
2517
|
const statements = [];
|
|
2457
|
-
const type =
|
|
2518
|
+
const type = qualify2(schema, name);
|
|
2458
2519
|
for (let index = 0;index < after.length; index += 1) {
|
|
2459
2520
|
const label = after[index];
|
|
2460
2521
|
if (label === undefined || present.has(label))
|
|
@@ -2538,8 +2599,8 @@ function columnAlterable(before, after) {
|
|
|
2538
2599
|
function identityChangeSql(before, after, schema) {
|
|
2539
2600
|
if (stable(before.definition.identity) === stable(after.definition.identity))
|
|
2540
2601
|
return;
|
|
2541
|
-
const table =
|
|
2542
|
-
const name =
|
|
2602
|
+
const table = qualify2(schema, after.identity.parent.name);
|
|
2603
|
+
const name = quoteIdent2(after.identity.name);
|
|
2543
2604
|
const next = after.definition.identity;
|
|
2544
2605
|
const previous = before.definition.identity;
|
|
2545
2606
|
if (next === undefined)
|
|
@@ -2683,7 +2744,7 @@ function folded(object, source) {
|
|
|
2683
2744
|
return true;
|
|
2684
2745
|
if (object.kind !== "sequence")
|
|
2685
2746
|
return false;
|
|
2686
|
-
if (
|
|
2747
|
+
if (identitySequence2(object, source))
|
|
2687
2748
|
return true;
|
|
2688
2749
|
const name = object.identity.name;
|
|
2689
2750
|
return source.objects.some((column) => {
|
|
@@ -2703,9 +2764,9 @@ function overall(steps) {
|
|
|
2703
2764
|
}
|
|
2704
2765
|
function updateSql(schema, table, column, from, to, catalogs, batchSize, cast = false) {
|
|
2705
2766
|
const key = primaryKeyColumns(catalogs, table);
|
|
2706
|
-
const qualified =
|
|
2767
|
+
const qualified = qualify2(schema, table);
|
|
2707
2768
|
const value = to === null ? "null" : quoteLiteral(to);
|
|
2708
|
-
const compare = cast ? `${
|
|
2769
|
+
const compare = cast ? `${quoteIdent2(column)}::text` : quoteIdent2(column);
|
|
2709
2770
|
const where = `${compare} = ${quoteLiteral(from)}`;
|
|
2710
2771
|
const backfill = {
|
|
2711
2772
|
table: qualified,
|
|
@@ -2713,7 +2774,7 @@ function updateSql(schema, table, column, from, to, catalogs, batchSize, cast =
|
|
|
2713
2774
|
batch: batchSize
|
|
2714
2775
|
};
|
|
2715
2776
|
return {
|
|
2716
|
-
sql: `update ${qualified} set ${
|
|
2777
|
+
sql: `update ${qualified} set ${quoteIdent2(column)} = ${value} where ${where} and ${keyRangePredicate(key)}`,
|
|
2717
2778
|
backfill
|
|
2718
2779
|
};
|
|
2719
2780
|
}
|
|
@@ -2804,7 +2865,7 @@ function readIdent(text, start) {
|
|
|
2804
2865
|
return;
|
|
2805
2866
|
}
|
|
2806
2867
|
function pushDrop(steps, object, schema) {
|
|
2807
|
-
const sql =
|
|
2868
|
+
const sql = dropObjectSql2(object, schema);
|
|
2808
2869
|
const kind = dropKind(object);
|
|
2809
2870
|
if (sql === undefined || kind === undefined)
|
|
2810
2871
|
return;
|
|
@@ -3118,4 +3179,4 @@ function endpointOf(url) {
|
|
|
3118
3179
|
};
|
|
3119
3180
|
}
|
|
3120
3181
|
|
|
3121
|
-
export { sqlStatements, transactionControl, canonicalTypeName, prepareMigrationText, assertMigrationSteps, columnPrivilege, createdRoleName, createRoleOnce, changesRole, DEFAULT_BACKFILL_PAUSE_MS, DEFAULT_BACKFILL_STATEMENT_TIMEOUT_MS, batchSizeField, aboutBatchCount, boundaryQuery, checkedCast, classOf, strictestClass, assertExtensionsAvailable, omitManagedObjects, parseReplace, planMigration, formatPlan, parsePlan, staleRenames, sessionFailure, finishQuiet, assertTargetPolicy, assertTargetAlias, assertDirectConnection, assertStableBackend, listTargets, selectTarget };
|
|
3182
|
+
export { sqlStatements, transactionControl, sqlIdentifiers, canonicalTypeName, prepareMigrationText, assertMigrationSteps, columnPrivilege, createdRoleName, createRoleOnce, changesRole, DEFAULT_BACKFILL_PAUSE_MS, DEFAULT_BACKFILL_STATEMENT_TIMEOUT_MS, batchSizeField, aboutBatchCount, boundaryQuery, checkedCast, classOf, strictestClass, assertExtensionsAvailable, omitManagedObjects, parseReplace, planMigration, formatPlan, parsePlan, staleRenames, sessionFailure, finishQuiet, assertTargetPolicy, assertTargetAlias, assertDirectConnection, assertStableBackend, listTargets, selectTarget };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
pullProject2,
|
|
3
|
+
pullLayout2,
|
|
4
|
+
commitPullFiles2
|
|
5
|
+
} from "./rbxt795q.js";
|
|
6
|
+
import"./myk8fswx.js";
|
|
7
|
+
import"./2zdxkt7b.js";
|
|
8
|
+
import"./6nae0spm.js";
|
|
9
|
+
import"./n442h54c.js";
|
|
10
|
+
import"./fk9vef30.js";
|
|
11
|
+
import"./12z7aznj.js";
|
|
12
|
+
import"./dd5pmnky.js";
|
|
13
|
+
export {
|
|
14
|
+
commitPullFiles2 as commitPullFiles,
|
|
15
|
+
pullLayout2 as pullLayout,
|
|
16
|
+
pullProject2 as pullProject
|
|
17
|
+
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import"./12z7aznj.js";
|
|
2
2
|
import"./n442h54c.js";
|
|
3
|
-
import"./
|
|
3
|
+
import"./fk9vef30.js";
|
|
4
|
+
import"./dd5pmnky.js";
|
|
4
5
|
import {
|
|
5
6
|
projectPath,
|
|
6
7
|
loadConfig
|
|
7
|
-
} from "./
|
|
8
|
+
} from "./2zdxkt7b.js";
|
|
8
9
|
import {
|
|
9
10
|
listTargets
|
|
10
|
-
} from "./
|
|
11
|
-
import"./sjk86yrx.js";
|
|
11
|
+
} from "./6nae0spm.js";
|
|
12
12
|
|
|
13
13
|
// src/tooling/migrate/dev.ts
|
|
14
14
|
import { mkdirSync } from "node:fs";
|
|
@@ -20,7 +20,7 @@ async function devProject(cwd) {
|
|
|
20
20
|
`;
|
|
21
21
|
const directory = projectPath(cwd, config.out ?? ".okm", "dev-db");
|
|
22
22
|
mkdirSync(directory, { recursive: true });
|
|
23
|
-
const { open } = await import("./
|
|
23
|
+
const { open } = await import("./ghqzdp94.js");
|
|
24
24
|
const pool = await open({ dataDir: directory });
|
|
25
25
|
try {
|
|
26
26
|
await pool.execute("select 1");
|