-- ======================
-- COMMERCE: Item
-- ======================
CREATE TABLE "unified_commerce_item" (
  "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,
  "public_name"            VARCHAR,
  "slug"                   VARCHAR,
  "description"            VARCHAR,
  "global_code"            VARCHAR,
  "public_description"     VARCHAR,
  "is_active"              BOOLEAN,
  "is_taxable"             BOOLEAN,
  "vendor_name"            VARCHAR,
  "type"                   VARCHAR,
  "is_visible"             BOOLEAN,
  "is_featured"            BOOLEAN,
  "weight"                 FLOAT,
  "weight_unit"            VARCHAR,
  "requires_shipping"      BOOLEAN,
  "prices"                 VARIANT,
  "inventory_id"           VARCHAR,
  "total_stock"            FLOAT,
  "variants"               VARIANT,
  "tags"                   VARIANT,
  "media"                  VARIANT,
  "collection_ids"         VARIANT,
  "account_id"             VARCHAR,
  "metadata"               VARIANT,
  "collections"            VARIANT,
  "taxrate_id"             VARCHAR,
  "location_id"            VARCHAR,
  "duration"               FLOAT,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- COMMERCE: Collection
-- ======================
CREATE TABLE "unified_commerce_collection" (
  "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,
  "public_name"            VARCHAR,
  "description"            VARCHAR,
  "public_description"     VARCHAR,
  "media"                  VARIANT,
  "is_visible"             BOOLEAN,
  "is_active"              BOOLEAN,
  "is_featured"            BOOLEAN,
  "tags"                   VARIANT,
  "type"                   VARCHAR,
  "parent_id"              VARCHAR,
  "metadata"               VARIANT,
  "item_metadata"          VARIANT,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- COMMERCE: Inventory
-- ======================
CREATE TABLE "unified_commerce_inventory" (
  "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,
  "updated_at"             TIMESTAMP_NTZ,
  "item_id"                VARCHAR,
  "item_variant_id"        VARCHAR,
  "item_option_id"         VARCHAR,
  "location_id"            VARCHAR,
  "available"              FLOAT,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- COMMERCE: Location
-- ======================
CREATE TABLE "unified_commerce_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,
  "address"                VARIANT,
  "description"            VARCHAR,
  "is_active"              BOOLEAN,
  "language_locale"        VARCHAR,
  "parent_id"              VARCHAR,
  "currency"               VARCHAR,
  "location_type"          VARCHAR,
  "telephones"             VARIANT,
  "rating"                 FLOAT,
  "review_count"           FLOAT,
  "price_level"            VARCHAR,
  "latitude"               FLOAT,
  "longitude"              FLOAT,
  "image_url"              VARCHAR,
  "web_url"                VARCHAR,
  "media"                  VARIANT,
  "raw"                    VARIANT,
  "categories"             VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- COMMERCE: Review
-- ======================
CREATE TABLE "unified_commerce_review" (
  "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,
  "item_id"                VARCHAR,
  "item_variant_id"        VARCHAR,
  "location_id"            VARCHAR,
  "rating"                 FLOAT,
  "title"                  VARCHAR,
  "content"                VARCHAR,
  "author_name"            VARCHAR,
  "author_email"           VARCHAR,
  "author_avatar_url"      VARCHAR,
  "author_location"        VARCHAR,
  "verified_purchase"      BOOLEAN,
  "helpful_votes"          FLOAT,
  "unhelpful_votes"        FLOAT,
  "media"                  VARIANT,
  "status"                 VARCHAR,
  "is_verified"            BOOLEAN,
  "is_featured"            BOOLEAN,
  "is_public"              BOOLEAN,
  "comments"               VARIANT,
  "metadata"               VARIANT,
  "url"                    VARCHAR,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- COMMERCE: Reservation
-- ======================
CREATE TABLE "unified_commerce_reservation" (
  "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,
  "location_id"            VARCHAR,
  "start_at"               TIMESTAMP_NTZ,
  "end_at"                 TIMESTAMP_NTZ,
  "size"                   FLOAT,
  "status"                 VARCHAR,
  "guest_name"             VARCHAR,
  "guest_phone"            VARCHAR,
  "guest_email"            VARCHAR,
  "notes"                  VARCHAR,
  "item_id"                VARCHAR,
  "item_name"              VARCHAR,
  "staff_user_id"          VARCHAR,
  "staff_name"             VARCHAR,
  "created_at"             TIMESTAMP_NTZ,
  "updated_at"             TIMESTAMP_NTZ,
  "url"                    VARCHAR,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- COMMERCE: Availability
-- ======================
CREATE TABLE "unified_commerce_availability" (
  "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,
  "location_id"            VARCHAR,
  "start_at"               TIMESTAMP_NTZ,
  "end_at"                 TIMESTAMP_NTZ,
  "size"                   FLOAT,
  "item_id"                VARCHAR,
  "staff_user_id"          VARCHAR,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- COMMERCE: Saleschannel
-- ======================
CREATE TABLE "unified_commerce_saleschannel" (
  "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,
  "slug"                   VARCHAR,
  "description"            VARCHAR,
  "is_active"              BOOLEAN,
  "collections"            VARIANT,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- COMMERCE: Itemvariant
-- ======================
CREATE TABLE "unified_commerce_itemvariant" (
  "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,
  "public_name"            VARCHAR,
  "description"            VARCHAR,
  "public_description"     VARCHAR,
  "sku"                    VARCHAR,
  "is_active"              BOOLEAN,
  "is_visible"             BOOLEAN,
  "is_featured"            BOOLEAN,
  "media"                  VARIANT,
  "available_at"           TIMESTAMP_NTZ,
  "tags"                   VARIANT,
  "width"                  FLOAT,
  "height"                 FLOAT,
  "length"                 FLOAT,
  "weight"                 FLOAT,
  "size_unit"              VARCHAR,
  "weight_unit"            VARCHAR,
  "total_stock"            FLOAT,
  "prices"                 VARIANT,
  "options"                VARIANT,
  "inventory_id"           VARCHAR,
  "requires_shipping"      BOOLEAN,
  "metadata"               VARIANT,
  "items"                  VARIANT,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
