@rebasepro/server-postgres 0.31.0 → 0.32.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/dist/{BranchService-USp1AvZB.js → BranchService-C8LtpMho.js} +3 -3
- package/dist/{BranchService-USp1AvZB.js.map → BranchService-C8LtpMho.js.map} +1 -1
- package/dist/{backup-cli-DbKyEj6c.js → backup-cli-DtV6n3oB.js} +3 -3
- package/dist/{backup-cli-DbKyEj6c.js.map → backup-cli-DtV6n3oB.js.map} +1 -1
- package/dist/{boot-ddl-5H2bL_80.js → boot-ddl-CSYhSSZD.js} +2 -2
- package/dist/{boot-ddl-5H2bL_80.js.map → boot-ddl-CSYhSSZD.js.map} +1 -1
- package/dist/{cli-console-DsRgGSBR.js → cli-console-Cu1DzqvR.js} +4 -4
- package/dist/{cli-console-DsRgGSBR.js.map → cli-console-Cu1DzqvR.js.map} +1 -1
- package/dist/{cli-schema-dir-CiN0ephV.js → cli-schema-dir-DuZIsF2e.js} +5 -5
- package/dist/{cli-schema-dir-CiN0ephV.js.map → cli-schema-dir-DuZIsF2e.js.map} +1 -1
- package/dist/cli.js +124 -36
- package/dist/cli.js.map +1 -1
- package/dist/{database-preflight-bfnIBnjM.js → database-preflight-CyTCWlfc.js} +2 -2
- package/dist/{database-preflight-bfnIBnjM.js.map → database-preflight-CyTCWlfc.js.map} +1 -1
- package/dist/{deferred-index-build-CcSDA7wE.js → deferred-index-build-ueYVUBZc.js} +4 -4
- package/dist/{deferred-index-build-CcSDA7wE.js.map → deferred-index-build-ueYVUBZc.js.map} +1 -1
- package/dist/{ensure-policies-rRmXb5bt.js → ensure-policies-13mHWjBs.js} +7 -7
- package/dist/{ensure-policies-rRmXb5bt.js.map → ensure-policies-13mHWjBs.js.map} +1 -1
- package/dist/{ensure-tables-Bvm-F2wW.js → ensure-tables-B3Kh2RwT.js} +7 -7
- package/dist/{ensure-tables-Bvm-F2wW.js.map → ensure-tables-B3Kh2RwT.js.map} +1 -1
- package/dist/{ensure-tables-CC8p_AK3.js → ensure-tables-DM1U9AZK.js} +3 -3
- package/dist/{ensure-tables-CC8p_AK3.js.map → ensure-tables-DM1U9AZK.js.map} +1 -1
- package/dist/{enum-labels-kept-FlX9SHdf.js → enum-labels-kept-CJDVtX14.js} +2 -2
- package/dist/{enum-labels-kept-FlX9SHdf.js.map → enum-labels-kept-CJDVtX14.js.map} +1 -1
- package/dist/{generate-drizzle-schema-SJMXxzPI.js → generate-drizzle-schema-B-Mkf8UI.js} +2 -2
- package/dist/{generate-drizzle-schema-SJMXxzPI.js.map → generate-drizzle-schema-B-Mkf8UI.js.map} +1 -1
- package/dist/{generate-files-tlJ9_lGI.js → generate-files-8MUP8UHC.js} +2 -2
- package/dist/{generate-files-tlJ9_lGI.js.map → generate-files-8MUP8UHC.js.map} +1 -1
- package/dist/{generate-postgres-ddl-logic-B8huc03c.js → generate-postgres-ddl-logic-CQof4iFH.js} +89 -45
- package/dist/generate-postgres-ddl-logic-CQof4iFH.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.es.js +14 -14
- package/dist/{migrate-baseline-DZmekgpD.js → migrate-baseline-DnMlSDup.js} +9 -2
- package/dist/{migrate-baseline-DZmekgpD.js.map → migrate-baseline-DnMlSDup.js.map} +1 -1
- package/dist/{migrate-policy-stamps-B_acrUQB.js → migrate-policy-stamps-BpHyEFkk.js} +5 -5
- package/dist/{migrate-policy-stamps-B_acrUQB.js.map → migrate-policy-stamps-BpHyEFkk.js.map} +1 -1
- package/dist/{open-rebase-4kisUF_k.js → open-rebase-B2mAA7UE.js} +175 -38
- package/dist/open-rebase-B2mAA7UE.js.map +1 -0
- package/dist/{pg-error-utils-BT5NzGFZ.js → pg-error-utils-CpUiBkp-.js} +2 -2
- package/dist/{pg-error-utils-BT5NzGFZ.js.map → pg-error-utils-CpUiBkp-.js.map} +1 -1
- package/dist/{policy-drift-BVMyqHSa.js → policy-drift-C9xRcbsU.js} +4 -4
- package/dist/{policy-drift-BVMyqHSa.js.map → policy-drift-C9xRcbsU.js.map} +1 -1
- package/dist/{push-index-adoption-hpHTyXMR.js → push-index-adoption-D-ph6kBc.js} +2 -2
- package/dist/{push-index-adoption-hpHTyXMR.js.map → push-index-adoption-D-ph6kBc.js.map} +1 -1
- package/dist/{push-index-prebuild-Bty9F7bD.js → push-index-prebuild-DUKtH87s.js} +3 -3
- package/dist/{push-index-prebuild-Bty9F7bD.js.map → push-index-prebuild-DUKtH87s.js.map} +1 -1
- package/dist/{push-legacy-renames-bB4bM6br.js → push-legacy-renames-wLSsAg80.js} +3 -3
- package/dist/{push-legacy-renames-bB4bM6br.js.map → push-legacy-renames-wLSsAg80.js.map} +1 -1
- package/dist/{push-policy-plan-BI8U4BOD.js → push-policy-plan-I9RNoP_-.js} +3 -3
- package/dist/{push-policy-plan-BI8U4BOD.js.map → push-policy-plan-I9RNoP_-.js.map} +1 -1
- package/dist/{request-role-cli-BdRzdE87.js → request-role-cli-D9yWoeSl.js} +8 -8
- package/dist/{request-role-cli-BdRzdE87.js.map → request-role-cli-D9yWoeSl.js.map} +1 -1
- package/dist/{request-role-migration-C8aq_TO3.js → request-role-migration-DQLiYJ4c.js} +2 -2
- package/dist/{request-role-migration-C8aq_TO3.js.map → request-role-migration-DQLiYJ4c.js.map} +1 -1
- package/dist/{rls-enforcement-DB5HHj96.js → rls-enforcement-Cwh5SJRx.js} +2 -2
- package/dist/{rls-enforcement-DB5HHj96.js.map → rls-enforcement-Cwh5SJRx.js.map} +1 -1
- package/dist/schema/doctor-cli.js +5 -5
- package/dist/schema/generate-drizzle-schema.js +1 -1
- package/dist/schema/generate-postgres-ddl-logic.d.ts +51 -8
- package/dist/schema/generate-postgres-ddl.js +1 -1
- package/dist/schema/introspect-db.js +1 -1
- package/dist/services/cdc/capture-consumers.d.ts +65 -0
- package/dist/services/cdc/wal-cdc.d.ts +13 -0
- package/dist/services/realtimeService.d.ts +18 -2
- package/dist/{websocket-BevXvwfo.js → websocket-CSVNOYHC.js} +3 -3
- package/dist/{websocket-BevXvwfo.js.map → websocket-CSVNOYHC.js.map} +1 -1
- package/package.json +7 -7
- package/dist/generate-postgres-ddl-logic-B8huc03c.js.map +0 -1
- package/dist/open-rebase-4kisUF_k.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebasepro/server-postgres",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"description": "PostgreSQL data source backend implementation for Rebase with Drizzle ORM",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms",
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
"execa": "^9.6.1",
|
|
51
51
|
"pg": "^8.22.0",
|
|
52
52
|
"ws": "^8.21.1",
|
|
53
|
-
"@rebasepro/
|
|
54
|
-
"@rebasepro/
|
|
55
|
-
"@rebasepro/
|
|
56
|
-
"@rebasepro/types": "0.
|
|
57
|
-
"@rebasepro/
|
|
53
|
+
"@rebasepro/common": "0.32.0",
|
|
54
|
+
"@rebasepro/codegen": "0.32.0",
|
|
55
|
+
"@rebasepro/server": "0.32.0",
|
|
56
|
+
"@rebasepro/types": "0.32.0",
|
|
57
|
+
"@rebasepro/utils": "0.32.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@electric-sql/pglite": "0.5.6",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"typescript": "^6.0.3",
|
|
71
71
|
"vite": "^8.1.5",
|
|
72
72
|
"vitest": "^4.1.11",
|
|
73
|
-
"@rebasepro/client": "0.
|
|
73
|
+
"@rebasepro/client": "0.32.0"
|
|
74
74
|
},
|
|
75
75
|
"gitHead": "d935eefa5aa8d1009a2398cfac2c1e4ee9aeb6b6",
|
|
76
76
|
"publishConfig": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-postgres-ddl-logic-B8huc03c.js","names":[],"sources":["../src/schema/generate-postgres-ddl-logic.ts"],"sourcesContent":["/**\n * The SQL half of `rebase db generate`, as a plan and a renderer.\n *\n * There is no interpretation left in this file. `schema/plan/plan-schema.ts`\n * reads the collections into a {@link SchemaPlan} and `schema/plan/render-ddl.ts`\n * writes the files; what remains here is the public entry points those two are\n * reached through, plus the smaller plans (`planRelationalColumns`,\n * `planJunctionTables`, `planTablePolicies`) that other modules ask for as\n * slices of the same plan.\n *\n * It used to hold `getSqlColumnType` and a `CREATE TABLE` walk with its own\n * reading of relations, junctions, enums and search — one of three such\n * readings. See `schema/plan/types.ts` for what that cost.\n */\nimport { REBASE_ADMIN_REQUEST_ROLE, type CompiledTable, type SecurityRule, type TableDescriptor } from \"@rebasepro/types\";\nimport { policyTableFromDescriptor, policyTableResolver, type ResolvePolicyTable } from \"@rebasepro/common\";\nimport { compileTableSecurityRule, planSchema, quoteSqlLiteral, defaultBelongsToOnDelete } from \"./plan/plan-schema\";\nimport {\n renderDenyingPolicyStatements,\n renderPgType,\n renderPoliciesDdl,\n renderPolicyStatements,\n renderPostgresDdl,\n renderSearchDdl,\n renderTriggersDdl,\n renderViewsDdl,\n renderVectorDdl,\n searchExcludePatternsOf,\n triggerExcludePatternsOf,\n vectorExcludePatternsOf,\n type DdlRenderOptions\n} from \"./plan/render-ddl\";\nimport type { ForeignKeyPlan, SchemaPlan } from \"./plan/types\";\nimport type { GeneratedColumnDependency } from \"./generated-column-conflicts\";\n\nexport { quoteSqlLiteral, defaultBelongsToOnDelete };\nexport type { ForeignKeyPlan };\n\n/**\n * The individual SQL statements a single security rule compiles to: a\n * `DROP POLICY IF EXISTS` / `CREATE POLICY` pair per operation, each a complete\n * statement (terminated by `;`, no trailing newline).\n *\n * This is the primitive the boot-time RLS applier runs one statement at a time\n * (the runtime's DB handle speaks the extended query protocol, which forbids\n * multiple commands in one execute), while `db push` writes the joined string.\n *\n * `resolveTable` answers the tables a rule's `existsIn` reaches; by default\n * only the table itself.\n */\nexport const generatePolicyStatements = (\n table: TableDescriptor,\n rule: SecurityRule,\n resolveTable: ResolvePolicyTable = policyTableResolver([table])\n): string[] =>\n compileTableSecurityRule(policyTableFromDescriptor(table), rule, resolveTable, false)\n .flatMap(policy => renderPolicyStatements({ schema: table.schema, table: table.table }, policy));\n\n/**\n * `.rebase/sql/schema.sql` — the desired state Atlas diffs the database against.\n *\n * Synchronous. It was `async` with nothing to await, which made every caller\n * (the writer script, the doctor, the live editor, two gates) carry a promise\n * for no reason and made the one place that forgot to await it silently compare\n * `[object Promise]`.\n */\nexport const generatePostgresDdl = (\n tables: readonly CompiledTable[],\n options: DdlRenderOptions = {}\n): string => renderPostgresDdl(planSchema(tables), options);\n\n/** `.rebase/sql/policies.sql` — the RLS policies. Atlas has no model for a policy. */\nexport const generatePostgresPoliciesDdl = (tables: readonly CompiledTable[]): string =>\n renderPoliciesDdl(planSchema(tables));\n\n/**\n * `.rebase/sql/search.sql` — everything a `search` block needs, as a file Rebase\n * applies itself.\n *\n * Search is one of the parts of the schema Atlas does not own, for two\n * independent reasons and either alone would be enough:\n *\n * 1. Its free tier refuses to *parse* a desired-state file that so much as\n * contains a function — \"functions and procedures are available to\n * logged-in users only\". A generated `tsvector` column cannot avoid one:\n * `unaccent` is STABLE and jsonb flattening needs a set-returning function,\n * so both have to be wrapped in an IMMUTABLE helper to be legal in a\n * generated column at all.\n * 2. Even with the file accepted, Atlas *wipes* the dev database it diffs\n * against, so a helper seeded there beforehand is gone by the time the plan\n * is analysed. There is no hook to reinstate it.\n *\n * Empty when nothing opted in — the caller writes no file then.\n */\nexport const generatePostgresSearchDdl = (tables: readonly CompiledTable[]): string =>\n renderSearchDdl(planSchema(tables));\n\n/**\n * Glob patterns telling Atlas to leave the search column and its index alone.\n *\n * Without these, a desired state that omits search reads to Atlas as an\n * instruction to drop the column — taking the index and the whole search\n * feature with it on the next push.\n */\nexport const searchExcludePatterns = (tables: readonly CompiledTable[]): string[] =>\n searchExcludePatternsOf(planSchema(tables));\n\n/**\n * `.rebase/sql/vector.sql` — the `vector` columns, their ANN indexes and, when a\n * database declared it, the extension.\n *\n * Vector is out of Atlas's hands for a narrower reason than search: not that\n * Atlas refuses to parse the file, but that it cannot *execute* it. To compute\n * a desired state Atlas materialises `schema.sql` in a dev database, that\n * database is created empty, and Atlas empties it again at the start of every\n * run — so `VECTOR(384)` resolves against a database that structurally cannot\n * have pgvector, and every push dies with `type \"vector\" does not exist`.\n */\nexport const generatePostgresVectorDdl = (\n tables: readonly CompiledTable[],\n options: { extensions?: readonly string[] } = {}\n): string => renderVectorDdl(planSchema(tables, { databaseExtensions: options.extensions }));\n\n/** @see searchExcludePatterns */\nexport const vectorExcludePatterns = (tables: readonly CompiledTable[]): string[] =>\n vectorExcludePatternsOf(planSchema(tables));\n\n/**\n * `.rebase/sql/triggers.sql` — the `BEFORE UPDATE` triggers behind\n * `autoValue: \"on_update\"`, and the one function they share.\n *\n * A trigger is a function plus a binding, so it is carved out of Atlas's view\n * for the first of the two reasons search is. Empty when no property declares\n * `on_update` — the caller writes no file then, and removes a stale one.\n */\nexport const generatePostgresTriggersDdl = (tables: readonly CompiledTable[]): string =>\n renderTriggersDdl(planSchema(tables));\n\n/**\n * `.rebase/sql/views.sql` — the views of the collections that declare `view`,\n * which Atlas's free tier does not manage. Empty when none does — the caller\n * writes no file then, and removes a stale one.\n */\nexport const generatePostgresViewsDdl = (tables: readonly CompiledTable[]): string =>\n renderViewsDdl(planSchema(tables));\n\n/** @see searchExcludePatterns */\nexport const triggerExcludePatterns = (tables: readonly CompiledTable[]): string[] =>\n triggerExcludePatternsOf(planSchema(tables));\n\n// ── Slices of the plan other modules ask for ─────────────────────────────────\n\n/** A column a `relation` or `reference` property owns on its own table. */\nexport interface RelationalColumnPlan {\n schema: string;\n /** Bare table name, no schema prefix. */\n table: string;\n column: string;\n /** Postgres type, exactly as the DDL renderer declares it. */\n type: string;\n /** `validation.required` on the property that owns the link. */\n required: boolean;\n /**\n * True when a declared property emits this column and the relation\n * contributes only the constraint — `postId` with `columnName: \"post_id\"`\n * beside a `belongsTo` on `post_id`.\n */\n columnOwnedByProperty?: boolean;\n /** Absent when the target collection is not part of this bundle. */\n foreignKey?: ForeignKeyPlan;\n /**\n * What this column would have been called before `generateForeignKeyName`\n * learned to singularize. Carried so the boot-time ensure can notice a\n * database provisioned under the old rule; never used to name anything.\n */\n legacyColumn?: string;\n}\n\n/** The table behind a many-to-many `through` relation. */\nexport interface JunctionTablePlan {\n schema: string;\n /** Bare table name, no schema prefix. */\n table: string;\n columns: { name: string; type: string; legacyName?: string }[];\n /** Both endpoint columns plus the composite primary key. */\n createTable: string;\n foreignKeys: ForeignKeyPlan[];\n}\n\nconst planOf = (tables: readonly CompiledTable[]): SchemaPlan => planSchema(tables);\n\n/**\n * The FK columns the declared collections own — one entry per `relation`\n * (`belongsTo` side) or `reference` property.\n *\n * A view over the schema plan. It was a second walk of the collections beside\n * the `CREATE TABLE` one, which is how boot-ensure came to add every relation\n * column bare while `db push` made the same column `NOT NULL`.\n */\nexport const planRelationalColumns = (tables: readonly CompiledTable[]): RelationalColumnPlan[] => {\n const plan = planOf(tables);\n const out: RelationalColumnPlan[] = [];\n for (const table of plan.tables) {\n if (table.kind !== \"collection\") continue;\n for (const column of table.columns) {\n if (column.source.kind !== \"relation\" && column.source.kind !== \"reference\") continue;\n out.push({\n schema: table.schema,\n table: table.table,\n column: column.column,\n type: renderPgType(column.type),\n required: !column.nullable,\n columnOwnedByProperty: column.columnOwnedByProperty,\n legacyColumn: column.legacyColumn,\n foreignKey: column.foreignKey\n });\n }\n }\n return out;\n};\n\n/**\n * The junction tables a bundle's many-to-many relations imply.\n *\n * Derived from the same plan the derived RLS comes from, so a table created\n * here always has policies planned for it — a junction with row-level security\n * left off is readable and writable by every signed-in user.\n */\nexport const planJunctionTables = (tables: readonly CompiledTable[]): JunctionTablePlan[] =>\n planOf(tables).tables\n .filter(table => table.kind === \"junction\")\n .map(table => ({\n schema: table.schema,\n table: table.table,\n columns: table.columns.map(c => ({\n name: c.column,\n type: renderPgType(c.type),\n legacyName: c.legacyColumn\n })),\n createTable:\n `CREATE TABLE IF NOT EXISTS \"${table.schema}\".\"${table.table}\" (` +\n table.columns.map(c => `\"${c.column}\" ${renderPgType(c.type)} NOT NULL`).join(\", \") +\n `, PRIMARY KEY (${table.primaryKey.map(c => `\"${c}\"`).join(\", \")}));`,\n foreignKeys: table.columns.map(c => c.foreignKey).filter((fk): fk is ForeignKeyPlan => fk !== undefined)\n }));\n\nexport interface TablePolicyPlan {\n /** The table's schema (e.g. `public`, `rebase`). */\n schema: string;\n /** The bare table name, no schema prefix. */\n table: string;\n /** `schema.table` — matches the keys `readExistingSchema` returns. */\n qualified: string;\n /** `ALTER TABLE … ENABLE ROW LEVEL SECURITY;` — locked by default. */\n enableRls: string;\n /** `DROP POLICY IF EXISTS` / `CREATE POLICY` statements, in order. */\n policyStatements: string[];\n /**\n * The same statements, grouped by policy, with each restrictive policy's\n * denying stand-in. What the boot applier's one-statement-at-a-time\n * fallback walks: it creates the restrictive gates before any grant, and\n * puts the stand-in where a gate could not be created.\n */\n policies: PolicyApplyPlan[];\n}\n\n/** One policy of a {@link TablePolicyPlan}, as the statements that make it. */\nexport interface PolicyApplyPlan {\n name: string;\n /** Written `TO rebase_admin` by the compiler's choice (`rls.adminPolicies`). */\n adminTarget: boolean;\n /** The `TO rebase_admin_request USING (true)` companion of an admin-only policy. */\n adminRequestTarget?: true;\n restrictive: boolean;\n /** Its `DROP POLICY IF EXISTS` / `CREATE POLICY` statements — a slice of `policyStatements`. */\n statements: string[];\n /** For a restrictive policy, the statements that make it deny every row instead. */\n denying?: string[];\n}\n\n/**\n * The per-table RLS plan for the declared collections and their junctions, as\n * executable statements — what the managed runtime applies at boot so a freshly\n * provisioned tenant database serves data instead of 401ing every read.\n *\n * The same policies `policies.sql` carries, from the same plan, so boot and\n * `db push` produce identical RLS from identical collections.\n */\nexport const planTablePolicies = (\n tables: readonly CompiledTable[],\n options: {\n adminRoleAvailable?: boolean;\n /**\n * The boot made `rebase_admin_request`, granted it to the admin request\n * roles alone, and checked the connection does not hold its\n * privileges. Only then are the companions planned; otherwise they\n * are left out, and the boot drops any left in the database.\n */\n adminRequestRoleAvailable?: boolean;\n } = {}\n): TablePolicyPlan[] => {\n const plan = planOf(tables);\n // Collections first, then the junctions no collection declares.\n const ordered = [\n ...plan.tables.filter(t => t.kind === \"collection\"),\n ...plan.tables.filter(t => t.kind === \"junction\")\n ];\n return ordered.map(table => {\n const policies: PolicyApplyPlan[] = table.policies.flatMap(planned => {\n // Where `rebase_admin` cannot exist, a policy the compiler put there\n // is written as it was before it did: `TO public`.\n const policy = options.adminRoleAvailable === false && planned.adminTarget\n ? { ...planned, roles: [\"public\"] }\n : planned;\n const restrictive = policy.mode === \"restrictive\";\n const applied: PolicyApplyPlan = {\n name: policy.name,\n adminTarget: policy.adminTarget === true && policy.roles[0] !== \"public\",\n restrictive,\n statements: renderPolicyStatements(table, policy),\n ...(restrictive ? { denying: renderDenyingPolicyStatements(table, policy) } : {})\n };\n // The companion goes only beside a policy actually written TO\n // rebase_admin, and never anywhere else: moved TO public, it would\n // be `USING (true)` for everyone.\n const companion = planned.adminRequestCompanion;\n if (!companion || !applied.adminTarget || options.adminRequestRoleAvailable !== true) return [applied];\n return [applied, {\n name: companion.name,\n adminTarget: false,\n adminRequestTarget: true,\n restrictive: false,\n statements: renderPolicyStatements(table, {\n ...policy,\n name: companion.name,\n mode: \"permissive\",\n roles: [REBASE_ADMIN_REQUEST_ROLE],\n using: companion.using,\n withCheck: companion.withCheck,\n adminTarget: undefined,\n adminRequestCompanion: undefined,\n supersedes: undefined\n })\n }];\n });\n return {\n schema: table.schema,\n table: table.table,\n qualified: table.qualified,\n enableRls: `ALTER TABLE \"${table.schema}\".\"${table.table}\" ENABLE ROW LEVEL SECURITY;`,\n policyStatements: policies.flatMap(policy => policy.statements),\n policies\n };\n });\n};\n\n/**\n * The `generated column → column it reads` edges a project's `search` blocks\n * imply, derived from the collections alone.\n *\n * The same edges `queryGeneratedColumnDependencies` reads out of `pg_depend`,\n * but available where no database is: `rebase db generate` writes a migration\n * that will run somewhere else, later, against a database it cannot inspect.\n * A spec's `fields[].column` is the physical column each search field starts\n * at, which is exactly what the generated expression depends on.\n */\nexport const searchColumnDependencies = (\n tables: readonly CompiledTable[]\n): GeneratedColumnDependency[] => {\n const dependencies: GeneratedColumnDependency[] = [];\n for (const table of planOf(tables).tables) {\n const spec = table.search;\n if (!spec) continue;\n const generated = [spec.column, ...(spec.fuzzy ? [spec.fuzzy.column] : [])];\n const sources = new Set(spec.fields.map(field => field.column));\n for (const column of generated) {\n for (const dependsOn of sources) {\n dependencies.push({ schema: table.schema, table: table.table, column, dependsOn });\n }\n }\n }\n return dependencies;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,IAAa,uBACT,QACA,UAA4B,CAAC,MACpB,kBAAkB,WAAW,MAAM,GAAG,OAAO;;AAG1D,IAAa,+BAA+B,WACxC,kBAAkB,WAAW,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;AAqBxC,IAAa,6BAA6B,WACtC,gBAAgB,WAAW,MAAM,CAAC;;;;;;;;AAStC,IAAa,yBAAyB,WAClC,wBAAwB,WAAW,MAAM,CAAC;;;;;;;;;;;;AAa9C,IAAa,6BACT,QACA,UAA8C,CAAC,MACtC,gBAAgB,WAAW,QAAQ,EAAE,oBAAoB,QAAQ,WAAW,CAAC,CAAC;;AAG3F,IAAa,yBAAyB,WAClC,wBAAwB,WAAW,MAAM,CAAC;;;;;;;;;AAU9C,IAAa,+BAA+B,WACxC,kBAAkB,WAAW,MAAM,CAAC;;;;;;AAOxC,IAAa,4BAA4B,WACrC,eAAe,WAAW,MAAM,CAAC;;AAGrC,IAAa,0BAA0B,WACnC,yBAAyB,WAAW,MAAM,CAAC;AAyC/C,IAAM,UAAU,WAAiD,WAAW,MAAM;;;;;;;;;AAUlF,IAAa,yBAAyB,WAA6D;CAC/F,MAAM,OAAO,OAAO,MA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