CREATE SINK alinma_bff.orders_sink AS
SELECT
order_id,
etag,
client_order_id,
customer_relationship_id,
portfolio_id,
security_account_id,
asset_id,
order_side,
workflow_state,
execution_state,
termination_reason,
termination_detail,
instruction,
execution_spec,
cost_estimate,
execution_summary,
initiator,
filled_quantity,
created_at,
executed_at
FROM alinma_bff.orders_mv
WITH (
connector='postgres',
host='psql-nonprod-uae-derived.postgres.database.azure.com',
port='6432',
user='migration_user',
password='***',
database='alinma-int-advisor-portal-bff',
schema='advisor_portal_bff',
table='orders',
type='upsert',
force_compaction='true',
primary_key='order_id'
)