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

RENAME TABLE `sub_account_admins` TO `sub_account_users`;

CREATE TABLE `account_super_admin`
(
    `account_idfk`         INT UNSIGNED NOT NULL,
    `invoice_account_idfk` INT UNSIGNED NOT NULL,
    CONSTRAINT `account_super_admin_pk`
        PRIMARY KEY (`account_idfk`, `invoice_account_idfk`),
    CONSTRAINT `account_super_admin_accounts_id_fk`
        FOREIGN KEY (`account_idfk`) REFERENCES `accounts` (`id`)
            ON UPDATE CASCADE ON DELETE CASCADE,
    CONSTRAINT `account_super_admin_invoice_accounts_id_fk`
        FOREIGN KEY (`invoice_account_idfk`) REFERENCES `invoice_accounts` (`id`)
            ON UPDATE CASCADE ON DELETE CASCADE
);