CREATE TABLE IF NOT EXISTS #__md_deposits (
    id                   INT UNSIGNED        NOT NULL AUTO_INCREMENT,
    creation_date        DATETIME            NOT NULL,
    deposit              MEDIUMBLOB          NULL,
    external_deposit_id  INTEGER UNSIGNED    NULL,
    printed              TINYINT(1)          NOT NULL DEFAULT 0,
    PRIMARY KEY (id),
    INDEX external_deposit_id (external_deposit_id)
);

CREATE TABLE IF NOT EXISTS #__md_labels (
    id               INTEGER UNSIGNED    NOT NULL AUTO_INCREMENT,
    order_id         INTEGER UNSIGNED    NOT NULL,
    creation_date    DATETIME            NOT NULL,
    label            MEDIUMBLOB          NULL,
    label_id         INTEGER UNSIGNED    NULL,
    tracking_number  VARCHAR(255)        NULL,
    tracking_url     TEXT                NULL,
    printed          TINYINT(1)          NOT NULL DEFAULT 0,
    status_code      TINYINT             NULL,
    deposit_id       INT UNSIGNED        NULL,
    sending_id       INT UNSIGNED        NULL,
    PRIMARY KEY (id),
    INDEX order_id (order_id),
    INDEX tracking_number (tracking_number),
    FOREIGN KEY (deposit_id) REFERENCES #__md_deposits(id)
);
