/*
 * Copyright ©  2022 Thomas J Collinson
 * All rights reserved
 */

CREATE TABLE `past_addresses`
(
    `account_idfk`  INT UNSIGNED  NOT NULL,
    `address_id`    VARCHAR(512)  NOT NULL,
    `address`       VARCHAR(500)  NOT NULL,
    `pickup`        INT DEFAULT 0 NOT NULL,
    `destination`   INT DEFAULT 0 NOT NULL,
    `dispatch_idfk` INT UNSIGNED  NOT NULL,
    PRIMARY KEY (`account_idfk`,`address_id`, `dispatch_idfk`),
    CONSTRAINT `past_addresses_dispatch_systems_null_fk`
        FOREIGN KEY (`dispatch_idfk`) REFERENCES `dispatch_systems` (`id`)
            ON UPDATE CASCADE ON DELETE CASCADE,
    CONSTRAINT `past_addresses_ibfk_1`
        FOREIGN KEY (`account_idfk`) REFERENCES `accounts` (`id`)
            ON UPDATE CASCADE ON DELETE CASCADE
);
