fix(edp): resolve managed reader source scope

This commit is contained in:
Codex
2026-07-19 12:28:00 +03:00
parent 0611a88971
commit 95446bdc24
10 changed files with 273 additions and 19 deletions
@@ -1,3 +1,5 @@
import { backfillManagedReaderSourceConnections } from "./reader-source-scope.mjs";
export async function migrate(pool) {
await pool.query("create extension if not exists timescaledb");
await pool.query("create extension if not exists postgis");
@@ -160,6 +162,7 @@ export async function migrate(pool) {
await pool.query("alter table external_data_plane_reader_bindings add column if not exists binding_key text");
await pool.query("alter table external_data_plane_reader_bindings add column if not exists request_hash text");
await pool.query("alter table external_data_plane_reader_bindings add column if not exists generation integer not null default 1");
await pool.query("alter table external_data_plane_reader_bindings add column if not exists source_connection_id text");
await pool.query("alter table external_data_plane_reader_bindings alter column expires_at drop not null");
await pool.query(`
do $$
@@ -202,6 +205,13 @@ export async function migrate(pool) {
`);
await pool.query("create unique index if not exists external_data_plane_reader_bindings_managed_key_idx on external_data_plane_reader_bindings (binding_key, generation) where binding_key is not null");
await pool.query("create index if not exists external_data_plane_reader_bindings_active_idx on external_data_plane_reader_bindings (active, expires_at)");
await pool.query("create index if not exists external_data_plane_reader_bindings_source_idx on external_data_plane_reader_bindings (tenant_id, source_connection_id, provider_id, active)");
await pool.query(`
update external_data_plane_reader_bindings
set source_connection_id = connection_id
where binding_key is null and source_connection_id is null
`);
await backfillManagedReaderSourceConnections(pool);
await pool.query(`
create table if not exists external_data_plane_facts (