-- CREATE DATABASE desarrollo;
CREATE TABLE IF NOT EXISTS wh_shipments_labels (
    id            BIGSERIAL PRIMARY KEY,
    provider      TEXT      NOT NULL DEFAULT 'CEX',
    country_code  CHAR(2)   NOT NULL,
    shipping_type TEXT      NOT NULL,
    shop_order_id TEXT      NOT NULL,
    label_pdf     BYTEA     NOT NULL,
    created_at    TIMESTAMPTZ NOT NULL DEFAULT now(),
    updated_at    TIMESTAMPTZ NOT NULL DEFAULT now()
    );

CREATE UNIQUE INDEX IF NOT EXISTS uq_wh_shipments_labels_by_order  ON wh_shipments_labels (shop_order_id);
CREATE INDEX        IF NOT EXISTS idx_wh_shipments_labels_created  ON wh_shipments_labels (created_at);
CREATE INDEX        IF NOT EXISTS idx_wh_shipments_labels_cc_date  ON wh_shipments_labels (country_code, created_at);
