36 lines
1.3 KiB
Plaintext
36 lines
1.3 KiB
Plaintext
DESCRIPTION >
|
|
Chunked backfill of entities from Postgres into entities.
|
|
Chunks by created_at (epoch ms). Cast numeric columns to match datasource schema.
|
|
|
|
NODE migrate
|
|
SQL >
|
|
%
|
|
SELECT
|
|
id,
|
|
org_id,
|
|
created_at::Int64 AS created_at,
|
|
coalesce(internal_id, '') AS internal_id,
|
|
coalesce(internal_customer_id, '') AS internal_customer_id,
|
|
env,
|
|
name,
|
|
toUInt8(if(deleted, 1, 0)) AS deleted,
|
|
internal_feature_id,
|
|
feature_id,
|
|
'read' AS __action,
|
|
toDateTime64(now(), 6) AS __commit_timestamp,
|
|
0 AS __commit_lsn,
|
|
concat('backfill-', coalesce(internal_id, '')) AS __idempotency_key
|
|
FROM postgresql(
|
|
'us-west-3.pg.psdb.cloud:5432',
|
|
'postgres',
|
|
'entities',
|
|
{{tb_secret('PG_USERNAME')}},
|
|
{{tb_secret('PG_PASSWORD')}},
|
|
'public'
|
|
)
|
|
WHERE created_at > {{Int64(start_epoch_ms, 0)}}
|
|
AND created_at <= {{Int64(end_epoch_ms, 9999999999999)}}
|
|
|
|
TYPE COPY
|
|
TARGET_DATASOURCE entities
|