@simetrajs/designer 0.1.0 → 0.3.0-next.1

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.
Files changed (29) hide show
  1. package/README.md +39 -4
  2. package/dist/{command-CRUaUglx.js → command-CHk1P9Dp.js} +91 -108
  3. package/dist/default-dir-DerxTbci.js +158 -0
  4. package/dist/errors-D1P2kKbL.js +62 -0
  5. package/dist/init-jr0Xsrpp.js +832 -0
  6. package/dist/invoke-BwP_5iN6.js +2676 -0
  7. package/dist/main.js +6 -6
  8. package/dist/mcp-args-D63akJ97.js +56 -0
  9. package/dist/mcp-jLOz0W7f.js +219 -0
  10. package/dist/package-hA0J8AMK.js +4 -0
  11. package/dist/{schema-engine-DAsJEc8K.js → schema-engine-8rVHcVYO.js} +704 -195
  12. package/dist/{types-CSc8XWLd.js → types-CMcZhIci.js} +8 -3
  13. package/package.json +16 -12
  14. package/skills/simetra-adoption/SKILL.md +82 -3
  15. package/skills/simetra-metadata/SKILL.md +126 -136
  16. package/skills/simetra-metadata/references/agents-over-mcp.md +236 -0
  17. package/skills/simetra-metadata/references/attribute-load-and-size.md +57 -0
  18. package/skills/simetra-metadata/references/list-order-indexes.md +17 -0
  19. package/skills/simetra-metadata/references/object-modules.md +78 -0
  20. package/skills/simetra-metadata/references/people-and-rights.md +702 -9
  21. package/skills/simetra-metadata/references/plan-and-apply.md +81 -0
  22. package/skills/simetra-metadata/references/project-setup.md +28 -0
  23. package/skills/simetra-metadata/references/row-version-epoch.md +39 -0
  24. package/skills/simetra-metadata/references/search-fields.md +28 -0
  25. package/skills/simetra-metadata/references/sql-trust-boundary.md +225 -0
  26. package/dist/errors-D5pJLrjP.js +0 -36
  27. package/dist/mcp-CJDCleh-.js +0 -241
  28. package/dist/package-DDuGk6yE.js +0 -5
  29. package/dist/report-D2jBS_04.js +0 -1550
