-- Per-tenant settings for the private-pay workflow (LarCare), managed from Aggie > Website > Workflows:
-- the ShiftCare connection (region address, account id, API key stored encrypted) and the booking link,
-- staff emails, company name and public site address used in the workflow emails.
-- A value saved here wins over the server environment, which stays as a fallback.
-- Idempotent and additive only.

USE db_abos_v0.1;

CREATE TABLE IF NOT EXISTS dim_private_care_settings (
  tenant_id            INT           NOT NULL PRIMARY KEY,
  shiftcare_base_url   VARCHAR(200)  NULL,
  shiftcare_account_id VARCHAR(60)   NULL,
  shiftcare_api_key    TEXT          NULL COMMENT 'encrypted (v1: AES-GCM), never returned to the browser',
  sync_enabled         TINYINT(1)    NOT NULL DEFAULT 1,
  booking_url          VARCHAR(500)  NULL,
  staff_emails         VARCHAR(500)  NULL,
  company_name         VARCHAR(200)  NULL,
  site_url             VARCHAR(200)  NULL,
  updated_by           INT           NULL,
  updated_at           TIMESTAMP     NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
