d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
72 lines
3.9 KiB
SQL
72 lines
3.9 KiB
SQL
-- migration-safe: data-only backfill. Expand-phase companion to the canonical-key collapse in
|
|
-- buildProviderConfig + the canonical-first poller reads. Populates each polling trigger's canonical
|
|
-- providerConfig key from the value the CURRENT poller already reads (basic-first), so NO deployed
|
|
-- trigger changes which resource it polls. Per provider the basic-first effective value is:
|
|
-- google-drive folderId <- folderId, else manualFolderId (canonical key == basic key)
|
|
-- google-sheets spreadsheetId <- spreadsheetId, else manualSpreadsheetId
|
|
-- google-sheets sheetName <- sheetName, else manualSheetName
|
|
-- google-calendar calendarId <- calendarId, else manualCalendarId
|
|
-- table tableId <- tableSelector, else manualTableId (canonical key is distinct)
|
|
-- For the Google triggers the canonical key IS the basic subblock key, so a row whose canonical key
|
|
-- is already set is left untouched (it already equals the basic-first read); only rows where it is
|
|
-- absent are filled from the advanced key. The table canonical key (tableId) was never written
|
|
-- before, so it is filled from tableSelector/manualTableId.
|
|
--
|
|
-- Idempotent: every statement only writes where the canonical key is still empty, so a replay (a
|
|
-- failed migration re-runs unjournaled files from the top) is a no-op. Bounded: each UPDATE is scoped
|
|
-- to one provider and the empty-canonical predicate, touching only un-backfilled rows. Safe under
|
|
-- concurrent writes: the still-live previous app version never writes these canonical keys (it writes
|
|
-- the raw subblock keys), and any row it inserts after this runs is handled by the pollers'
|
|
-- transitional basic-first fallback until its next redeploy. providerConfig is a `json` column, so it
|
|
-- is cast to jsonb for the `||` merge and back to json for storage.
|
|
UPDATE "webhook"
|
|
SET "provider_config" = (
|
|
COALESCE(("provider_config")::jsonb, '{}'::jsonb)
|
|
|| jsonb_build_object('folderId', ("provider_config")::jsonb ->> 'manualFolderId')
|
|
)::json
|
|
WHERE "provider" = 'google-drive'
|
|
AND NULLIF(("provider_config")::jsonb ->> 'folderId', '') IS NULL
|
|
AND NULLIF(("provider_config")::jsonb ->> 'manualFolderId', '') IS NOT NULL;
|
|
--> statement-breakpoint
|
|
UPDATE "webhook"
|
|
SET "provider_config" = (
|
|
COALESCE(("provider_config")::jsonb, '{}'::jsonb)
|
|
|| jsonb_build_object('spreadsheetId', ("provider_config")::jsonb ->> 'manualSpreadsheetId')
|
|
)::json
|
|
WHERE "provider" = 'google-sheets'
|
|
AND NULLIF(("provider_config")::jsonb ->> 'spreadsheetId', '') IS NULL
|
|
AND NULLIF(("provider_config")::jsonb ->> 'manualSpreadsheetId', '') IS NOT NULL;
|
|
--> statement-breakpoint
|
|
UPDATE "webhook"
|
|
SET "provider_config" = (
|
|
COALESCE(("provider_config")::jsonb, '{}'::jsonb)
|
|
|| jsonb_build_object('sheetName', ("provider_config")::jsonb ->> 'manualSheetName')
|
|
)::json
|
|
WHERE "provider" = 'google-sheets'
|
|
AND NULLIF(("provider_config")::jsonb ->> 'sheetName', '') IS NULL
|
|
AND NULLIF(("provider_config")::jsonb ->> 'manualSheetName', '') IS NOT NULL;
|
|
--> statement-breakpoint
|
|
UPDATE "webhook"
|
|
SET "provider_config" = (
|
|
COALESCE(("provider_config")::jsonb, '{}'::jsonb)
|
|
|| jsonb_build_object('calendarId', ("provider_config")::jsonb ->> 'manualCalendarId')
|
|
)::json
|
|
WHERE "provider" = 'google-calendar'
|
|
AND NULLIF(("provider_config")::jsonb ->> 'calendarId', '') IS NULL
|
|
AND NULLIF(("provider_config")::jsonb ->> 'manualCalendarId', '') IS NOT NULL;
|
|
--> statement-breakpoint
|
|
UPDATE "webhook"
|
|
SET "provider_config" = (
|
|
COALESCE(("provider_config")::jsonb, '{}'::jsonb)
|
|
|| jsonb_build_object('tableId', COALESCE(
|
|
NULLIF(("provider_config")::jsonb ->> 'tableSelector', ''),
|
|
NULLIF(("provider_config")::jsonb ->> 'manualTableId', '')
|
|
))
|
|
)::json
|
|
WHERE "provider" = 'table'
|
|
AND NULLIF(("provider_config")::jsonb ->> 'tableId', '') IS NULL
|
|
AND COALESCE(
|
|
NULLIF(("provider_config")::jsonb ->> 'tableSelector', ''),
|
|
NULLIF(("provider_config")::jsonb ->> 'manualTableId', '')
|
|
) IS NOT NULL;
|