insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.administered_vaccines'::regclass::oid as table_oid,
    'public' as table_schema,
    'administered_vaccines' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.administered_vaccines t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.appointment_schedules'::regclass::oid as table_oid,
    'public' as table_schema,
    'appointment_schedules' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.appointment_schedules t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.appointments'::regclass::oid as table_oid,
    'public' as table_schema,
    'appointments' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.appointments t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.assets'::regclass::oid as table_oid,
    'public' as table_schema,
    'assets' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.assets t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.certifiable_vaccines'::regclass::oid as table_oid,
    'public' as table_schema,
    'certifiable_vaccines' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.certifiable_vaccines t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.certificate_notifications'::regclass::oid as table_oid,
    'public' as table_schema,
    'certificate_notifications' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.certificate_notifications t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.contributing_death_causes'::regclass::oid as table_oid,
    'public' as table_schema,
    'contributing_death_causes' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.contributing_death_causes t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.death_revert_logs'::regclass::oid as table_oid,
    'public' as table_schema,
    'death_revert_logs' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.death_revert_logs t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.departments'::regclass::oid as table_oid,
    'public' as table_schema,
    'departments' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.departments t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.discharges'::regclass::oid as table_oid,
    'public' as table_schema,
    'discharges' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.discharges t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.document_metadata'::regclass::oid as table_oid,
    'public' as table_schema,
    'document_metadata' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.document_metadata t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.encounter_diagnoses'::regclass::oid as table_oid,
    'public' as table_schema,
    'encounter_diagnoses' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.encounter_diagnoses t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.encounter_diets'::regclass::oid as table_oid,
    'public' as table_schema,
    'encounter_diets' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.encounter_diets t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.encounter_pause_prescription_histories'::regclass::oid as table_oid,
    'public' as table_schema,
    'encounter_pause_prescription_histories' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.encounter_pause_prescription_histories t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.encounter_pause_prescriptions'::regclass::oid as table_oid,
    'public' as table_schema,
    'encounter_pause_prescriptions' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.encounter_pause_prescriptions t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.encounter_prescriptions'::regclass::oid as table_oid,
    'public' as table_schema,
    'encounter_prescriptions' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.encounter_prescriptions t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.encounters'::regclass::oid as table_oid,
    'public' as table_schema,
    'encounters' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.encounters t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.facilities'::regclass::oid as table_oid,
    'public' as table_schema,
    'facilities' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.facilities t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.imaging_area_external_codes'::regclass::oid as table_oid,
    'public' as table_schema,
    'imaging_area_external_codes' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.imaging_area_external_codes t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.imaging_request_areas'::regclass::oid as table_oid,
    'public' as table_schema,
    'imaging_request_areas' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.imaging_request_areas t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.imaging_requests'::regclass::oid as table_oid,
    'public' as table_schema,
    'imaging_requests' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.imaging_requests t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.imaging_results'::regclass::oid as table_oid,
    'public' as table_schema,
    'imaging_results' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.imaging_results t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.invoice_discounts'::regclass::oid as table_oid,
    'public' as table_schema,
    'invoice_discounts' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.invoice_discounts t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.invoice_insurer_payments'::regclass::oid as table_oid,
    'public' as table_schema,
    'invoice_insurer_payments' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.invoice_insurer_payments t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.invoice_insurers'::regclass::oid as table_oid,
    'public' as table_schema,
    'invoice_insurers' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.invoice_insurers t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.invoice_item_discounts'::regclass::oid as table_oid,
    'public' as table_schema,
    'invoice_item_discounts' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.invoice_item_discounts t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.invoice_items'::regclass::oid as table_oid,
    'public' as table_schema,
    'invoice_items' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.invoice_items t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.invoice_patient_payments'::regclass::oid as table_oid,
    'public' as table_schema,
    'invoice_patient_payments' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.invoice_patient_payments t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.invoice_payments'::regclass::oid as table_oid,
    'public' as table_schema,
    'invoice_payments' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.invoice_payments t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.invoice_products'::regclass::oid as table_oid,
    'public' as table_schema,
    'invoice_products' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.invoice_products t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.invoices'::regclass::oid as table_oid,
    'public' as table_schema,
    'invoices' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.invoices t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.ips_requests'::regclass::oid as table_oid,
    'public' as table_schema,
    'ips_requests' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.ips_requests t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.lab_requests'::regclass::oid as table_oid,
    'public' as table_schema,
    'lab_requests' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.lab_requests t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.lab_test_panel_lab_test_types'::regclass::oid as table_oid,
    'public' as table_schema,
    'lab_test_panel_lab_test_types' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.lab_test_panel_lab_test_types t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.lab_test_panel_requests'::regclass::oid as table_oid,
    'public' as table_schema,
    'lab_test_panel_requests' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.lab_test_panel_requests t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.lab_test_panels'::regclass::oid as table_oid,
    'public' as table_schema,
    'lab_test_panels' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.lab_test_panels t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.lab_test_types'::regclass::oid as table_oid,
    'public' as table_schema,
    'lab_test_types' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.lab_test_types t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.lab_tests'::regclass::oid as table_oid,
    'public' as table_schema,
    'lab_tests' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.lab_tests t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.location_groups'::regclass::oid as table_oid,
    'public' as table_schema,
    'location_groups' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.location_groups t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.locations'::regclass::oid as table_oid,
    'public' as table_schema,
    'locations' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.locations t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.medication_administration_record_doses'::regclass::oid as table_oid,
    'public' as table_schema,
    'medication_administration_record_doses' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.medication_administration_record_doses t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.medication_administration_records'::regclass::oid as table_oid,
    'public' as table_schema,
    'medication_administration_records' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.medication_administration_records t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.notifications'::regclass::oid as table_oid,
    'public' as table_schema,
    'notifications' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.notifications t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.patient_additional_data'::regclass::oid as table_oid,
    'public' as table_schema,
    'patient_additional_data' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.patient_additional_data t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.patient_allergies'::regclass::oid as table_oid,
    'public' as table_schema,
    'patient_allergies' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.patient_allergies t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.patient_birth_data'::regclass::oid as table_oid,
    'public' as table_schema,
    'patient_birth_data' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.patient_birth_data t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.patient_care_plans'::regclass::oid as table_oid,
    'public' as table_schema,
    'patient_care_plans' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.patient_care_plans t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.patient_communications'::regclass::oid as table_oid,
    'public' as table_schema,
    'patient_communications' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.patient_communications t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.patient_conditions'::regclass::oid as table_oid,
    'public' as table_schema,
    'patient_conditions' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.patient_conditions t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.patient_contacts'::regclass::oid as table_oid,
    'public' as table_schema,
    'patient_contacts' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.patient_contacts t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.patient_death_data'::regclass::oid as table_oid,
    'public' as table_schema,
    'patient_death_data' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.patient_death_data t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.patient_facilities'::regclass::oid as table_oid,
    'public' as table_schema,
    'patient_facilities' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.patient_facilities t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.patient_family_histories'::regclass::oid as table_oid,
    'public' as table_schema,
    'patient_family_histories' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.patient_family_histories t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.patient_field_definition_categories'::regclass::oid as table_oid,
    'public' as table_schema,
    'patient_field_definition_categories' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.patient_field_definition_categories t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.patient_field_definitions'::regclass::oid as table_oid,
    'public' as table_schema,
    'patient_field_definitions' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.patient_field_definitions t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.patient_field_values'::regclass::oid as table_oid,
    'public' as table_schema,
    'patient_field_values' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.patient_field_values t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.patient_issues'::regclass::oid as table_oid,
    'public' as table_schema,
    'patient_issues' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.patient_issues t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.patient_ongoing_prescriptions'::regclass::oid as table_oid,
    'public' as table_schema,
    'patient_ongoing_prescriptions' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.patient_ongoing_prescriptions t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.patient_program_registration_conditions'::regclass::oid as table_oid,
    'public' as table_schema,
    'patient_program_registration_conditions' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.patient_program_registration_conditions t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.patient_program_registrations'::regclass::oid as table_oid,
    'public' as table_schema,
    'patient_program_registrations' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.patient_program_registrations t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.patient_secondary_ids'::regclass::oid as table_oid,
    'public' as table_schema,
    'patient_secondary_ids' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.patient_secondary_ids t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.patients'::regclass::oid as table_oid,
    'public' as table_schema,
    'patients' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.patients t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.permissions'::regclass::oid as table_oid,
    'public' as table_schema,
    'permissions' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.permissions t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.prescriptions'::regclass::oid as table_oid,
    'public' as table_schema,
    'prescriptions' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.prescriptions t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.procedures'::regclass::oid as table_oid,
    'public' as table_schema,
    'procedures' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.procedures t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.program_data_elements'::regclass::oid as table_oid,
    'public' as table_schema,
    'program_data_elements' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.program_data_elements t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.program_registries'::regclass::oid as table_oid,
    'public' as table_schema,
    'program_registries' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.program_registries t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.program_registry_clinical_statuses'::regclass::oid as table_oid,
    'public' as table_schema,
    'program_registry_clinical_statuses' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.program_registry_clinical_statuses t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.program_registry_condition_categories'::regclass::oid as table_oid,
    'public' as table_schema,
    'program_registry_condition_categories' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.program_registry_condition_categories t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.program_registry_conditions'::regclass::oid as table_oid,
    'public' as table_schema,
    'program_registry_conditions' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.program_registry_conditions t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.programs'::regclass::oid as table_oid,
    'public' as table_schema,
    'programs' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.programs t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.reference_data'::regclass::oid as table_oid,
    'public' as table_schema,
    'reference_data' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.reference_data t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.reference_data_relations'::regclass::oid as table_oid,
    'public' as table_schema,
    'reference_data_relations' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.reference_data_relations t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.reference_drugs'::regclass::oid as table_oid,
    'public' as table_schema,
    'reference_drugs' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.reference_drugs t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.reference_medication_templates'::regclass::oid as table_oid,
    'public' as table_schema,
    'reference_medication_templates' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.reference_medication_templates t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.referrals'::regclass::oid as table_oid,
    'public' as table_schema,
    'referrals' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.referrals t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.report_definition_versions'::regclass::oid as table_oid,
    'public' as table_schema,
    'report_definition_versions' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.report_definition_versions t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.report_definitions'::regclass::oid as table_oid,
    'public' as table_schema,
    'report_definitions' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.report_definitions t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.report_requests'::regclass::oid as table_oid,
    'public' as table_schema,
    'report_requests' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.report_requests t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.roles'::regclass::oid as table_oid,
    'public' as table_schema,
    'roles' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.roles t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.scheduled_vaccines'::regclass::oid as table_oid,
    'public' as table_schema,
    'scheduled_vaccines' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.scheduled_vaccines t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.settings'::regclass::oid as table_oid,
    'public' as table_schema,
    'settings' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.settings t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.survey_response_answers'::regclass::oid as table_oid,
    'public' as table_schema,
    'survey_response_answers' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.survey_response_answers t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.survey_responses'::regclass::oid as table_oid,
    'public' as table_schema,
    'survey_responses' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.survey_responses t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.survey_screen_components'::regclass::oid as table_oid,
    'public' as table_schema,
    'survey_screen_components' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.survey_screen_components t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.surveys'::regclass::oid as table_oid,
    'public' as table_schema,
    'surveys' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.surveys t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.task_designations'::regclass::oid as table_oid,
    'public' as table_schema,
    'task_designations' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.task_designations t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.task_template_designations'::regclass::oid as table_oid,
    'public' as table_schema,
    'task_template_designations' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.task_template_designations t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.task_templates'::regclass::oid as table_oid,
    'public' as table_schema,
    'task_templates' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.task_templates t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.tasks'::regclass::oid as table_oid,
    'public' as table_schema,
    'tasks' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.tasks t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.templates'::regclass::oid as table_oid,
    'public' as table_schema,
    'templates' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.templates t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.translated_strings'::regclass::oid as table_oid,
    'public' as table_schema,
    'translated_strings' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.translated_strings t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.triages'::regclass::oid as table_oid,
    'public' as table_schema,
    'triages' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.triages t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.user_designations'::regclass::oid as table_oid,
    'public' as table_schema,
    'user_designations' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.user_designations t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.user_facilities'::regclass::oid as table_oid,
    'public' as table_schema,
    'user_facilities' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.user_facilities t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.user_preferences'::regclass::oid as table_oid,
    'public' as table_schema,
    'user_preferences' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.user_preferences t;

insert into logs.changes (
    table_oid, table_schema, table_name,
    logged_at, record_created_at, record_updated_at, record_deleted_at,
    updated_at_sync_tick, updated_by_user_id, record_id,
    record_data
  )
  select
    'public.users'::regclass::oid as table_oid,
    'public' as table_schema,
    'users' as table_name,

    t.updated_at as logged_at,
    coalesce(t.created_at, t.updated_at) as record_created_at,
    coalesce(t.updated_at, t.created_at) as record_updated_at,
    t.deleted_at as record_deleted_at,

    t.updated_at_sync_tick as updated_at_sync_tick,
    uuid_nil() as updated_by_user_id,
    t.id::text as record_id,

    to_jsonb(t) as record_data
  from public.users t;