@@ -0,0 +1,81 @@
1
+ # The database: plan and apply
2
+
3
+ `plan` compares the live database with the metadata and writes
4
+ `plans/<from>-<to>.plan.json` next to the metadata directory (the directory
5
+ that holds `metadata/`); the database is only read. Its output shows drift
6
+ first, then each step with its class and lock level, then the `planHash`.
7
+ Show the plan to the owner before applying it.
8
+
9
+ The generated SQL grants to platform roles (`simetra_command`) that live in the
10
+ cluster, not in the database, so `plan` does not create them. Without one on
11
+ the target or the shadow server, `plan`, `diff` and `rehearse` refuse with
12
+ `plan.platform-role-missing`: run `simetra roles` once with a role that has
13
+ `CREATEROLE` ("Platform roles" in the people-and-rights reference; `postgres`
14
+ needs a superuser and no separate shadow server). It only checks an existing role; an unsafe
15
+ shape (`plan.platform-role-shape`) is fixed by hand, not by `roles`.
16
+
17
+ `apply` applies exactly that file in one transaction. It needs the `planHash`
18
+ of the reviewed plan, confirmation (`--yes`, MCP `confirm: true`), and in
19
+ `allow` the id of every step that drops data or relaxes a guarantee and
20
+ `drift` when the plan carries drift; the plan output says which items need
21
+ it. `rehearse` runs the plan and rolls it back, but still takes the same
22
+ locks as `apply`. It also builds the desired shadow database and proves on the
23
+ same connection that the catalog equals the desired state, so it holds the
24
+ plan's locks a little longer. A successful `rehearse` writes its report to
25
+ `plans/<from>-<to>.rehearsal.json` next to the plan.
26
+
27
+ Before the end of the transaction, `apply` and `rehearse` re-validate function
28
+ bodies and fire deferred constraints; an invalid constraint or index that the
29
+ desired state does not have is refused. An `apply.function-check-blind` warning lists
30
+ functions the check cannot see (another language, no `EXECUTE` for the role, a
31
+ trigger function without a trigger): nothing proved their bodies, so review
32
+ them by hand.
33
+
34
+ When the role has global default privileges, a plan also ends with environment
35
+ steps: explicit GRANT/REVOKE that cancel them on the objects the plan creates.
36
+ The output shows them as their own group, `environment rights: the global
37
+ default privileges of role <role>`; review them with the rest of the plan.
38
+ If the environment changes before the apply, it is refused
39
+ (`apply.target-changed`); plan again. A plan file from an older tool version is
40
+ refused too: rebuild it with `plan`. After a data-only restore or a
41
+ logical-replication move, reset the row version epoch (the row-version-epoch reference).
42
+
43
+ A promotion plan's `allow` also takes its listed `access:<table>`, `remove:<t>`,
44
+ `repair:<t>`, `delete:<t>.<constraint>` and `update:<t>.<constraint>` items; a
45
+ repair rewrites existing values with the fill expression shown.
46
+ A promotion is applied only with a valid rehearsal report: rehearse the plan on
47
+ a copy of the target with data first. Point the rehearsal at the copy through
48
+ the connection variable: `simetra apply --rehearse --database-url-env <VAR>`
49
+ on the command line, or an MCP server launched with
50
+ `simetra mcp --database-url-env <VAR>` (an MCP server's database is fixed at
51
+ launch). Make the copy from the target after the plan, restore it as the plan's
52
+ role with `pg_restore --no-owner`, on a server with the same PostgreSQL major
53
+ version, encoding and collation; otherwise the rehearsal is refused as not a
54
+ copy of the plan's target (`apply.target-changed`). Rehearsing on the target
55
+ itself is allowed, but it holds the target's locks for the whole run: make it
56
+ a deliberate choice of the owner, not a default. `apply` refuses without a
57
+ report (`apply.rehearsal-required`), with a stale one (`apply.rehearsal-stale`:
58
+ another plan, report format, server, ledger head, or not one row count per
59
+ promoted table), and when a table has rows on the target but none on the copy
60
+ (`apply.rehearsal-copy-empty`); it warns when the copy has fewer rows
61
+ (`apply.rehearsal-fewer-rows`) or when the statement timeout computed from the
62
+ report exceeds what Postgres accepts (`apply.rehearsal-timeout-unbounded`).
63
+
64
+ Which connection to use:
65
+
66
+ - Reads of the target (`introspect`, `diff`, `plan`) run in short read-only
67
+ transactions and work through a transaction-mode pooler.
68
+ - The shadow database of `diff` and `plan` needs a direct or session-mode
69
+ connection: it is created, reached by name and loaded with session settings
70
+ that a transaction-mode pooler is not guaranteed to keep. With a pooled target
71
+ connection, point `--shadow-url-env` at a direct one.
72
+ - A long `apply` wants a direct or session-mode connection too: a pooler may
73
+ cut the transaction with its own timeouts.
74
+
75
+ A changed plan file, changed metadata or a changed database refuses the
76
+ apply; plan again.
77
+
78
+ If `apply` reports `outcome unknown`, the connection was lost and the apply may
79
+ or may not have been committed. Never apply again blindly: look up the printed
80
+ apply id in the `apply_id` column of `simetra.ledger` first — a row means it was
81
+ committed.
@@ -0,0 +1,28 @@
1
+ # Project setup
2
+
3
+ `simetra init` connects a project to the installed tools: it links the
4
+ package skills into `.agents/skills/` and `.claude/skills/` and writes the MCP
5
+ server entry for the chosen agents. Run it from the project root — the
6
+ directory the agent starts in, where `metadata/` lives.
7
+
8
+ ```sh
9
+ pnpm exec simetra init
10
+ pnpm exec simetra init --agents claude,codex,cursor,vscode
11
+ pnpm exec simetra init --dry-run
12
+ pnpm exec simetra init --check --agents claude,codex
13
+ ```
14
+
15
+ - Without `--agents` only Claude Code's `.mcp.json` is written. The skill
16
+ links are made in both skill directories for every agent.
17
+ - The links and configs belong in git. In CI run `init --check` with the same
18
+ `--agents`: it exits 1 when a link or an MCP entry is missing or stale, and
19
+ changes nothing.
20
+ - `init` never overwrites what it does not own: a skill directory with the
21
+ same name, or a `simetra` MCP entry with another command, is left alone and
22
+ reported as a note. Arguments you add to its own entry — `--read-only`, a
23
+ metadata directory — are kept.
24
+ - A config `init` cannot read safely (JSON with comments, an ambiguous TOML
25
+ table) stops the whole run with exit 2; nothing is written.
26
+ - After `pnpm up @simetrajs/designer` the links show the new skill content by
27
+ themselves. A new skill or a moved binary is reported by `init --check`;
28
+ run `init` again.
@@ -0,0 +1,39 @@
1
+ # Row version epoch
2
+
3
+ Every row of a table with the mechanics trigger carries a `version` from one
4
+ database-wide sequence, `simetra.row_version`. A client keeps a row by its
5
+ version, so a version must never repeat for a key. The database gives the
6
+ client an epoch, `simetra.row_version_epoch()`; when it changes, the client drops
7
+ the versions it holds.
8
+
9
+ The epoch changes on its own when the server restarts, a volume snapshot or a
10
+ point in the past is restored, a failover moves the timeline, or the database
11
+ moves to a new cluster or a new database. It is `NULL` on a replica.
12
+
13
+ Two cases the database cannot see:
14
+
15
+ - **A data-only restore into the same database** (`pg_restore --data-only`,
16
+ `psql` from a dump). The dump brings back old sequence values and the old
17
+ epoch row.
18
+ - **A move by logical replication.** Sequences do not travel, so the new
19
+ sequence may sit below the versions in the rows.
20
+
21
+ After either, the schema owner runs the call below with the application stopped
22
+ and before its first read:
23
+
24
+ ```sql
25
+ SELECT simetra.reset_row_version_epoch();
26
+ ```
27
+
28
+ It seeds the sequence above every version in the mechanics tables and issues a
29
+ new epoch. Versions issued between the restore and the call may repeat: the
30
+ database does not guard that window.
31
+
32
+ Rules for your own SQL:
33
+
34
+ - Never set `synchronous_commit = off` after a row write in a debt unit. The
35
+ mechanics trigger raises the commit to synchronous; `off` makes it
36
+ asynchronous again, and a crash then loses issued versions without an epoch
37
+ change.
38
+ - Never write the `simetra.row_version_*` settings (`sql.debt-session-write`
39
+ warns).
@@ -0,0 +1,28 @@
1
+ # Search fields and mode
2
+
3
+ The object property `search` on a Catalog, a Document or a `CustomTable`
4
+ names what a search of the object looks at (a reference picker, a `contains`
5
+ or `startsWith` filter of a list read).
6
+
7
+ ```json
8
+ { "search": { "fields": ["description", "code"], "mode": "startsWith" } }
9
+ ```
10
+
11
+ - `fields`: logical names of header attributes, standard or custom. Omitted:
12
+ the default fields of the kind — a Catalog's presentation field
13
+ (`description`, or `code` with `mainPresentation: "Code"`; none when its
14
+ length is 0), a Document's `number`, a `CustomTable` none. An object with no
15
+ fields has no search.
16
+ - `mode`: `startsWith` or `contains`; `contains` when omitted.
17
+ - A field of type `String` or `Text` gets a stored derived column and an index
18
+ built by the platform (`<column>_search`); it is not an attribute, so leave
19
+ it out of metadata files and out of `fields`.
20
+ - `startsWith` is read through an index on a bounded prefix of the lowercased
21
+ value, with the exact condition on the full value beside it, so the result
22
+ is the same with or without the index. It is the mode to choose for a large
23
+ table.
24
+ - `contains` has no index: it scans the rows of the scope, so it stays fast
25
+ only for a scope up to about a hundred thousand rows, and a request needs a
26
+ scope equality. Without one the scan covers the whole table.
27
+ - Adding `search` to an adopted `CustomTable` adds the derived column in the
28
+ apply plan; it rewrites the table, so the plan marks it as a heavy step.
@@ -0,0 +1,225 @@
1
+ # SQL trust boundary
2
+
3
+ What application SQL may do around the tables of a kind, and how to fix each
4
+ refusal; the router is `SKILL.md`. Every diagnostic below carries a hint with
5
+ the exact allowlist: read it, do not reword the statement until it passes.
6
+
7
+ Contents:
8
+
9
+ - Policies and triggers on a table of a kind
10
+ - Writes to a table of a kind
11
+ - Function bodies
12
+ - Code that runs inside a command
13
+ - Reading `sql.head-not-allowed`
14
+ - Session settings
15
+ - Other paths into a command
16
+ - Before a promotion
17
+
18
+ ## Policies and triggers on a table of a kind
19
+
20
+ Only the platform attaches policies and triggers to a table of a kind (and to
21
+ its tabular sections), in any `.sql` file, shared `sql/` folder included.
22
+ A verbatim `CREATE POLICY` or `CREATE TRIGGER` there is the error
23
+ `sql.kind-table-verbatim`, and the unit can never be listed in
24
+ `sql-debt.json`. A hand-written policy would open rows past the rights, a
25
+ hand-written trigger would act inside every command. Use what replaces them:
26
+
27
+ - a policy → a right: a role's `grant` (with an extent), `ownership`,
28
+ `access` or `publicRead` on the object;
29
+ - a trigger → an `EventSubscription` with a handler that only checks (below).
30
+
31
+ The same statement on a `CustomTable` is ordinary SQL debt until the table is
32
+ promoted into a kind.
33
+
34
+ ## Writes to a table of a kind
35
+
36
+ Only commands write a table of a kind: write a change of its rows as a
37
+ command of the object or its TypeScript hook. No application SQL, in any
38
+ file and in debt too, writes one: an `INSERT`, `UPDATE`, `DELETE` or `MERGE`
39
+ in a function or procedure body whose target is a table of a kind, a tabular
40
+ section, a view of the model over one, the provider's account table
41
+ (`auth.users`) or any relation of the platform schema `simetra` is
42
+ `sql.kind-table-verbatim` with the form `functionBody`, also
43
+ inside a literal `EXECUTE`, a `DO` block or a function the body creates.
44
+ Reading the table (`SELECT`, `FOR UPDATE`, `UPDATE … FROM`, `MERGE … USING`)
45
+ and `LOCK` are fine. An unqualified table name counts in every schema,
46
+ because the body may run with any `search_path`: qualify the names of your
47
+ own tables. Such a function is never debt.
48
+
49
+ ## Function bodies
50
+
51
+ The body of any function or procedure, in any file and in debt too, runs only
52
+ the statements the hint of `sql.function-body-statement` lists; the field
53
+ `statement` names the one refused. A body never changes the schema: move DDL
54
+ into metadata or a migration.
55
+
56
+ - `nonLiteralExecute`, `dynamicText` (a call of a builtin that executes SQL
57
+ text, such as `query_to_xml`, or of any function of a provider schema that
58
+ is not on the provider's reviewed list, such as `dblink` or `cron.schedule`;
59
+ in a body without an empty `search_path`, also an unqualified call that is
60
+ neither a builtin nor a function of the model) and
61
+ `language` (a language other than `sql` and `plpgsql`) cannot be judged:
62
+ rewrite the function with static SQL or remove it. Partition maintenance or
63
+ statistics through `EXECUTE format(…)` is refused on adoption for the same
64
+ reason.
65
+ - `unread`: the compiler could not read part of the body; simplify it.
66
+ - A temporary table of the body is `CREATE TEMP TABLE … ON COMMIT DROP`, and
67
+ every later reference to it (`DROP`, DML, a read) is `pg_temp.<name>`: an
68
+ unqualified name could hit a table of the same name in your schema.
69
+ - A body leaves no session state behind its transaction: a pooled connection
70
+ serves the next command of another user. A setting is `SET LOCAL` or
71
+ `set_config(…, true)` with the literal `true`; `SET` without `LOCAL`,
72
+ `RESET` and any other `set_config` are `sql.function-body-session-setting`.
73
+ A temporary table named after a type of `pg_catalog` (`name`, `uuid`,
74
+ `text`…) is `sql.function-body-temp-type`: rename it. A session-level
75
+ advisory lock, `setseed`, `currval` or `lastval` is
76
+ `sql.function-body-session-builtin`: take `pg_advisory_xact_lock` instead of
77
+ the lock, and read the generated value from `INSERT … RETURNING` instead of
78
+ `currval` or `lastval`, which depend on the state of the session.
79
+
80
+ Application SQL anywhere (a body, a view, a policy, a domain `CHECK`, a
81
+ default) calls only the platform and generated functions that read, such as
82
+ `simetra.current_user_id()`; calling another one is
83
+ `sql.platform-function-call`. Run the write through a command instead.
84
+
85
+ Expressions — a view, the `USING` and `WITH CHECK` of a policy, and the
86
+ defaults, generated columns, checks and index expressions of an adopted
87
+ table — call only allowlisted builtins, functions of the model by
88
+ `schema.name` and the listed provider functions, in any file and in debt too
89
+ (`sql.expression-call-not-allowed`): `set_config` and functions that execute
90
+ SQL text are refused there. A column default may also call
91
+ `nextval('<schema>.<sequence>')` of a sequence declared in the model.
92
+
93
+ The shell of every judged function (volatility, `SECURITY`, `search_path`,
94
+ `SET` options) is read from its `CREATE FUNCTION`. A separate
95
+ `ALTER FUNCTION` that changes it is refused
96
+ (`sql.function-settings-shell`, `RESET ALL` included): move the option into
97
+ `CREATE FUNCTION` and remove the `ALTER FUNCTION` statement.
98
+
99
+ ## Code that runs inside a command
100
+
101
+ Kind module functions, subscription handlers, scope set functions, access
102
+ dimension value functions and movement query blocks run in the middle of a
103
+ command or a policy. The compiler judges them, and every function of the
104
+ model they call, by an allowlist (`sql.head-not-allowed`):
105
+
106
+ - **A handler only checks.** It reads with `SELECT … INTO`, assigns fields of
107
+ `NEW`, raises errors and returns `NEW` or `NULL`. It writes no table and runs
108
+ no `EXECUTE`, `CALL`, `SET`, cursor or `ASSERT` (a session setting can
109
+ switch `ASSERT` off: check with `IF … THEN RAISE`). A `beforeWrite` handler on a provider
110
+ table (`auth.users`) does not assign `NEW` either. A write the handler did
111
+ belongs to a command or a TypeScript hook.
112
+ - **Everything else is a query function.** `LANGUAGE sql`, a string body of
113
+ exactly one `SELECT` (no `INTO`, no `FOR UPDATE`, no data-modifying `WITH`),
114
+ `SET search_path = ''` and no other `SET` option except the pinned session
115
+ settings below. It reads only qualified
116
+ tables of kinds, adopted tables and views of the model, and calls only query
117
+ functions of the model, generated functions that read,
118
+ `simetra.current_user_id()`, the listed provider functions and allowlisted
119
+ builtins. A function of a kind module that is not of this form belongs in
120
+ a shared `sql/` file, called by nothing inside a command.
121
+ - **A scope set function, an access dimension values function and a policy
122
+ function pin the session settings** the client could choose (time zone,
123
+ date, interval, number, money, `bytea` and XML styles, text search
124
+ configuration) with `SET` options of their `CREATE FUNCTION`; the hint of
125
+ `sql.head-settings` lists the exact options (`fix` does not add them). A
126
+ function they call sets none of these to another value.
127
+ - **A verbatim policy expression runs in the client's settings**, and so does
128
+ what it reads: a view and a function that does not pin the settings itself.
129
+ There `current_date`, `localtime` and a conversion to `date`, `time`,
130
+ `timetz` or `timestamp` without `now() AT TIME ZONE '<zone>'`, or to
131
+ `timestamptz` from a value without a zone, is `sql.head-not-allowed`
132
+ (`setting`, `TimeZone`).
133
+ - **A cast to a `reg*` type** names an object by text; only a string literal
134
+ cast to `regclass` (read as that relation) is allowed in a head.
135
+
136
+ ## Reading `sql.head-not-allowed`
137
+
138
+ The diagnostic names the head, the chain from the head to the construct, and
139
+ `construct` (with `detail`: the statement kind, function or relation):
140
+
141
+ | `construct` | Fix |
142
+ | --- | --- |
143
+ | `call` | Schema-qualify the call, or replace it with an allowlisted builtin, a query function or a reading function of the platform |
144
+ | `unqualified` | Qualify the name: `pg_catalog.<name>` for a builtin in a view or a policy, `<schema>.<name>` for your own relation or function |
145
+ | `relation` | Read a table of a kind, an adopted table or a view of the model instead |
146
+ | `statement` | Move the write, `EXECUTE`, `CALL` or `SET` into a command or a TypeScript hook |
147
+ | `query` | Make the body one plain `SELECT` |
148
+ | `language`, `searchPath`, `setting`, `sqlBody` | Fix the shell: `LANGUAGE sql`, `SET search_path = ''`, no other `SET` option, an `AS $$ … $$` body |
149
+ | `operator` | Use an operator of `pg_catalog` |
150
+ | `unread` | Simplify the part the compiler could not read |
151
+
152
+ ## Session settings
153
+
154
+ - Any application SQL unit (subscription handlers wherever they live,
155
+ object-module functions, and every statement of shared `sql/` files:
156
+ functions, `ALTER FUNCTION`, views, domains, aggregates, policies) must not
157
+ change the platform's session settings — `simetra.*`, the request claims
158
+ (`request.jwt.*`), `session_replication_role` and the role (`SET ROLE`,
159
+ `SET SESSION AUTHORIZATION` and their `RESET`) — in any form (`set_config`
160
+ however it is qualified, `SET`/`RESET`, a function option, a write to
161
+ `pg_settings` or a view over it, a literal `EXECUTE`): compiler error
162
+ `sql.command-context-write`. The command context, the user and the role
163
+ belong to the platform.
164
+ - In a debt unit — a statement of the `.sql` file of a `CustomTable` or a
165
+ `PgEnum`, or of a shared `sql/` file, that is listed in `sql-debt.json`
166
+ (a function in the closed shell, a subscription handler and a scope set
167
+ function are never debt) — the rule is split by setting. A write to
168
+ `simetra.*` or `session_replication_role`, `RESET ALL` and a write to
169
+ `pg_settings` stay errors (`sql.command-context-write`, marked
170
+ `unit: debt`). A write to the role or the request claims is a warning
171
+ (`sql.debt-session-write`): it may stay while the unit is debt, because
172
+ code inside a command calls only query functions, which have no such write.
173
+ Converting the unit into a closed-shell function turns that warning into
174
+ the error above, so remove the named statement when you convert the unit;
175
+ write a `set_config` name as a literal, because a name built at run time
176
+ counts as a write.
177
+
178
+ ## Other paths into a command
179
+
180
+ Postgres also runs SQL implicitly in the middle of a command. Each such path
181
+ is closed by its own rule:
182
+
183
+ - **Domain `CHECK`** — follows the rules of a query function: allowlisted
184
+ builtins as `pg_catalog.<name>`, query functions of the model
185
+ (`sql.domain-check-not-allowed`).
186
+ - **Foreign key from a `CustomTable` to a table of a kind** — `onDelete` and
187
+ `onUpdate` are only `restrict` or `noAction`
188
+ (`customTable.fk-action-on-kind-table`): a cascade would write the child
189
+ table from inside a command. Clean up the child rows in a TypeScript hook of
190
+ the command, or promote the child table. The target names the key, not
191
+ columns: `references: { object, key: "ref" }` (one local column) or
192
+ `key: "scopedRef"` — the in-tenant composite key (scope column, key) of a
193
+ scoped object that is not the scope root (two local columns: scope, then
194
+ key). `scopedRef` guarantees that the target lies in the tenant named by the
195
+ local scope column; that this column is the row's own tenant is up to the
196
+ write policy of the `CustomTable`. `columns` on a table of a kind, or `key` on a `CustomTable` target,
197
+ is `customTable.fk-target-not-key`. A foreign key check bypasses row
198
+ level security, so a key on a guessable value (a code, a number) would
199
+ reveal whether a row exists in another tenant; and the command role updates
200
+ unique attributes, while the key never changes.
201
+ - **Scope root** — `onRootDelete: "cascade"` only when the root is an object
202
+ of a kind (`scope.root-cascade-not-kind`): a `CustomTable` root is deleted by
203
+ your SQL, and its cascade would write tables of kinds. Promote the root, or
204
+ delete tenants through a command.
205
+ - **Extensions** — `CREATE EXTENSION … SCHEMA extensions` (a schema of the
206
+ provider); without `SCHEMA` or with another schema it is the error
207
+ `sql.debt-extension-schema`. Fix it with `ALTER EXTENSION … SET SCHEMA
208
+ extensions` in the database and `SCHEMA extensions` in the statement:
209
+ Postgres picks an overload by argument types, so a name match with a model
210
+ function would not make a call safe.
211
+
212
+ ## Before a promotion
213
+
214
+ - A debt unit that writes a table being promoted is refused before any change
215
+ (`promote.debt-writes-table`, every unit listed): rewrite the unit without
216
+ the write, or delete it, then promote.
217
+ - A closed-shell function of the adopted table moves to the kind's module
218
+ only when it is a query function; the others move to
219
+ `sql/<schema>/<function>.sql`.
220
+ - An incoming foreign key with `cascade`, `setNull` or `setDefault` from a
221
+ table that stays a `CustomTable` is set to `restrict` by the promotion
222
+ itself (warning `promote.cascade-to-restrict`, one per key and event). The
223
+ plan needs the permission `delete:<table>.<constraint>` for `ON DELETE` and
224
+ `update:<table>.<constraint>` for `ON UPDATE`: after it, deleting the
225
+ promoted row with child rows, or changing its key, is refused.
@@ -1,36 +0,0 @@
1
- #!/usr/bin/env node
2
- //#region src/schema-engine/errors.ts
3
- /**
4
- * Помилки адаптера, які межа підключення (`io/database.ts`) розпізнає за
5
- * класом. Окремий модуль без `pg` і pg-delta: межу імпортує кожен виклик
6
- * CLI, а двигун вантажиться лише інструментом бази.
7
- */
8
- /** Тінь на сервері іншої мажорної версії: каталоги двох версій не порівнюються. */
9
- var ShadowServerMismatchError = class extends Error {
10
- name = "ShadowServerMismatchError";
11
- };
12
- /** Роль підключення не має `CREATEDB` на сервері, де мала б з'явитися тінь. */
13
- var ShadowCreateRefusedError = class extends Error {
14
- onShadowBase;
15
- name = "ShadowCreateRefusedError";
16
- constructor(onShadowBase) {
17
- super("the connecting role lacks CREATEDB");
18
- this.onShadowBase = onShadowBase;
19
- }
20
- };
21
- /**
22
- * Збій створення тіні чи підключення до неї з причиною, якої адаптер не
23
- * розпізнав: причина — у `cause`. Межа описує її адресою сервера, де мала
24
- * з'явитися тінь, і називає вимогу тіні до режиму з'єднання (спека designer
25
- * §3.2).
26
- */
27
- var ShadowServerError = class extends Error {
28
- onShadowBase;
29
- name = "ShadowServerError";
30
- constructor(cause, onShadowBase) {
31
- super("the shadow could not be created or reached", { cause });
32
- this.onShadowBase = onShadowBase;
33
- }
34
- };
35
- //#endregion
36
- export { ShadowServerError as n, ShadowServerMismatchError as r, ShadowCreateRefusedError as t };