-- ======================
-- HRIS: Employee
-- ======================
CREATE TABLE "unified_hris_employee" (
  "unified_connection_id"  VARCHAR NOT NULL,
  "unified_webhook_id"     VARCHAR NOT NULL,
  "unified_external_xref"  VARCHAR,
  "unified_integration_type" VARCHAR NOT NULL,
  "unified_raw_id"         VARCHAR,
  "unified_id"             VARCHAR NOT NULL,
  "id"                     VARCHAR,
  "created_at"             TIMESTAMP_NTZ,
  "updated_at"             TIMESTAMP_NTZ,
  "name"                   VARCHAR,
  "first_name"             VARCHAR,
  "last_name"              VARCHAR,
  "emails"                 VARIANT,
  "title"                  VARCHAR,
  "manager_id"             VARCHAR,
  "employment_status"      VARCHAR,
  "gender"                 VARCHAR,
  "telephones"             VARIANT,
  "date_of_birth"          TIMESTAMP_NTZ,
  "employee_number"        VARCHAR,
  "hired_at"               TIMESTAMP_NTZ,
  "terminated_at"          TIMESTAMP_NTZ,
  "termination_reason"     VARCHAR,
  "marital_status"         VARCHAR,
  "employment_type"        VARCHAR,
  "address"                VARIANT,
  "language_locale"        VARCHAR,
  "currency"               VARCHAR,
  "timezone"               VARCHAR,
  "image_url"              VARCHAR,
  "company_id"             VARCHAR,
  "pronouns"               VARCHAR,
  "employee_roles"         VARIANT,
  "compensation"           VARIANT,
  "salutation"             VARCHAR,
  "bio"                    VARCHAR,
  "ssn_sin"                VARCHAR,
  "groups"                 VARIANT,
  "locations"              VARIANT,
  "metadata"               VARIANT,
  "storage_quota_allocated" FLOAT,
  "storage_quota_used"     FLOAT,
  "storage_quota_available" FLOAT,
  "relationships"          VARIANT,
  "has_mfa"                BOOLEAN,
  "timeoff_days_total"     FLOAT,
  "timeoff_days_used"      FLOAT,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- HRIS: Company
-- ======================
CREATE TABLE "unified_hris_company" (
  "unified_connection_id"  VARCHAR NOT NULL,
  "unified_webhook_id"     VARCHAR NOT NULL,
  "unified_external_xref"  VARCHAR,
  "unified_integration_type" VARCHAR NOT NULL,
  "unified_raw_id"         VARCHAR,
  "unified_id"             VARCHAR NOT NULL,
  "id"                     VARCHAR,
  "created_at"             TIMESTAMP_NTZ,
  "updated_at"             TIMESTAMP_NTZ,
  "name"                   VARCHAR,
  "legal_name"             VARCHAR,
  "address"                VARIANT,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- HRIS: Location
-- ======================
CREATE TABLE "unified_hris_location" (
  "unified_connection_id"  VARCHAR NOT NULL,
  "unified_webhook_id"     VARCHAR NOT NULL,
  "unified_external_xref"  VARCHAR,
  "unified_integration_type" VARCHAR NOT NULL,
  "unified_raw_id"         VARCHAR,
  "unified_id"             VARCHAR NOT NULL,
  "id"                     VARCHAR,
  "created_at"             TIMESTAMP_NTZ,
  "updated_at"             TIMESTAMP_NTZ,
  "name"                   VARCHAR,
  "description"            VARCHAR,
  "address"                VARIANT,
  "parent_id"              VARCHAR,
  "external_identifier"    VARCHAR,
  "telephones"             VARIANT,
  "timezone"               VARCHAR,
  "currency"               VARCHAR,
  "language_locale"        VARCHAR,
  "is_active"              BOOLEAN,
  "is_hq"                  BOOLEAN,
  "company_id"             VARCHAR,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- HRIS: Group
-- ======================
CREATE TABLE "unified_hris_group" (
  "unified_connection_id"  VARCHAR NOT NULL,
  "unified_webhook_id"     VARCHAR NOT NULL,
  "unified_external_xref"  VARCHAR,
  "unified_integration_type" VARCHAR NOT NULL,
  "unified_raw_id"         VARCHAR,
  "unified_id"             VARCHAR NOT NULL,
  "id"                     VARCHAR,
  "created_at"             TIMESTAMP_NTZ,
  "updated_at"             TIMESTAMP_NTZ,
  "name"                   VARCHAR,
  "description"            VARCHAR,
  "parent_id"              VARCHAR,
  "type"                   VARCHAR,
  "user_ids"               VARIANT,
  "manager_ids"            VARIANT,
  "is_active"              BOOLEAN,
  "company_id"             VARCHAR,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- HRIS: Timeoff
-- ======================
CREATE TABLE "unified_hris_timeoff" (
  "unified_connection_id"  VARCHAR NOT NULL,
  "unified_webhook_id"     VARCHAR NOT NULL,
  "unified_external_xref"  VARCHAR,
  "unified_integration_type" VARCHAR NOT NULL,
  "unified_raw_id"         VARCHAR,
  "unified_id"             VARCHAR NOT NULL,
  "id"                     VARCHAR,
  "created_at"             TIMESTAMP_NTZ,
  "updated_at"             TIMESTAMP_NTZ,
  "user_id"                VARCHAR,
  "company_id"             VARCHAR,
  "start_at"               TIMESTAMP_NTZ,
  "end_at"                 TIMESTAMP_NTZ,
  "is_paid"                BOOLEAN,
  "status"                 VARCHAR,
  "approver_user_id"       VARCHAR,
  "approved_at"            TIMESTAMP_NTZ,
  "comments"               VARCHAR,
  "reason"                 VARCHAR,
  "type"                   VARCHAR,
  "duration"               FLOAT,
  "duration_type"          VARCHAR,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- HRIS: Payslip
-- ======================
CREATE TABLE "unified_hris_payslip" (
  "unified_connection_id"  VARCHAR NOT NULL,
  "unified_webhook_id"     VARCHAR NOT NULL,
  "unified_external_xref"  VARCHAR,
  "unified_integration_type" VARCHAR NOT NULL,
  "unified_raw_id"         VARCHAR,
  "unified_id"             VARCHAR NOT NULL,
  "id"                     VARCHAR,
  "created_at"             TIMESTAMP_NTZ,
  "updated_at"             TIMESTAMP_NTZ,
  "user_id"                VARCHAR,
  "company_id"             VARCHAR,
  "payment_reference"      VARCHAR,
  "payment_type"           VARCHAR,
  "paid_at"                TIMESTAMP_NTZ,
  "start_at"               TIMESTAMP_NTZ,
  "end_at"                 TIMESTAMP_NTZ,
  "currency"               VARCHAR,
  "gross_amount"           FLOAT,
  "net_amount"             FLOAT,
  "details"                VARIANT,
  "deduction"              VARIANT,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- HRIS: Device
-- ======================
CREATE TABLE "unified_hris_device" (
  "unified_connection_id"  VARCHAR NOT NULL,
  "unified_webhook_id"     VARCHAR NOT NULL,
  "unified_external_xref"  VARCHAR,
  "unified_integration_type" VARCHAR NOT NULL,
  "unified_raw_id"         VARCHAR,
  "unified_id"             VARCHAR NOT NULL,
  "id"                     VARCHAR,
  "created_at"             TIMESTAMP_NTZ,
  "updated_at"             TIMESTAMP_NTZ,
  "name"                   VARCHAR,
  "asset_tag"              VARCHAR,
  "version"                VARCHAR,
  "manufacturer"           VARCHAR,
  "model"                  VARCHAR,
  "os"                     VARCHAR,
  "os_version"             VARCHAR,
  "user_ids"               VARIANT,
  "admin_user_ids"         VARIANT,
  "location_id"            VARCHAR,
  "has_antivirus"          BOOLEAN,
  "has_password_manager"   BOOLEAN,
  "has_firewall"           BOOLEAN,
  "has_hd_encrypted"       BOOLEAN,
  "has_screenlock"         BOOLEAN,
  "is_missing"             BOOLEAN,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- HRIS: Timeshift
-- ======================
CREATE TABLE "unified_hris_timeshift" (
  "unified_connection_id"  VARCHAR NOT NULL,
  "unified_webhook_id"     VARCHAR NOT NULL,
  "unified_external_xref"  VARCHAR,
  "unified_integration_type" VARCHAR NOT NULL,
  "unified_raw_id"         VARCHAR,
  "unified_id"             VARCHAR NOT NULL,
  "id"                     VARCHAR,
  "created_at"             TIMESTAMP_NTZ,
  "updated_at"             TIMESTAMP_NTZ,
  "employee_user_id"       VARCHAR,
  "start_at"               TIMESTAMP_NTZ,
  "end_at"                 TIMESTAMP_NTZ,
  "location_id"            VARCHAR,
  "company_id"             VARCHAR,
  "group_id"               VARCHAR,
  "compensation"           VARIANT,
  "approver_user_id"       VARCHAR,
  "approved_at"            TIMESTAMP_NTZ,
  "hours"                  FLOAT,
  "is_approved"            BOOLEAN,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- HRIS: Benefit
-- ======================
CREATE TABLE "unified_hris_benefit" (
  "unified_connection_id"  VARCHAR NOT NULL,
  "unified_webhook_id"     VARCHAR NOT NULL,
  "unified_external_xref"  VARCHAR,
  "unified_integration_type" VARCHAR NOT NULL,
  "unified_raw_id"         VARCHAR,
  "unified_id"             VARCHAR NOT NULL,
  "id"                     VARCHAR,
  "created_at"             TIMESTAMP_NTZ,
  "updated_at"             TIMESTAMP_NTZ,
  "name"                   VARCHAR,
  "description"            VARCHAR,
  "company_id"             VARCHAR,
  "type"                   VARCHAR,
  "tax"                    VARCHAR,
  "frequency"              VARCHAR,
  "is_active"              BOOLEAN,
  "employer_contribution_type" VARCHAR,
  "employer_contribution_amount" FLOAT,
  "employer_contribution_max_amount" FLOAT,
  "coverage_level"         VARCHAR,
  "currency"               VARCHAR,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- HRIS: Deduction
-- ======================
CREATE TABLE "unified_hris_deduction" (
  "unified_connection_id"  VARCHAR NOT NULL,
  "unified_webhook_id"     VARCHAR NOT NULL,
  "unified_external_xref"  VARCHAR,
  "unified_integration_type" VARCHAR NOT NULL,
  "unified_raw_id"         VARCHAR,
  "unified_id"             VARCHAR NOT NULL,
  "id"                     VARCHAR,
  "created_at"             TIMESTAMP_NTZ,
  "updated_at"             TIMESTAMP_NTZ,
  "user_id"                VARCHAR,
  "company_id"             VARCHAR,
  "benefit_id"             VARCHAR,
  "amount"                 FLOAT,
  "type"                   VARCHAR,
  "coverage_level"         VARCHAR,
  "frequency"              VARCHAR,
  "start_at"               TIMESTAMP_NTZ,
  "end_at"                 TIMESTAMP_NTZ,
  "is_active"              BOOLEAN,
  "notes"                  VARCHAR,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- HRIS: Bankaccount
-- ======================
CREATE TABLE "unified_hris_bankaccount" (
  "unified_connection_id"  VARCHAR NOT NULL,
  "unified_webhook_id"     VARCHAR NOT NULL,
  "unified_external_xref"  VARCHAR,
  "unified_integration_type" VARCHAR NOT NULL,
  "unified_raw_id"         VARCHAR,
  "unified_id"             VARCHAR NOT NULL,
  "id"                     VARCHAR,
  "created_at"             TIMESTAMP_NTZ,
  "updated_at"             TIMESTAMP_NTZ,
  "user_id"                VARCHAR,
  "company_id"             VARCHAR,
  "account_type"           VARCHAR,
  "bank_name"              VARCHAR,
  "routing_number"         VARCHAR,
  "account_number"         VARCHAR,
  "account_number_last4"   VARCHAR,
  "name"                   VARCHAR,
  "is_primary"             BOOLEAN,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- HRIS: Taxonomy
-- ======================
CREATE TABLE "unified_hris_taxonomy" (
  "unified_connection_id"  VARCHAR NOT NULL,
  "unified_webhook_id"     VARCHAR NOT NULL,
  "unified_external_xref"  VARCHAR,
  "unified_integration_type" VARCHAR NOT NULL,
  "unified_raw_id"         VARCHAR,
  "unified_id"             VARCHAR NOT NULL,
  "id"                     VARCHAR,
  "created_at"             TIMESTAMP_NTZ,
  "updated_at"             TIMESTAMP_NTZ,
  "type"                   VARCHAR,
  "name"                   VARCHAR,
  "description"            VARCHAR,
  "domain"                 VARCHAR,
  "category"               VARCHAR,
  "subcategory"            VARCHAR,
  "parent_id"              VARCHAR,
  "alternative_names"      VARIANT,
  "url"                    VARCHAR,
  "role_ids"               VARIANT,
  "is_active"              BOOLEAN,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- HRIS: Document
-- ======================
CREATE TABLE "unified_hris_document" (
  "unified_connection_id"  VARCHAR NOT NULL,
  "unified_webhook_id"     VARCHAR NOT NULL,
  "unified_external_xref"  VARCHAR,
  "unified_integration_type" VARCHAR NOT NULL,
  "unified_raw_id"         VARCHAR,
  "unified_id"             VARCHAR NOT NULL,
  "id"                     VARCHAR,
  "created_at"             TIMESTAMP_NTZ,
  "updated_at"             TIMESTAMP_NTZ,
  "document_url"           VARCHAR,
  "document_data"          VARCHAR,
  "filename"               VARCHAR,
  "type"                   VARCHAR,
  "user_id"                VARCHAR,
  "company_id"             VARCHAR,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
