{
  "name": "royalty_accounting",
  "tables": [
    {
      "name": "ACC_8715_CONTRACT_OWNER_MAP_SNOWFLAKE",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "owner",
          "type": "varchar(25)",
          "nullable": false
        },
        {
          "name": "vendor_id",
          "type": "mediumint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "contract_id",
          "def": "UNIQUE KEY contract_id (contract_id) USING BTREE",
          "table": "ACC_8715_CONTRACT_OWNER_MAP_SNOWFLAKE",
          "columns": [
            "contract_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "contract_id",
          "type": "UNIQUE",
          "def": "UNIQUE KEY contract_id (contract_id)",
          "table": "ACC_8715_CONTRACT_OWNER_MAP_SNOWFLAKE",
          "columns": [
            "contract_id"
          ]
        }
      ],
      "def": "CREATE TABLE `ACC_8715_CONTRACT_OWNER_MAP_SNOWFLAKE` (\n  `contract_id` mediumint unsigned NOT NULL,\n  `owner` varchar(25) NOT NULL,\n  `vendor_id` mediumint unsigned NOT NULL,\n  UNIQUE KEY `contract_id` (`contract_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "ACC_8715_OWNER_SIGNING_ENTITY_MAP_GOOGLE_SHEET",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "company_code",
          "type": "int unsigned",
          "nullable": false
        },
        {
          "name": "id",
          "type": "int unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "legal_name",
          "type": "varchar(1024)",
          "nullable": false
        },
        {
          "name": "owner_type_arr",
          "type": "json",
          "nullable": false
        },
        {
          "name": "signing_entity_id",
          "type": "int unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (id) USING BTREE",
          "table": "ACC_8715_OWNER_SIGNING_ENTITY_MAP_GOOGLE_SHEET",
          "columns": [
            "id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (id)",
          "table": "ACC_8715_OWNER_SIGNING_ENTITY_MAP_GOOGLE_SHEET",
          "columns": [
            "id"
          ]
        }
      ],
      "def": "CREATE TABLE `ACC_8715_OWNER_SIGNING_ENTITY_MAP_GOOGLE_SHEET` (\n  `id` int unsigned NOT NULL AUTO_INCREMENT,\n  `legal_name` varchar(1024) NOT NULL,\n  `company_code` int unsigned NOT NULL,\n  `signing_entity_id` int unsigned NOT NULL,\n  `owner_type_arr` json NOT NULL,\n  PRIMARY KEY (`id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "ACC_8738_CONTRACT_OWNER_MAP_SNOWFLAKE",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "owner",
          "type": "varchar(25)",
          "nullable": false
        },
        {
          "name": "vendor_id",
          "type": "mediumint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "contract_id",
          "def": "UNIQUE KEY contract_id (contract_id) USING BTREE",
          "table": "ACC_8738_CONTRACT_OWNER_MAP_SNOWFLAKE",
          "columns": [
            "contract_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "contract_id",
          "type": "UNIQUE",
          "def": "UNIQUE KEY contract_id (contract_id)",
          "table": "ACC_8738_CONTRACT_OWNER_MAP_SNOWFLAKE",
          "columns": [
            "contract_id"
          ]
        }
      ],
      "def": "CREATE TABLE `ACC_8738_CONTRACT_OWNER_MAP_SNOWFLAKE` (\n  `contract_id` mediumint unsigned NOT NULL,\n  `owner` varchar(25) NOT NULL,\n  `vendor_id` mediumint unsigned NOT NULL,\n  UNIQUE KEY `contract_id` (`contract_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "abacus_event",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "abacus_event_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false,
          "default": "default_user_id"
        },
        {
          "name": "event_date",
          "type": "datetime(6)",
          "nullable": false
        },
        {
          "name": "event_name",
          "type": "varchar(32)",
          "nullable": false
        },
        {
          "name": "previous_abacus_event_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "rolled_back_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "statement_period_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "target_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "target_type",
          "type": "varchar(64)",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (abacus_event_id) USING BTREE",
          "table": "abacus_event",
          "columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_abacus_event_statement_period",
          "def": "KEY fk_abacus_event_statement_period (statement_period_id) USING BTREE",
          "table": "abacus_event",
          "columns": [
            "statement_period_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (abacus_event_id)",
          "table": "abacus_event",
          "columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_abacus_event_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "abacus_event",
          "referenced_table": "statement_period",
          "columns": [
            "statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        }
      ],
      "triggers": [
        {
          "name": "before_insert_abacus_event",
          "def": "CREATE TRIGGER before_insert_abacus_event BEFORE INSERT ON abacus_event\nFOR EACH ROW\nBEGIN\n    IF NEW.statement_period_id IS NULL THEN\n        SET NEW.statement_period_id = COALESCE(\n            (SELECT statement_period_id FROM statement_period WHERE statement_period_status = 'current'),\n            (SELECT MIN(statement_period_id) FROM statement_period WHERE statement_period_status = 'open')\n        );\n    END IF;\nEND"
        }
      ],
      "def": "CREATE TABLE `abacus_event` (\n  `abacus_event_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `statement_period_id` mediumint unsigned DEFAULT NULL,\n  `event_name` varchar(32) COLLATE utf8mb4_general_ci NOT NULL,\n  `target_type` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `target_id` mediumint unsigned NOT NULL,\n  `event_date` datetime(6) NOT NULL,\n  `previous_abacus_event_id` mediumint unsigned DEFAULT NULL,\n  `rolled_back_at` datetime DEFAULT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'default_user_id',\n  PRIMARY KEY (`abacus_event_id`),\n  KEY `fk_abacus_event_statement_period` (`statement_period_id`),\n  CONSTRAINT `fk_abacus_event_statement_period` FOREIGN KEY (`statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "abacus_state",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "abacus_state_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "action_name",
          "type": "varchar(32)",
          "nullable": false
        },
        {
          "name": "action_status",
          "type": "enum('init','running','error','complete','approved','rejected')",
          "nullable": false,
          "default": "init"
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "message",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "parent_table_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "parent_table_name",
          "type": "varchar(64)",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (abacus_state_id) USING BTREE",
          "table": "abacus_state",
          "columns": [
            "abacus_state_id"
          ]
        },
        {
          "name": "uidx_parent_action",
          "def": "UNIQUE KEY uidx_parent_action (parent_table_id, parent_table_name, action_name) USING BTREE",
          "table": "abacus_state",
          "columns": [
            "parent_table_id",
            "parent_table_name",
            "action_name"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (abacus_state_id)",
          "table": "abacus_state",
          "columns": [
            "abacus_state_id"
          ]
        },
        {
          "name": "uidx_parent_action",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_parent_action (parent_table_id, parent_table_name, action_name)",
          "table": "abacus_state",
          "columns": [
            "parent_table_id",
            "parent_table_name",
            "action_name"
          ]
        }
      ],
      "triggers": [
        {
          "name": "after_update_abacus_state",
          "def": "CREATE TRIGGER after_update_abacus_state AFTER UPDATE ON abacus_state\nFOR EACH ROW\nBEGIN\n  INSERT INTO `abacus_state_history` (\n    `abacus_state_id`,\n    `parent_table_id`,\n    `parent_table_name`,\n    `action_name`,\n    `action_status`,\n    `message`,\n    `created_by`,\n    `created_at`,\n    `last_modified_by`,\n    `last_modified`\n  ) VALUES (\n    old.abacus_state_id,\n    old.parent_table_id,\n    old.parent_table_name,\n    old.action_name,\n    old.action_status,\n    old.message,\n    old.created_by,\n    old.created_at,\n    old.last_modified_by,\n    old.last_modified\n  );\nEND"
        }
      ],
      "def": "CREATE TABLE `abacus_state` (\n  `abacus_state_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `parent_table_id` mediumint unsigned NOT NULL,\n  `parent_table_name` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `action_name` varchar(32) COLLATE utf8mb4_general_ci NOT NULL,\n  `action_status` enum('init','running','error','complete','approved','rejected') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'init',\n  `message` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`abacus_state_id`),\n  UNIQUE KEY `uidx_parent_action` (`parent_table_id`,`parent_table_name`,`action_name`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "abacus_state_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "abacus_state_history_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "abacus_state_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "action_name",
          "type": "varchar(32)",
          "nullable": false
        },
        {
          "name": "action_status",
          "type": "enum('init','running','error','complete','approved','rejected')",
          "nullable": false,
          "default": "init"
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "message",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "parent_table_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "parent_table_name",
          "type": "varchar(64)",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (abacus_state_history_id) USING BTREE",
          "table": "abacus_state_history",
          "columns": [
            "abacus_state_history_id"
          ]
        },
        {
          "name": "fk_abacus_state_history",
          "def": "KEY fk_abacus_state_history (abacus_state_id) USING BTREE",
          "table": "abacus_state_history",
          "columns": [
            "abacus_state_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (abacus_state_history_id)",
          "table": "abacus_state_history",
          "columns": [
            "abacus_state_history_id"
          ]
        },
        {
          "name": "fk_abacus_state_history",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (abacus_state_id) REFERENCES abacus_state (abacus_state_id)",
          "table": "abacus_state_history",
          "referenced_table": "abacus_state",
          "columns": [
            "abacus_state_id"
          ],
          "referenced_columns": [
            "abacus_state_id"
          ]
        }
      ],
      "def": "CREATE TABLE `abacus_state_history` (\n  `abacus_state_history_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `abacus_state_id` mediumint unsigned NOT NULL,\n  `parent_table_id` mediumint unsigned NOT NULL,\n  `parent_table_name` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `action_name` varchar(32) COLLATE utf8mb4_general_ci NOT NULL,\n  `action_status` enum('init','running','error','complete','approved','rejected') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'init',\n  `message` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`abacus_state_history_id`),\n  KEY `fk_abacus_state_history` (`abacus_state_id`),\n  CONSTRAINT `fk_abacus_state_history` FOREIGN KEY (`abacus_state_id`) REFERENCES `abacus_state` (`abacus_state_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "account",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "account_name",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "sap_created_at",
          "type": "datetime",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (account_id) USING BTREE",
          "table": "account",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "idx_account_name",
          "def": "KEY idx_account_name (account_name) USING BTREE",
          "table": "account",
          "columns": [
            "account_name"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (account_id)",
          "table": "account",
          "columns": [
            "account_id"
          ]
        }
      ],
      "def": "CREATE TABLE `account` (\n  `account_id` mediumint unsigned NOT NULL,\n  `account_name` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `sap_created_at` datetime DEFAULT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`account_id`),\n  KEY `idx_account_name` (`account_name`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "account_contract",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_contract_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "is_primary_for_calc",
          "type": "tinyint(1)",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (account_contract_id) USING BTREE",
          "table": "account_contract",
          "columns": [
            "account_contract_id"
          ]
        },
        {
          "name": "fk_account_contract_account_id",
          "def": "KEY fk_account_contract_account_id (account_id) USING BTREE",
          "table": "account_contract",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "uidx_account_contract_contract",
          "def": "UNIQUE KEY uidx_account_contract_contract (contract_id) USING BTREE",
          "table": "account_contract",
          "columns": [
            "contract_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (account_contract_id)",
          "table": "account_contract",
          "columns": [
            "account_contract_id"
          ]
        },
        {
          "name": "fk_account_contract_account_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "account_contract",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_account_contract_contract_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "account_contract",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "uidx_account_contract_contract",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_account_contract_contract (contract_id)",
          "table": "account_contract",
          "columns": [
            "contract_id"
          ]
        }
      ],
      "def": "CREATE TABLE `account_contract` (\n  `account_contract_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `account_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned NOT NULL,\n  `is_primary_for_calc` tinyint(1) DEFAULT NULL,\n  PRIMARY KEY (`account_contract_id`),\n  UNIQUE KEY `uidx_account_contract_contract` (`contract_id`),\n  KEY `fk_account_contract_account_id` (`account_id`),\n  CONSTRAINT `fk_account_contract_account_id` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_account_contract_contract_id` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "account_contract_vat_detail",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_contract_vat_detail_id",
          "type": "int",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "company_code",
          "type": "varchar(8)",
          "nullable": true
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "is_vat_eligible",
          "type": "tinyint(1)",
          "nullable": false,
          "default": "0"
        },
        {
          "name": "is_vat_registered",
          "type": "tinyint(1)",
          "nullable": false,
          "default": "0"
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "vat_country",
          "type": "varchar(60)",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (account_contract_vat_detail_id) USING BTREE",
          "table": "account_contract_vat_detail",
          "columns": [
            "account_contract_vat_detail_id"
          ]
        },
        {
          "name": "account_id",
          "def": "KEY account_id (account_id) USING BTREE",
          "table": "account_contract_vat_detail",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "account_id_2",
          "def": "UNIQUE KEY account_id_2 (account_id, contract_id) USING BTREE",
          "table": "account_contract_vat_detail",
          "columns": [
            "account_id",
            "contract_id"
          ]
        },
        {
          "name": "contract_id",
          "def": "KEY contract_id (contract_id) USING BTREE",
          "table": "account_contract_vat_detail",
          "columns": [
            "contract_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (account_contract_vat_detail_id)",
          "table": "account_contract_vat_detail",
          "columns": [
            "account_contract_vat_detail_id"
          ]
        },
        {
          "name": "account_id_2",
          "type": "UNIQUE",
          "def": "UNIQUE KEY account_id_2 (account_id, contract_id)",
          "table": "account_contract_vat_detail",
          "columns": [
            "account_id",
            "contract_id"
          ]
        },
        {
          "name": "fk_vat_detail_account_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "account_contract_vat_detail",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_vat_detail_contract_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "account_contract_vat_detail",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        }
      ],
      "def": "CREATE TABLE `account_contract_vat_detail` (\n  `account_contract_vat_detail_id` int NOT NULL AUTO_INCREMENT,\n  `account_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned NOT NULL,\n  `company_code` varchar(8) DEFAULT NULL,\n  `is_vat_eligible` tinyint(1) NOT NULL DEFAULT '0',\n  `vat_country` varchar(60) DEFAULT NULL,\n  `is_vat_registered` tinyint(1) NOT NULL DEFAULT '0',\n  `created_at` datetime DEFAULT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `last_modified` datetime DEFAULT NULL,\n  PRIMARY KEY (`account_contract_vat_detail_id`),\n  UNIQUE KEY `account_id_2` (`account_id`,`contract_id`),\n  KEY `account_id` (`account_id`),\n  KEY `contract_id` (`contract_id`),\n  CONSTRAINT `fk_vat_detail_account_id` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,\n  CONSTRAINT `fk_vat_detail_contract_id` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE RESTRICT ON UPDATE RESTRICT\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "account_payee",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "account_payee_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "payment_description",
          "type": "varchar(250)",
          "nullable": false,
          "default": ""
        },
        {
          "name": "payoneer_iframe_url",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "payoneer_iframe_url_date",
          "type": "date",
          "nullable": true
        },
        {
          "name": "payoneer_payee_id",
          "type": "bigint unsigned",
          "nullable": true
        },
        {
          "name": "payoneer_payee_name",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "payoneer_program_id",
          "type": "int unsigned",
          "nullable": true
        },
        {
          "name": "payoneer_session_id",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "reference_payment_type_id",
          "type": "smallint unsigned",
          "nullable": true
        },
        {
          "name": "sap_vendor_id",
          "type": "int unsigned",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (account_payee_id) USING BTREE",
          "table": "account_payee",
          "columns": [
            "account_payee_id"
          ]
        },
        {
          "name": "fk_account_payee_account",
          "def": "KEY fk_account_payee_account (account_id) USING BTREE",
          "table": "account_payee",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_payoneer_program_id",
          "def": "KEY fk_payoneer_program_id (payoneer_program_id) USING BTREE",
          "table": "account_payee",
          "columns": [
            "payoneer_program_id"
          ]
        },
        {
          "name": "fk_reference_payment_type_id",
          "def": "KEY fk_reference_payment_type_id (reference_payment_type_id) USING BTREE",
          "table": "account_payee",
          "columns": [
            "reference_payment_type_id"
          ]
        },
        {
          "name": "uidx_account_id",
          "def": "UNIQUE KEY uidx_account_id (account_id) USING BTREE",
          "table": "account_payee",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "unique_sap_vendor_id",
          "def": "UNIQUE KEY unique_sap_vendor_id (sap_vendor_id) USING BTREE",
          "table": "account_payee",
          "columns": [
            "sap_vendor_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (account_payee_id)",
          "table": "account_payee",
          "columns": [
            "account_payee_id"
          ]
        },
        {
          "name": "fk_account_payee_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "account_payee",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_payoneer_program_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (payoneer_program_id) REFERENCES reference_payoneer_program (payoneer_program_id)",
          "table": "account_payee",
          "referenced_table": "reference_payoneer_program",
          "columns": [
            "payoneer_program_id"
          ],
          "referenced_columns": [
            "payoneer_program_id"
          ]
        },
        {
          "name": "fk_reference_payment_type_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (reference_payment_type_id) REFERENCES reference_payment_type (reference_payment_type_id)",
          "table": "account_payee",
          "referenced_table": "reference_payment_type",
          "columns": [
            "reference_payment_type_id"
          ],
          "referenced_columns": [
            "reference_payment_type_id"
          ]
        },
        {
          "name": "uidx_account_id",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_account_id (account_id)",
          "table": "account_payee",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "unique_sap_vendor_id",
          "type": "UNIQUE",
          "def": "UNIQUE KEY unique_sap_vendor_id (sap_vendor_id)",
          "table": "account_payee",
          "columns": [
            "sap_vendor_id"
          ]
        }
      ],
      "triggers": [
        {
          "name": "after_account_payee_update",
          "def": "CREATE TRIGGER after_account_payee_update AFTER UPDATE ON account_payee\nFOR EACH ROW\nBEGIN\n    INSERT INTO `account_payee_history`(\n        account_payee_id,\n        account_id,\n        payoneer_program_id,\n        payoneer_payee_id,\n        payoneer_payee_name,\n        payoneer_iframe_url,\n        payoneer_iframe_url_date,\n        payoneer_session_id,\n        sap_vendor_id,\n        reference_payment_type_id,\n        payment_description,\n        created_by,\n        created_at,\n        last_modified_by,\n        last_modified\n    ) VALUES (\n        OLD.account_payee_id,\n        OLD.account_id,\n        OLD.payoneer_program_id,\n        OLD.payoneer_payee_id,\n        OLD.payoneer_payee_name,\n        OLD.payoneer_iframe_url,\n        OLD.payoneer_iframe_url_date,\n        OLD.payoneer_session_id,\n        OLD.sap_vendor_id,\n        OLD.reference_payment_type_id,\n        OLD.payment_description,\n        OLD.created_by,\n        OLD.created_at,\n        OLD.last_modified_by,\n        OLD.last_modified\n    );\nEND"
        }
      ],
      "def": "CREATE TABLE `account_payee` (\n  `account_payee_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `account_id` mediumint unsigned NOT NULL,\n  `payoneer_program_id` int unsigned DEFAULT NULL,\n  `payoneer_payee_id` bigint unsigned DEFAULT NULL,\n  `payoneer_payee_name` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `payoneer_iframe_url` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `payoneer_iframe_url_date` date DEFAULT NULL,\n  `payoneer_session_id` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `sap_vendor_id` int unsigned DEFAULT NULL,\n  `reference_payment_type_id` smallint unsigned DEFAULT NULL,\n  `payment_description` varchar(250) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`account_payee_id`),\n  UNIQUE KEY `uidx_account_id` (`account_id`),\n  UNIQUE KEY `unique_sap_vendor_id` (`sap_vendor_id`),\n  KEY `fk_account_payee_account` (`account_id`),\n  KEY `fk_payoneer_program_id` (`payoneer_program_id`),\n  KEY `fk_reference_payment_type_id` (`reference_payment_type_id`),\n  CONSTRAINT `fk_account_payee_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_payoneer_program_id` FOREIGN KEY (`payoneer_program_id`) REFERENCES `reference_payoneer_program` (`payoneer_program_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,\n  CONSTRAINT `fk_reference_payment_type_id` FOREIGN KEY (`reference_payment_type_id`) REFERENCES `reference_payment_type` (`reference_payment_type_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "account_payee_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "account_payee_history_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "account_payee_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "payment_description",
          "type": "varchar(250)",
          "nullable": false,
          "default": ""
        },
        {
          "name": "payoneer_iframe_url",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "payoneer_iframe_url_date",
          "type": "date",
          "nullable": true
        },
        {
          "name": "payoneer_payee_id",
          "type": "bigint unsigned",
          "nullable": true
        },
        {
          "name": "payoneer_payee_name",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "payoneer_program_id",
          "type": "int unsigned",
          "nullable": true
        },
        {
          "name": "payoneer_session_id",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "reference_payment_type_id",
          "type": "smallint unsigned",
          "nullable": true
        },
        {
          "name": "sap_vendor_id",
          "type": "int unsigned",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (account_payee_history_id) USING BTREE",
          "table": "account_payee_history",
          "columns": [
            "account_payee_history_id"
          ]
        },
        {
          "name": "fk_account_account_payee_history",
          "def": "KEY fk_account_account_payee_history (account_id) USING BTREE",
          "table": "account_payee_history",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_account_payee_account_payee_history",
          "def": "KEY fk_account_payee_account_payee_history (account_payee_id) USING BTREE",
          "table": "account_payee_history",
          "columns": [
            "account_payee_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (account_payee_history_id)",
          "table": "account_payee_history",
          "columns": [
            "account_payee_history_id"
          ]
        },
        {
          "name": "fk_account_account_payee_history",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "account_payee_history",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_account_payee_account_payee_history",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_payee_id) REFERENCES account_payee (account_payee_id)",
          "table": "account_payee_history",
          "referenced_table": "account_payee",
          "columns": [
            "account_payee_id"
          ],
          "referenced_columns": [
            "account_payee_id"
          ]
        }
      ],
      "def": "CREATE TABLE `account_payee_history` (\n  `account_payee_history_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `account_payee_id` mediumint unsigned NOT NULL,\n  `account_id` mediumint unsigned NOT NULL,\n  `payoneer_program_id` int unsigned DEFAULT NULL,\n  `payoneer_payee_id` bigint unsigned DEFAULT NULL,\n  `payoneer_payee_name` varchar(180) DEFAULT NULL,\n  `payoneer_iframe_url` varchar(180) DEFAULT NULL,\n  `payoneer_iframe_url_date` date DEFAULT NULL,\n  `payoneer_session_id` varchar(180) DEFAULT NULL,\n  `sap_vendor_id` int unsigned DEFAULT NULL,\n  `reference_payment_type_id` smallint unsigned DEFAULT NULL,\n  `payment_description` varchar(250) NOT NULL DEFAULT '',\n  `created_by` varchar(255) NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`account_payee_history_id`),\n  KEY `fk_account_payee_account_payee_history` (`account_payee_id`),\n  KEY `fk_account_account_payee_history` (`account_id`),\n  CONSTRAINT `fk_account_account_payee_history` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_account_payee_account_payee_history` FOREIGN KEY (`account_payee_id`) REFERENCES `account_payee` (`account_payee_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "account_payee_kyc_notification",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_payee_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "account_payee_kyc_notification_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "entity_reference_id",
          "type": "varchar(36)",
          "nullable": true
        },
        {
          "name": "entity_reference_type_id",
          "type": "tinyint",
          "nullable": true
        },
        {
          "name": "file_upload_link",
          "type": "varchar(1000)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "possible_sub_requirement_types",
          "type": "varchar(1000)",
          "nullable": true
        },
        {
          "name": "requirement_id",
          "type": "varchar(1000)",
          "nullable": true
        },
        {
          "name": "requirement_type_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "sub_requirement_id",
          "type": "varchar(1000)",
          "nullable": true
        },
        {
          "name": "sub_requirement_status_id",
          "type": "tinyint",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (account_payee_kyc_notification_id) USING BTREE",
          "table": "account_payee_kyc_notification",
          "columns": [
            "account_payee_kyc_notification_id"
          ]
        },
        {
          "name": "fk_apkn_account_payee_id",
          "def": "KEY fk_apkn_account_payee_id (account_payee_id) USING BTREE",
          "table": "account_payee_kyc_notification",
          "columns": [
            "account_payee_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (account_payee_kyc_notification_id)",
          "table": "account_payee_kyc_notification",
          "columns": [
            "account_payee_kyc_notification_id"
          ]
        },
        {
          "name": "fk_apkn_account_payee_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_payee_id) REFERENCES account_payee (account_payee_id)",
          "table": "account_payee_kyc_notification",
          "referenced_table": "account_payee",
          "columns": [
            "account_payee_id"
          ],
          "referenced_columns": [
            "account_payee_id"
          ]
        }
      ],
      "triggers": [
        {
          "name": "after_account_payee_kyc_notification",
          "def": "CREATE TRIGGER after_account_payee_kyc_notification AFTER UPDATE ON account_payee_kyc_notification\nFOR EACH ROW\nBEGIN\n    INSERT INTO `account_payee_kyc_notification_history`(\n        `account_payee_kyc_notification_id`,\n        `account_payee_id`,\n        `file_upload_link`,\n        `requirement_id`,\n        `requirement_type_id`,\n        `sub_requirement_id`,\n        `possible_sub_requirement_types`,\n        `sub_requirement_status_id`,\n        `entity_reference_id`,\n        `entity_reference_type_id`,\n        `created_at`,\n        `created_by`,\n        `last_modified`,\n        `last_modified_by`,\n        `deleted_at`,\n        `deleted_by`\n    ) VALUES (\n        old.`account_payee_kyc_notification_id`,\n        old.`account_payee_id`,\n        old.`file_upload_link`,\n        old.`requirement_id`,\n        old.`requirement_type_id`,\n        old.`sub_requirement_id`,\n        old.`possible_sub_requirement_types`,\n        old.`sub_requirement_status_id`,\n        old.`entity_reference_id`,\n        old.`entity_reference_type_id`,\n        old.`created_at`,\n        old.`created_by`,\n        old.`last_modified`,\n        old.`last_modified_by`,\n        old.`deleted_at`,\n        old.`deleted_by`\n    );\nEND"
        }
      ],
      "def": "CREATE TABLE `account_payee_kyc_notification` (\n  `account_payee_kyc_notification_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `account_payee_id` mediumint unsigned NOT NULL,\n  `file_upload_link` varchar(1000) NOT NULL,\n  `requirement_id` varchar(1000) DEFAULT NULL,\n  `requirement_type_id` mediumint unsigned DEFAULT NULL,\n  `sub_requirement_id` varchar(1000) DEFAULT NULL,\n  `possible_sub_requirement_types` varchar(1000) DEFAULT NULL,\n  `sub_requirement_status_id` tinyint DEFAULT NULL,\n  `entity_reference_id` varchar(36) DEFAULT NULL,\n  `entity_reference_type_id` tinyint DEFAULT NULL,\n  `created_at` datetime NOT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(255) DEFAULT NULL,\n  PRIMARY KEY (`account_payee_kyc_notification_id`),\n  KEY `fk_apkn_account_payee_id` (`account_payee_id`),\n  CONSTRAINT `fk_apkn_account_payee_id` FOREIGN KEY (`account_payee_id`) REFERENCES `account_payee` (`account_payee_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci"
    },
    {
      "name": "account_payee_kyc_notification_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_payee_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "account_payee_kyc_notification_history_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "account_payee_kyc_notification_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "entity_reference_id",
          "type": "varchar(36)",
          "nullable": true
        },
        {
          "name": "entity_reference_type_id",
          "type": "tinyint",
          "nullable": true
        },
        {
          "name": "file_upload_link",
          "type": "varchar(1000)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "possible_sub_requirement_types",
          "type": "varchar(1000)",
          "nullable": true
        },
        {
          "name": "requirement_id",
          "type": "varchar(1000)",
          "nullable": true
        },
        {
          "name": "requirement_type_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "sub_requirement_id",
          "type": "varchar(1000)",
          "nullable": true
        },
        {
          "name": "sub_requirement_status_id",
          "type": "tinyint",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (account_payee_kyc_notification_history_id) USING BTREE",
          "table": "account_payee_kyc_notification_history",
          "columns": [
            "account_payee_kyc_notification_history_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (account_payee_kyc_notification_history_id)",
          "table": "account_payee_kyc_notification_history",
          "columns": [
            "account_payee_kyc_notification_history_id"
          ]
        }
      ],
      "def": "CREATE TABLE `account_payee_kyc_notification_history` (\n  `account_payee_kyc_notification_history_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `account_payee_kyc_notification_id` mediumint unsigned NOT NULL,\n  `account_payee_id` mediumint unsigned NOT NULL,\n  `file_upload_link` varchar(1000) NOT NULL,\n  `requirement_id` varchar(1000) DEFAULT NULL,\n  `requirement_type_id` mediumint unsigned DEFAULT NULL,\n  `sub_requirement_id` varchar(1000) DEFAULT NULL,\n  `possible_sub_requirement_types` varchar(1000) DEFAULT NULL,\n  `sub_requirement_status_id` tinyint DEFAULT NULL,\n  `entity_reference_id` varchar(36) DEFAULT NULL,\n  `entity_reference_type_id` tinyint DEFAULT NULL,\n  `created_at` datetime NOT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(255) DEFAULT NULL,\n  PRIMARY KEY (`account_payee_kyc_notification_history_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci"
    },
    {
      "name": "account_payee_tax_form_info",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_payee_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "account_payee_tax_form_info_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "expiration_date",
          "type": "date",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "revision_id",
          "type": "varchar(36)",
          "nullable": true
        },
        {
          "name": "signed_date",
          "type": "date",
          "nullable": true
        },
        {
          "name": "tax_form_type",
          "type": "enum('W9','W8','W8BEN','W8BEN-E','W8IMY','W8ECI')",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (account_payee_tax_form_info_id) USING BTREE",
          "table": "account_payee_tax_form_info",
          "columns": [
            "account_payee_tax_form_info_id"
          ]
        },
        {
          "name": "uidx_account_payee_id_revision_id",
          "def": "UNIQUE KEY uidx_account_payee_id_revision_id (account_payee_id, revision_id) USING BTREE",
          "table": "account_payee_tax_form_info",
          "columns": [
            "account_payee_id",
            "revision_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (account_payee_tax_form_info_id)",
          "table": "account_payee_tax_form_info",
          "columns": [
            "account_payee_tax_form_info_id"
          ]
        },
        {
          "name": "fk_account_payee_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_payee_id) REFERENCES account_payee (account_payee_id)",
          "table": "account_payee_tax_form_info",
          "referenced_table": "account_payee",
          "columns": [
            "account_payee_id"
          ],
          "referenced_columns": [
            "account_payee_id"
          ]
        },
        {
          "name": "uidx_account_payee_id_revision_id",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_account_payee_id_revision_id (account_payee_id, revision_id)",
          "table": "account_payee_tax_form_info",
          "columns": [
            "account_payee_id",
            "revision_id"
          ]
        }
      ],
      "triggers": [
        {
          "name": "after_account_payee_tax_form_info",
          "def": "CREATE TRIGGER after_account_payee_tax_form_info AFTER UPDATE ON account_payee_tax_form_info\nFOR EACH ROW\nBEGIN\n    INSERT INTO `account_payee_tax_form_info_history` (\n        `account_payee_tax_form_info_id`,\n        `tax_form_type`,\n        `account_payee_id`,\n        `signed_date`,\n        `expiration_date`,\n        `created_at`,\n        `created_by`,\n        `last_modified`,\n        `last_modified_by`,\n        `deleted_at`,\n        `deleted_by`,\n        `revision_id`\n    ) VALUES (\n        old.`account_payee_tax_form_info_id`,\n        old.`tax_form_type`,\n        old.`account_payee_id`,\n        old.`signed_date`,\n        old.`expiration_date`,\n        old.`created_at`,\n        old.`created_by`,\n        old.`last_modified`,\n        old.`last_modified_by`,\n        old.`deleted_at`,\n        old.`deleted_by`,\n        old.`revision_id`\n    );\nEND"
        }
      ],
      "def": "CREATE TABLE `account_payee_tax_form_info` (\n  `account_payee_tax_form_info_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `tax_form_type` enum('W9','W8','W8BEN','W8BEN-E','W8IMY','W8ECI') COLLATE utf8mb4_general_ci NOT NULL,\n  `account_payee_id` mediumint unsigned NOT NULL,\n  `revision_id` varchar(36) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `signed_date` date DEFAULT NULL,\n  `expiration_date` date DEFAULT NULL,\n  `created_at` datetime NOT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  PRIMARY KEY (`account_payee_tax_form_info_id`),\n  UNIQUE KEY `uidx_account_payee_id_revision_id` (`account_payee_id`,`revision_id`),\n  CONSTRAINT `fk_account_payee_id` FOREIGN KEY (`account_payee_id`) REFERENCES `account_payee` (`account_payee_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "account_payee_tax_form_info_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_payee_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "account_payee_tax_form_info_history_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "account_payee_tax_form_info_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "expiration_date",
          "type": "date",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "revision_id",
          "type": "varchar(36)",
          "nullable": true
        },
        {
          "name": "signed_date",
          "type": "date",
          "nullable": true
        },
        {
          "name": "tax_form_type",
          "type": "enum('W9','W8','W8BEN','W8BEN-E','W8IMY','W8ECI')",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (account_payee_tax_form_info_history_id) USING BTREE",
          "table": "account_payee_tax_form_info_history",
          "columns": [
            "account_payee_tax_form_info_history_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (account_payee_tax_form_info_history_id)",
          "table": "account_payee_tax_form_info_history",
          "columns": [
            "account_payee_tax_form_info_history_id"
          ]
        }
      ],
      "def": "CREATE TABLE `account_payee_tax_form_info_history` (\n  `account_payee_tax_form_info_history_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `account_payee_tax_form_info_id` mediumint unsigned NOT NULL,\n  `tax_form_type` enum('W9','W8','W8BEN','W8BEN-E','W8IMY','W8ECI') COLLATE utf8mb4_general_ci NOT NULL,\n  `account_payee_id` mediumint unsigned NOT NULL,\n  `revision_id` varchar(36) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `signed_date` date DEFAULT NULL,\n  `expiration_date` date DEFAULT NULL,\n  `created_at` datetime NOT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  PRIMARY KEY (`account_payee_tax_form_info_history_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "account_payment_term",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "account_payment_term_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "agreement_type_id",
          "type": "tinyint unsigned",
          "nullable": true
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "payment_entity_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "payment_minimum",
          "type": "decimal(10,2)",
          "nullable": true
        },
        {
          "name": "payment_schedule",
          "type": "enum('30_days_after_month_end','45_days_after_month_end','60_days_after_month_end','90_days_after_month_end','30_days_after_quarter_end','45_days_after_quarter_end','60_days_after_quarter_end','90_days_after_quarter_end','30_days_after_half_year_end','45_days_after_half_year_end','60_days_after_half_year_end','90_days_after_half_year_end','TEMPORARY')",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (account_payment_term_id) USING BTREE",
          "table": "account_payment_term",
          "columns": [
            "account_payment_term_id"
          ]
        },
        {
          "name": "fk_account_payment_term_agreement_type",
          "def": "KEY fk_account_payment_term_agreement_type (agreement_type_id) USING BTREE",
          "table": "account_payment_term",
          "columns": [
            "agreement_type_id"
          ]
        },
        {
          "name": "fk_account_payment_term_payment_entity",
          "def": "KEY fk_account_payment_term_payment_entity (payment_entity_id) USING BTREE",
          "table": "account_payment_term",
          "columns": [
            "payment_entity_id"
          ]
        },
        {
          "name": "uidx_account_id",
          "def": "UNIQUE KEY uidx_account_id (account_id) USING BTREE",
          "table": "account_payment_term",
          "columns": [
            "account_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (account_payment_term_id)",
          "table": "account_payment_term",
          "columns": [
            "account_payment_term_id"
          ]
        },
        {
          "name": "fk_account_payment_term_account_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "account_payment_term",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_account_payment_term_agreement_type",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (agreement_type_id) REFERENCES reference_agreement_type (reference_agreement_type_id)",
          "table": "account_payment_term",
          "referenced_table": "reference_agreement_type",
          "columns": [
            "agreement_type_id"
          ],
          "referenced_columns": [
            "reference_agreement_type_id"
          ]
        },
        {
          "name": "fk_account_payment_term_payment_entity",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (payment_entity_id) REFERENCES reference_payment_entity (reference_payment_entity_id)",
          "table": "account_payment_term",
          "referenced_table": "reference_payment_entity",
          "columns": [
            "payment_entity_id"
          ],
          "referenced_columns": [
            "reference_payment_entity_id"
          ]
        },
        {
          "name": "uidx_account_id",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_account_id (account_id)",
          "table": "account_payment_term",
          "columns": [
            "account_id"
          ]
        }
      ],
      "triggers": [
        {
          "name": "after_update_account_payment_term",
          "def": "CREATE TRIGGER after_update_account_payment_term AFTER UPDATE ON account_payment_term\nFOR EACH ROW\nBEGIN\nINSERT INTO `account_payment_term_history`(\n        `account_payment_term_id`,\n        `account_id`,\n        `currency_code`,\n        `payment_minimum`,\n        `payment_entity_id`,\n        `agreement_type_id`,\n        `payment_schedule`,\n        `created_by`,\n        `created_at`,\n        `last_modified_by`,\n        `last_modified`\n    ) VALUES (\n        old.account_payment_term_id,\n        old.account_id,\n        old.currency_code,\n        old.payment_minimum,\n        old.payment_entity_id,\n        old.agreement_type_id,\n        old.payment_schedule,\n        old.created_by,\n        old.created_at,\n        old.last_modified_by,\n        old.last_modified\n    );\nEND"
        }
      ],
      "def": "CREATE TABLE `account_payment_term` (\n  `account_payment_term_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `account_id` mediumint unsigned NOT NULL,\n  `currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `payment_minimum` decimal(10,2) DEFAULT NULL,\n  `payment_entity_id` mediumint unsigned DEFAULT NULL,\n  `agreement_type_id` tinyint unsigned DEFAULT NULL,\n  `payment_schedule` enum('30_days_after_month_end','45_days_after_month_end','60_days_after_month_end','90_days_after_month_end','30_days_after_quarter_end','45_days_after_quarter_end','60_days_after_quarter_end','90_days_after_quarter_end','30_days_after_half_year_end','45_days_after_half_year_end','60_days_after_half_year_end','90_days_after_half_year_end','TEMPORARY') COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`account_payment_term_id`),\n  UNIQUE KEY `uidx_account_id` (`account_id`),\n  KEY `fk_account_payment_term_agreement_type` (`agreement_type_id`),\n  KEY `fk_account_payment_term_payment_entity` (`payment_entity_id`),\n  CONSTRAINT `fk_account_payment_term_account_id` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_account_payment_term_agreement_type` FOREIGN KEY (`agreement_type_id`) REFERENCES `reference_agreement_type` (`reference_agreement_type_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_account_payment_term_payment_entity` FOREIGN KEY (`payment_entity_id`) REFERENCES `reference_payment_entity` (`reference_payment_entity_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "account_payment_term_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "account_payment_term_history_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "account_payment_term_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "agreement_type_id",
          "type": "tinyint unsigned",
          "nullable": true
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "payment_entity_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "payment_minimum",
          "type": "decimal(10,2)",
          "nullable": true
        },
        {
          "name": "payment_schedule",
          "type": "enum('30_days_after_month_end','45_days_after_month_end','60_days_after_month_end','90_days_after_month_end','30_days_after_quarter_end','45_days_after_quarter_end','60_days_after_quarter_end','90_days_after_quarter_end','30_days_after_half_year_end','45_days_after_half_year_end','60_days_after_half_year_end','90_days_after_half_year_end','TEMPORARY')",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (account_payment_term_history_id) USING BTREE",
          "table": "account_payment_term_history",
          "columns": [
            "account_payment_term_history_id"
          ]
        },
        {
          "name": "fk_account_payment_term_history_account",
          "def": "KEY fk_account_payment_term_history_account (account_id) USING BTREE",
          "table": "account_payment_term_history",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_account_payment_term_history_payment_entity",
          "def": "KEY fk_account_payment_term_history_payment_entity (payment_entity_id) USING BTREE",
          "table": "account_payment_term_history",
          "columns": [
            "payment_entity_id"
          ]
        },
        {
          "name": "fk_account_payment_term_history_payment_term_id",
          "def": "KEY fk_account_payment_term_history_payment_term_id (account_payment_term_id) USING BTREE",
          "table": "account_payment_term_history",
          "columns": [
            "account_payment_term_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (account_payment_term_history_id)",
          "table": "account_payment_term_history",
          "columns": [
            "account_payment_term_history_id"
          ]
        },
        {
          "name": "fk_account_payment_term_history_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "account_payment_term_history",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_account_payment_term_history_payment_entity",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (payment_entity_id) REFERENCES reference_payment_entity (reference_payment_entity_id)",
          "table": "account_payment_term_history",
          "referenced_table": "reference_payment_entity",
          "columns": [
            "payment_entity_id"
          ],
          "referenced_columns": [
            "reference_payment_entity_id"
          ]
        },
        {
          "name": "fk_account_payment_term_history_payment_term_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_payment_term_id) REFERENCES account_payment_term (account_payment_term_id)",
          "table": "account_payment_term_history",
          "referenced_table": "account_payment_term",
          "columns": [
            "account_payment_term_id"
          ],
          "referenced_columns": [
            "account_payment_term_id"
          ]
        }
      ],
      "def": "CREATE TABLE `account_payment_term_history` (\n  `account_payment_term_history_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `account_payment_term_id` mediumint unsigned NOT NULL,\n  `account_id` mediumint unsigned NOT NULL,\n  `currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `payment_minimum` decimal(10,2) DEFAULT NULL,\n  `payment_entity_id` mediumint unsigned DEFAULT NULL,\n  `agreement_type_id` tinyint unsigned DEFAULT NULL,\n  `payment_schedule` enum('30_days_after_month_end','45_days_after_month_end','60_days_after_month_end','90_days_after_month_end','30_days_after_quarter_end','45_days_after_quarter_end','60_days_after_quarter_end','90_days_after_quarter_end','30_days_after_half_year_end','45_days_after_half_year_end','60_days_after_half_year_end','90_days_after_half_year_end','TEMPORARY') COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`account_payment_term_history_id`),\n  KEY `fk_account_payment_term_history_account` (`account_id`),\n  KEY `fk_account_payment_term_history_payment_term_id` (`account_payment_term_id`),\n  KEY `fk_account_payment_term_history_payment_entity` (`payment_entity_id`),\n  CONSTRAINT `fk_account_payment_term_history_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_account_payment_term_history_payment_entity` FOREIGN KEY (`payment_entity_id`) REFERENCES `reference_payment_entity` (`reference_payment_entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_account_payment_term_history_payment_term_id` FOREIGN KEY (`account_payment_term_id`) REFERENCES `account_payment_term` (`account_payment_term_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "account_payment_term_template",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_payment_term_template_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "currency_code",
          "type": "varchar(3)",
          "nullable": false
        },
        {
          "name": "payment_terms",
          "type": "json",
          "nullable": false
        },
        {
          "name": "template_name",
          "type": "varchar(180)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (account_payment_term_template_id) USING BTREE",
          "table": "account_payment_term_template",
          "columns": [
            "account_payment_term_template_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (account_payment_term_template_id)",
          "table": "account_payment_term_template",
          "columns": [
            "account_payment_term_template_id"
          ]
        }
      ],
      "def": "CREATE TABLE `account_payment_term_template` (\n  `account_payment_term_template_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `template_name` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `currency_code` varchar(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `payment_terms` json NOT NULL,\n  PRIMARY KEY (`account_payment_term_template_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "account_tax_info",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "account_tax_info_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "certificate_of_residence_expiration_date",
          "type": "date",
          "nullable": true
        },
        {
          "name": "country_of_tax_residence",
          "type": "char(3)",
          "nullable": true
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "is_resident_of_spanish_islands",
          "type": "tinyint(1)",
          "nullable": true
        },
        {
          "name": "is_sba_signed",
          "type": "tinyint(1)",
          "nullable": true,
          "default": "0"
        },
        {
          "name": "is_tax_treaty_claimed",
          "type": "tinyint(1)",
          "nullable": false,
          "default": "0"
        },
        {
          "name": "is_vat_exempt",
          "type": "tinyint(1)",
          "nullable": false,
          "default": "1"
        },
        {
          "name": "is_wht_applicable",
          "type": "tinyint(1)",
          "nullable": false,
          "default": "1"
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "tax_employment_type",
          "type": "enum('Business','Employed Individual','Self-Employed Individual (\u003c 2 years)','Self-Employed Individual (\u003e= 2 years)','Individual','Small Business that is not required to register for EU VAT')",
          "nullable": true
        },
        {
          "name": "wht_rate_override",
          "type": "decimal(5,2)",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (account_tax_info_id) USING BTREE",
          "table": "account_tax_info",
          "columns": [
            "account_tax_info_id"
          ]
        },
        {
          "name": "uidx_account_id",
          "def": "UNIQUE KEY uidx_account_id (account_id) USING BTREE",
          "table": "account_tax_info",
          "columns": [
            "account_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (account_tax_info_id)",
          "table": "account_tax_info",
          "columns": [
            "account_tax_info_id"
          ]
        },
        {
          "name": "fk_account_tax_info_account_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "account_tax_info",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "uidx_account_id",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_account_id (account_id)",
          "table": "account_tax_info",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "wht_rate_override_check",
          "type": "CHECK",
          "def": "CHECK (((`wht_rate_override` is null) or ((`wht_rate_override` \u003e= 0.00) and (`wht_rate_override` \u003c= 100.00))))",
          "table": "account_tax_info"
        }
      ],
      "triggers": [
        {
          "name": "after_update_account_tax_info",
          "def": "CREATE TRIGGER after_update_account_tax_info AFTER UPDATE ON account_tax_info\nFOR EACH ROW\nBEGIN\n    INSERT INTO `account_tax_info_history`(\n        `account_tax_info_id`,\n        `account_id`,\n        `country_of_tax_residence`,\n        `is_sba_signed`,\n        `is_vat_exempt`,\n        `is_tax_treaty_claimed`,\n        `tax_employment_type`,\n        `certificate_of_residence_expiration_date`,\n        `is_wht_applicable`,\n        `is_resident_of_spanish_islands`,\n        `wht_rate_override`,\n        `created_by`,\n        `created_at`,\n        `last_modified_by`,\n        `last_modified`\n    ) VALUES (\n        old.account_tax_info_id,\n        old.account_id,\n        old.country_of_tax_residence,\n        old.is_sba_signed,\n        old.is_vat_exempt,\n        old.is_tax_treaty_claimed,\n        old.tax_employment_type,\n        old.certificate_of_residence_expiration_date,\n        old.is_wht_applicable,\n        old.is_resident_of_spanish_islands,\n        old.wht_rate_override,\n        old.created_by,\n        old.created_at,\n        old.last_modified_by,\n        old.last_modified\n    );\nEND"
        }
      ],
      "def": "CREATE TABLE `account_tax_info` (\n  `account_tax_info_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `account_id` mediumint unsigned NOT NULL,\n  `country_of_tax_residence` char(3) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `is_sba_signed` tinyint(1) DEFAULT '0',\n  `is_vat_exempt` tinyint(1) NOT NULL DEFAULT '1',\n  `is_tax_treaty_claimed` tinyint(1) NOT NULL DEFAULT '0',\n  `tax_employment_type` enum('Business','Employed Individual','Self-Employed Individual (\u003c 2 years)','Self-Employed Individual (\u003e= 2 years)','Individual','Small Business that is not required to register for EU VAT') COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `certificate_of_residence_expiration_date` date DEFAULT NULL,\n  `is_wht_applicable` tinyint(1) NOT NULL DEFAULT '1',\n  `is_resident_of_spanish_islands` tinyint(1) DEFAULT NULL,\n  `wht_rate_override` decimal(5,2) DEFAULT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`account_tax_info_id`),\n  UNIQUE KEY `uidx_account_id` (`account_id`),\n  CONSTRAINT `fk_account_tax_info_account_id` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `wht_rate_override_check` CHECK (((`wht_rate_override` is null) or ((`wht_rate_override` \u003e= 0.00) and (`wht_rate_override` \u003c= 100.00))))\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "account_tax_info_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "account_tax_info_history_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "account_tax_info_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "certificate_of_residence_expiration_date",
          "type": "date",
          "nullable": true
        },
        {
          "name": "country_of_tax_residence",
          "type": "char(3)",
          "nullable": true
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "is_resident_of_spanish_islands",
          "type": "tinyint(1)",
          "nullable": true
        },
        {
          "name": "is_sba_signed",
          "type": "tinyint(1)",
          "nullable": true,
          "default": "0"
        },
        {
          "name": "is_tax_treaty_claimed",
          "type": "tinyint(1)",
          "nullable": false,
          "default": "0"
        },
        {
          "name": "is_vat_exempt",
          "type": "tinyint(1)",
          "nullable": false,
          "default": "1"
        },
        {
          "name": "is_wht_applicable",
          "type": "tinyint(1)",
          "nullable": false,
          "default": "1"
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "tax_employment_type",
          "type": "enum('Business','Employed Individual','Self-Employed Individual (\u003c 2 years)','Self-Employed Individual (\u003e= 2 years)','Individual','Small Business that is not required to register for EU VAT')",
          "nullable": true
        },
        {
          "name": "wht_rate_override",
          "type": "decimal(5,2)",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (account_tax_info_history_id) USING BTREE",
          "table": "account_tax_info_history",
          "columns": [
            "account_tax_info_history_id"
          ]
        },
        {
          "name": "fk_account_tax_info_history_account",
          "def": "KEY fk_account_tax_info_history_account (account_id) USING BTREE",
          "table": "account_tax_info_history",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_account_tax_info_id",
          "def": "KEY fk_account_tax_info_id (account_tax_info_id) USING BTREE",
          "table": "account_tax_info_history",
          "columns": [
            "account_tax_info_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (account_tax_info_history_id)",
          "table": "account_tax_info_history",
          "columns": [
            "account_tax_info_history_id"
          ]
        },
        {
          "name": "fk_account_tax_info_history_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "account_tax_info_history",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_account_tax_info_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_tax_info_id) REFERENCES account_tax_info (account_tax_info_id)",
          "table": "account_tax_info_history",
          "referenced_table": "account_tax_info",
          "columns": [
            "account_tax_info_id"
          ],
          "referenced_columns": [
            "account_tax_info_id"
          ]
        }
      ],
      "def": "CREATE TABLE `account_tax_info_history` (\n  `account_tax_info_history_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `account_tax_info_id` mediumint unsigned NOT NULL,\n  `account_id` mediumint unsigned NOT NULL,\n  `country_of_tax_residence` char(3) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `is_sba_signed` tinyint(1) DEFAULT '0',\n  `is_vat_exempt` tinyint(1) NOT NULL DEFAULT '1',\n  `is_tax_treaty_claimed` tinyint(1) NOT NULL DEFAULT '0',\n  `tax_employment_type` enum('Business','Employed Individual','Self-Employed Individual (\u003c 2 years)','Self-Employed Individual (\u003e= 2 years)','Individual','Small Business that is not required to register for EU VAT') COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `certificate_of_residence_expiration_date` date DEFAULT NULL,\n  `is_wht_applicable` tinyint(1) NOT NULL DEFAULT '1',\n  `is_resident_of_spanish_islands` tinyint(1) DEFAULT NULL,\n  `wht_rate_override` decimal(5,2) DEFAULT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`account_tax_info_history_id`),\n  KEY `fk_account_tax_info_history_account` (`account_id`),\n  KEY `fk_account_tax_info_id` (`account_tax_info_id`),\n  CONSTRAINT `fk_account_tax_info_history_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_account_tax_info_id` FOREIGN KEY (`account_tax_info_id`) REFERENCES `account_tax_info` (`account_tax_info_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "accounting_period",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "accounting_period_id",
          "type": "smallint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "accounting_period_name",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "accounting_period_status",
          "type": "enum('open','locked','closed')",
          "nullable": false,
          "default": "open"
        },
        {
          "name": "closed_date",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "contract_type",
          "type": "enum('distribution','legacy_distribution','neighbouring_rights')",
          "nullable": false,
          "default": "distribution"
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "is_visible",
          "type": "tinyint(1)",
          "nullable": false,
          "default": "1"
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "visible_reason",
          "type": "varchar(50)",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (accounting_period_id) USING BTREE",
          "table": "accounting_period",
          "columns": [
            "accounting_period_id"
          ]
        },
        {
          "name": "fk_statement_period_acct_period",
          "def": "KEY fk_statement_period_acct_period (statement_period_id) USING BTREE",
          "table": "accounting_period",
          "columns": [
            "statement_period_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (accounting_period_id)",
          "table": "accounting_period",
          "columns": [
            "accounting_period_id"
          ]
        },
        {
          "name": "chk_is_visible_value",
          "type": "CHECK",
          "def": "CHECK ((`is_visible` in (false,true)))",
          "table": "accounting_period"
        },
        {
          "name": "fk_statement_period_acct_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "accounting_period",
          "referenced_table": "statement_period",
          "columns": [
            "statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        }
      ],
      "def": "CREATE TABLE `accounting_period` (\n  `accounting_period_id` smallint unsigned NOT NULL AUTO_INCREMENT,\n  `statement_period_id` mediumint unsigned NOT NULL,\n  `accounting_period_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `accounting_period_status` enum('open','locked','closed') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'open',\n  `contract_type` enum('distribution','legacy_distribution','neighbouring_rights') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'distribution',\n  `closed_date` datetime DEFAULT NULL,\n  `is_visible` tinyint(1) NOT NULL DEFAULT '1',\n  `visible_reason` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`accounting_period_id`),\n  KEY `fk_statement_period_acct_period` (`statement_period_id`),\n  CONSTRAINT `fk_statement_period_acct_period` FOREIGN KEY (`statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `chk_is_visible_value` CHECK ((`is_visible` in (false,true)))\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "accounting_period_report",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "accounting_period_id",
          "type": "smallint unsigned",
          "nullable": false
        },
        {
          "name": "accounting_period_report_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "report_export_url",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "report_type",
          "type": "varchar(32)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (accounting_period_report_id) USING BTREE",
          "table": "accounting_period_report",
          "columns": [
            "accounting_period_report_id"
          ]
        },
        {
          "name": "fk_accounting_period_report_acc_period",
          "def": "KEY fk_accounting_period_report_acc_period (accounting_period_id) USING BTREE",
          "table": "accounting_period_report",
          "columns": [
            "accounting_period_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (accounting_period_report_id)",
          "table": "accounting_period_report",
          "columns": [
            "accounting_period_report_id"
          ]
        },
        {
          "name": "fk_accounting_period_report_acc_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (accounting_period_id) REFERENCES accounting_period (accounting_period_id)",
          "table": "accounting_period_report",
          "referenced_table": "accounting_period",
          "columns": [
            "accounting_period_id"
          ],
          "referenced_columns": [
            "accounting_period_id"
          ]
        }
      ],
      "def": "CREATE TABLE `accounting_period_report` (\n  `accounting_period_report_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `accounting_period_id` smallint unsigned NOT NULL,\n  `report_type` varchar(32) COLLATE utf8mb4_general_ci NOT NULL,\n  `report_export_url` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`accounting_period_report_id`),\n  KEY `fk_accounting_period_report_acc_period` (`accounting_period_id`),\n  CONSTRAINT `fk_accounting_period_report_acc_period` FOREIGN KEY (`accounting_period_id`) REFERENCES `accounting_period` (`accounting_period_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "accounting_run",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "accounting_period_id",
          "type": "smallint unsigned",
          "nullable": false
        },
        {
          "name": "accounting_run_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "end_date",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "run_controller_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "run_status",
          "type": "enum('No Action Taken','Waiting to Run','Running','Error','Complete','Invalid','Committing','Committed','Skipped','Sent to Workstation','Export Payments')",
          "nullable": false,
          "default": "No Action Taken"
        },
        {
          "name": "start_date",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "summary_export_url",
          "type": "varchar(255)",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (accounting_run_id) USING BTREE",
          "table": "accounting_run",
          "columns": [
            "accounting_run_id"
          ]
        },
        {
          "name": "idx_acct_period_id",
          "def": "KEY idx_acct_period_id (accounting_period_id) USING BTREE",
          "table": "accounting_run",
          "columns": [
            "accounting_period_id"
          ]
        },
        {
          "name": "idx_run_ctrl_id",
          "def": "KEY idx_run_ctrl_id (run_controller_id) USING BTREE",
          "table": "accounting_run",
          "columns": [
            "run_controller_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (accounting_run_id)",
          "table": "accounting_run",
          "columns": [
            "accounting_run_id"
          ]
        },
        {
          "name": "fk_acc_run_run_ctrl",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (run_controller_id) REFERENCES run_controller (run_controller_id)",
          "table": "accounting_run",
          "referenced_table": "run_controller",
          "columns": [
            "run_controller_id"
          ],
          "referenced_columns": [
            "run_controller_id"
          ]
        },
        {
          "name": "fk_acct_run_acct_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (accounting_period_id) REFERENCES accounting_period (accounting_period_id)",
          "table": "accounting_run",
          "referenced_table": "accounting_period",
          "columns": [
            "accounting_period_id"
          ],
          "referenced_columns": [
            "accounting_period_id"
          ]
        }
      ],
      "def": "CREATE TABLE `accounting_run` (\n  `accounting_run_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `accounting_period_id` smallint unsigned NOT NULL,\n  `run_controller_id` mediumint unsigned NOT NULL,\n  `run_status` enum('No Action Taken','Waiting to Run','Running','Error','Complete','Invalid','Committing','Committed','Skipped','Sent to Workstation','Export Payments') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'No Action Taken',\n  `start_date` datetime DEFAULT NULL,\n  `end_date` datetime DEFAULT NULL,\n  `summary_export_url` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`accounting_run_id`),\n  KEY `idx_acct_period_id` (`accounting_period_id`),\n  KEY `idx_run_ctrl_id` (`run_controller_id`),\n  CONSTRAINT `fk_acc_run_run_ctrl` FOREIGN KEY (`run_controller_id`) REFERENCES `run_controller` (`run_controller_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_acct_run_acct_period` FOREIGN KEY (`accounting_period_id`) REFERENCES `accounting_period` (`accounting_period_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "contract",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "contract_name",
          "type": "varchar(180)",
          "nullable": false,
          "default": ""
        },
        {
          "name": "contract_type",
          "type": "enum('distribution','legacy_distribution','neighbouring_rights')",
          "nullable": false,
          "default": "distribution"
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "execution_date",
          "type": "date",
          "nullable": true
        },
        {
          "name": "general_note",
          "type": "mediumtext",
          "nullable": true
        },
        {
          "name": "initial_start_date",
          "type": "date",
          "nullable": true
        },
        {
          "name": "is_excluded_from_accounting_run",
          "type": "tinyint(1)",
          "nullable": true,
          "default": "0"
        },
        {
          "name": "is_paythrough_contract",
          "type": "tinyint(1)",
          "nullable": false,
          "default": "0"
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "reference_signing_entity_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "sap_created_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "summary_note",
          "type": "mediumtext",
          "nullable": true
        },
        {
          "name": "term_end",
          "type": "date",
          "nullable": true
        },
        {
          "name": "term_start",
          "type": "date",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (contract_id) USING BTREE",
          "table": "contract",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_contract_reference_signing_entity",
          "def": "KEY fk_contract_reference_signing_entity (reference_signing_entity_id) USING BTREE",
          "table": "contract",
          "columns": [
            "reference_signing_entity_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (contract_id)",
          "table": "contract",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_contract_reference_signing_entity",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (reference_signing_entity_id) REFERENCES reference_signing_entity (reference_signing_entity_id)",
          "table": "contract",
          "referenced_table": "reference_signing_entity",
          "columns": [
            "reference_signing_entity_id"
          ],
          "referenced_columns": [
            "reference_signing_entity_id"
          ]
        }
      ],
      "triggers": [
        {
          "name": "after_contract_update",
          "def": "CREATE TRIGGER after_contract_update AFTER UPDATE ON contract\nFOR EACH ROW\nBEGIN\n    INSERT INTO contract_history(\n        `contract_id`,\n        `reference_signing_entity_id`,\n        `contract_name`,\n        `contract_type`,\n        `sap_created_at`,\n        `initial_start_date`,\n        `execution_date`,\n        `is_excluded_from_accounting_run`,\n        `summary_note`,\n        `general_note`,\n        `term_start`,\n        `term_end`,\n        `created_by`,\n        `created_at`,\n        `last_modified_by`,\n        `last_modified`\n    ) VALUES (\n        OLD.contract_id,\n        OLD.reference_signing_entity_id,\n        OLD.contract_name,\n        OLD.contract_type,\n        OLD.sap_created_at,\n        OLD.initial_start_date,\n        OLD.execution_date,\n        OLD.is_excluded_from_accounting_run,\n        OLD.summary_note,\n        OLD.general_note,\n        OLD.term_start,\n        OLD.term_end,\n        OLD.created_by,\n        OLD.created_at,\n        OLD.last_modified_by,\n        OLD.last_modified\n    );\nEND"
        }
      ],
      "def": "CREATE TABLE `contract` (\n  `contract_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `reference_signing_entity_id` mediumint unsigned NOT NULL,\n  `contract_name` varchar(180) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',\n  `contract_type` enum('distribution','legacy_distribution','neighbouring_rights') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'distribution',\n  `sap_created_at` datetime DEFAULT NULL,\n  `initial_start_date` date DEFAULT NULL,\n  `execution_date` date DEFAULT NULL,\n  `is_excluded_from_accounting_run` tinyint(1) DEFAULT '0',\n  `is_paythrough_contract` tinyint(1) NOT NULL DEFAULT '0',\n  `summary_note` mediumtext COLLATE utf8mb4_general_ci,\n  `general_note` mediumtext COLLATE utf8mb4_general_ci,\n  `term_start` date DEFAULT NULL,\n  `term_end` date DEFAULT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`contract_id`),\n  KEY `fk_contract_reference_signing_entity` (`reference_signing_entity_id`),\n  CONSTRAINT `fk_contract_reference_signing_entity` FOREIGN KEY (`reference_signing_entity_id`) REFERENCES `reference_signing_entity` (`reference_signing_entity_id`) ON DELETE RESTRICT ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "contract_advance",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "advance_description",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "advance_status",
          "type": "enum('not_qualified','qualified','approved','paid','deleted','in_review','pending_payment')",
          "nullable": false,
          "default": "not_qualified"
        },
        {
          "name": "amount",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "amount_after_withholding_and_vat",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "contract_advance_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "milestone",
          "type": "enum('contract_execution','delivery','recoupment','scheduled_installment','sales_milestone','other')",
          "nullable": false
        },
        {
          "name": "milestone_date",
          "type": "date",
          "nullable": true
        },
        {
          "name": "milestone_description",
          "type": "text",
          "nullable": false
        },
        {
          "name": "note",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "reference_advance_payment_method_id",
          "type": "smallint unsigned",
          "nullable": true
        },
        {
          "name": "reference_payment_type_id",
          "type": "smallint unsigned",
          "nullable": true
        },
        {
          "name": "us_source_income_rate",
          "type": "decimal(9,6) unsigned",
          "nullable": true
        },
        {
          "name": "vat_amount",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "withholding_tax_amount",
          "type": "decimal(20,2)",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (contract_advance_id) USING BTREE",
          "table": "contract_advance",
          "columns": [
            "contract_advance_id"
          ]
        },
        {
          "name": "fk_contract_advance_reference_advance_payment_method",
          "def": "KEY fk_contract_advance_reference_advance_payment_method (reference_advance_payment_method_id) USING BTREE",
          "table": "contract_advance",
          "columns": [
            "reference_advance_payment_method_id"
          ]
        },
        {
          "name": "fk_contract_advance_reference_payment_type",
          "def": "KEY fk_contract_advance_reference_payment_type (reference_payment_type_id) USING BTREE",
          "table": "contract_advance",
          "columns": [
            "reference_payment_type_id"
          ]
        },
        {
          "name": "fk_contract_contract_advance",
          "def": "KEY fk_contract_contract_advance (contract_id) USING BTREE",
          "table": "contract_advance",
          "columns": [
            "contract_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (contract_advance_id)",
          "table": "contract_advance",
          "columns": [
            "contract_advance_id"
          ]
        },
        {
          "name": "fk_contract_advance_reference_advance_payment_method",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (reference_advance_payment_method_id) REFERENCES reference_advance_payment_method (reference_advance_payment_method_id)",
          "table": "contract_advance",
          "referenced_table": "reference_advance_payment_method",
          "columns": [
            "reference_advance_payment_method_id"
          ],
          "referenced_columns": [
            "reference_advance_payment_method_id"
          ]
        },
        {
          "name": "fk_contract_advance_reference_payment_type",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (reference_payment_type_id) REFERENCES reference_payment_type (reference_payment_type_id)",
          "table": "contract_advance",
          "referenced_table": "reference_payment_type",
          "columns": [
            "reference_payment_type_id"
          ],
          "referenced_columns": [
            "reference_payment_type_id"
          ]
        },
        {
          "name": "fk_contract_contract_advance",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "contract_advance",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        }
      ],
      "triggers": [
        {
          "name": "after_contract_advance_update",
          "def": "CREATE TRIGGER after_contract_advance_update AFTER UPDATE ON contract_advance\nFOR EACH ROW\nBEGIN\n\tINSERT INTO `contract_advance_history`(\n\t\t`contract_advance_id`,\n\t\t`contract_id`,\n\t\t`reference_payment_type_id`,\n\t\t`reference_advance_payment_method_id`,\n\t    `advance_description`,\n\t\t`amount`,\n\t    `vat_amount`,\n\t    `withholding_tax_amount`,\n\t    `amount_after_withholding_and_vat`,\n\t    `us_source_income_rate`,\n\t\t`currency_code`,\n\t\t`milestone`,\n\t\t`milestone_description`,\n\t\t`milestone_date`,\n\t\t`advance_status`,\n\t\t`note`,\n\t\t`created_by`,\n\t\t`created_at`,\n\t\t`last_modified_by`,\n\t\t`last_modified`,\n\t\t`deleted_at`,\n\t\t`deleted_by`\n\t) VALUES (\n\t\told.contract_advance_id,\n\t\told.contract_id,\n\t\told.reference_payment_type_id,\n\t\told.reference_advance_payment_method_id,\n\t    old.advance_description,\n\t\told.amount,\n\t    old.vat_amount,\n\t    old.withholding_tax_amount,\n\t    old.amount_after_withholding_and_vat,\n\t    old.us_source_income_rate,\n\t\told.currency_code,\n\t\told.milestone,\n\t\told.milestone_description,\n\t\told.milestone_date,\n\t\told.advance_status,\n\t\told.note,\n\t\told.created_by,\n\t\told.created_at,\n\t\told.last_modified_by,\n\t\told.last_modified,\n\t\told.deleted_at,\n\t\told.deleted_by\n\t);\nEND"
        }
      ],
      "def": "CREATE TABLE `contract_advance` (\n  `contract_advance_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `contract_id` mediumint unsigned NOT NULL,\n  `reference_payment_type_id` smallint unsigned DEFAULT NULL,\n  `reference_advance_payment_method_id` smallint unsigned DEFAULT NULL,\n  `advance_description` varchar(180) NOT NULL,\n  `amount` decimal(20,2) NOT NULL,\n  `vat_amount` decimal(20,2) DEFAULT NULL,\n  `withholding_tax_amount` decimal(20,2) DEFAULT NULL,\n  `amount_after_withholding_and_vat` decimal(20,2) DEFAULT NULL,\n  `us_source_income_rate` decimal(9,6) unsigned DEFAULT NULL,\n  `currency_code` char(3) NOT NULL,\n  `milestone` enum('contract_execution','delivery','recoupment','scheduled_installment','sales_milestone','other') NOT NULL,\n  `milestone_description` text NOT NULL,\n  `milestone_date` date DEFAULT NULL,\n  `advance_status` enum('not_qualified','qualified','approved','paid','deleted','in_review','pending_payment') NOT NULL DEFAULT 'not_qualified',\n  `note` varchar(255) DEFAULT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(180) DEFAULT NULL,\n  PRIMARY KEY (`contract_advance_id`),\n  KEY `fk_contract_contract_advance` (`contract_id`),\n  KEY `fk_contract_advance_reference_advance_payment_method` (`reference_advance_payment_method_id`),\n  KEY `fk_contract_advance_reference_payment_type` (`reference_payment_type_id`),\n  CONSTRAINT `fk_contract_advance_reference_advance_payment_method` FOREIGN KEY (`reference_advance_payment_method_id`) REFERENCES `reference_advance_payment_method` (`reference_advance_payment_method_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_contract_advance_reference_payment_type` FOREIGN KEY (`reference_payment_type_id`) REFERENCES `reference_payment_type` (`reference_payment_type_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_contract_contract_advance` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "contract_advance_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "advance_description",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "advance_status",
          "type": "enum('not_qualified','qualified','approved','paid','deleted','in_review','pending_payment')",
          "nullable": false,
          "default": "not_qualified"
        },
        {
          "name": "amount",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "amount_after_withholding_and_vat",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "contract_advance_history_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "contract_advance_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "milestone",
          "type": "enum('contract_execution','delivery','recoupment','scheduled_installment','sales_milestone','other')",
          "nullable": false
        },
        {
          "name": "milestone_date",
          "type": "date",
          "nullable": true
        },
        {
          "name": "milestone_description",
          "type": "text",
          "nullable": false
        },
        {
          "name": "note",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "reference_advance_payment_method_id",
          "type": "smallint unsigned",
          "nullable": true
        },
        {
          "name": "reference_payment_type_id",
          "type": "smallint unsigned",
          "nullable": true
        },
        {
          "name": "us_source_income_rate",
          "type": "decimal(9,6) unsigned",
          "nullable": true
        },
        {
          "name": "vat_amount",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "withholding_tax_amount",
          "type": "decimal(20,2)",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (contract_advance_history_id) USING BTREE",
          "table": "contract_advance_history",
          "columns": [
            "contract_advance_history_id"
          ]
        },
        {
          "name": "fk_contract_advance_contract_advance_history",
          "def": "KEY fk_contract_advance_contract_advance_history (contract_advance_id) USING BTREE",
          "table": "contract_advance_history",
          "columns": [
            "contract_advance_id"
          ]
        },
        {
          "name": "fk_contract_advance_history_reference_advance_payment_method",
          "def": "KEY fk_contract_advance_history_reference_advance_payment_method (reference_advance_payment_method_id) USING BTREE",
          "table": "contract_advance_history",
          "columns": [
            "reference_advance_payment_method_id"
          ]
        },
        {
          "name": "fk_contract_advance_history_reference_payment_type",
          "def": "KEY fk_contract_advance_history_reference_payment_type (reference_payment_type_id) USING BTREE",
          "table": "contract_advance_history",
          "columns": [
            "reference_payment_type_id"
          ]
        },
        {
          "name": "fk_contract_contract_advance_history",
          "def": "KEY fk_contract_contract_advance_history (contract_id) USING BTREE",
          "table": "contract_advance_history",
          "columns": [
            "contract_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (contract_advance_history_id)",
          "table": "contract_advance_history",
          "columns": [
            "contract_advance_history_id"
          ]
        },
        {
          "name": "fk_contract_advance_contract_advance_history",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_advance_id) REFERENCES contract_advance (contract_advance_id)",
          "table": "contract_advance_history",
          "referenced_table": "contract_advance",
          "columns": [
            "contract_advance_id"
          ],
          "referenced_columns": [
            "contract_advance_id"
          ]
        },
        {
          "name": "fk_contract_advance_history_reference_advance_payment_method",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (reference_advance_payment_method_id) REFERENCES reference_advance_payment_method (reference_advance_payment_method_id)",
          "table": "contract_advance_history",
          "referenced_table": "reference_advance_payment_method",
          "columns": [
            "reference_advance_payment_method_id"
          ],
          "referenced_columns": [
            "reference_advance_payment_method_id"
          ]
        },
        {
          "name": "fk_contract_advance_history_reference_payment_type",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (reference_payment_type_id) REFERENCES reference_payment_type (reference_payment_type_id)",
          "table": "contract_advance_history",
          "referenced_table": "reference_payment_type",
          "columns": [
            "reference_payment_type_id"
          ],
          "referenced_columns": [
            "reference_payment_type_id"
          ]
        },
        {
          "name": "fk_contract_contract_advance_history",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "contract_advance_history",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        }
      ],
      "def": "CREATE TABLE `contract_advance_history` (\n  `contract_advance_history_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `contract_advance_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned NOT NULL,\n  `reference_payment_type_id` smallint unsigned DEFAULT NULL,\n  `reference_advance_payment_method_id` smallint unsigned DEFAULT NULL,\n  `advance_description` varchar(180) NOT NULL,\n  `amount` decimal(20,2) NOT NULL,\n  `vat_amount` decimal(20,2) DEFAULT NULL,\n  `withholding_tax_amount` decimal(20,2) DEFAULT NULL,\n  `amount_after_withholding_and_vat` decimal(20,2) DEFAULT NULL,\n  `us_source_income_rate` decimal(9,6) unsigned DEFAULT NULL,\n  `currency_code` char(3) NOT NULL,\n  `milestone` enum('contract_execution','delivery','recoupment','scheduled_installment','sales_milestone','other') NOT NULL,\n  `milestone_description` text NOT NULL,\n  `milestone_date` date DEFAULT NULL,\n  `advance_status` enum('not_qualified','qualified','approved','paid','deleted','in_review','pending_payment') NOT NULL DEFAULT 'not_qualified',\n  `note` varchar(255) DEFAULT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(180) DEFAULT NULL,\n  PRIMARY KEY (`contract_advance_history_id`),\n  KEY `fk_contract_advance_contract_advance_history` (`contract_advance_id`),\n  KEY `fk_contract_contract_advance_history` (`contract_id`),\n  KEY `fk_contract_advance_history_reference_advance_payment_method` (`reference_advance_payment_method_id`),\n  KEY `fk_contract_advance_history_reference_payment_type` (`reference_payment_type_id`),\n  CONSTRAINT `fk_contract_advance_contract_advance_history` FOREIGN KEY (`contract_advance_id`) REFERENCES `contract_advance` (`contract_advance_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_contract_advance_history_reference_advance_payment_method` FOREIGN KEY (`reference_advance_payment_method_id`) REFERENCES `reference_advance_payment_method` (`reference_advance_payment_method_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_contract_advance_history_reference_payment_type` FOREIGN KEY (`reference_payment_type_id`) REFERENCES `reference_payment_type` (`reference_payment_type_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_contract_contract_advance_history` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "contract_exclusion",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "contract_exclusion_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "exclusions",
          "type": "json",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (contract_exclusion_id) USING BTREE",
          "table": "contract_exclusion",
          "columns": [
            "contract_exclusion_id"
          ]
        },
        {
          "name": "uidx_contract_id",
          "def": "UNIQUE KEY uidx_contract_id (contract_id) USING BTREE",
          "table": "contract_exclusion",
          "columns": [
            "contract_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (contract_exclusion_id)",
          "table": "contract_exclusion",
          "columns": [
            "contract_exclusion_id"
          ]
        },
        {
          "name": "fk_contract_exclusion_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "contract_exclusion",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "uidx_contract_id",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_contract_id (contract_id)",
          "table": "contract_exclusion",
          "columns": [
            "contract_id"
          ]
        }
      ],
      "def": "CREATE TABLE `contract_exclusion` (\n  `contract_exclusion_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `contract_id` mediumint unsigned NOT NULL,\n  `exclusions` json NOT NULL,\n  PRIMARY KEY (`contract_exclusion_id`),\n  UNIQUE KEY `uidx_contract_id` (`contract_id`),\n  CONSTRAINT `fk_contract_exclusion_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "contract_flowthrough",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "contract_flowthrough_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "flowthrough_rate",
          "type": "decimal(5,2)",
          "nullable": false
        },
        {
          "name": "flowthrough_status",
          "type": "enum('active','shutoff','paused')",
          "nullable": false,
          "default": "active"
        },
        {
          "name": "has_automatic_shutoff",
          "type": "tinyint(1)",
          "nullable": false,
          "default": "1"
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "previous_flowthrough_status",
          "type": "enum('active','shutoff','paused')",
          "nullable": true
        },
        {
          "name": "recoupment_cap",
          "type": "bigint",
          "nullable": true
        },
        {
          "name": "reference_flowthrough_calculation_id",
          "type": "tinyint unsigned",
          "nullable": false
        },
        {
          "name": "status_last_modified",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "status_last_modified_by",
          "type": "varchar(180)",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (contract_flowthrough_id) USING BTREE",
          "table": "contract_flowthrough",
          "columns": [
            "contract_flowthrough_id"
          ]
        },
        {
          "name": "fk_contract_flowthrough_contract",
          "def": "KEY fk_contract_flowthrough_contract (contract_id) USING BTREE",
          "table": "contract_flowthrough",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_contract_flowthrough_reference_flowthrough_calculation",
          "def": "KEY fk_contract_flowthrough_reference_flowthrough_calculation (reference_flowthrough_calculation_id) USING BTREE",
          "table": "contract_flowthrough",
          "columns": [
            "reference_flowthrough_calculation_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (contract_flowthrough_id)",
          "table": "contract_flowthrough",
          "columns": [
            "contract_flowthrough_id"
          ]
        },
        {
          "name": "fk_contract_flowthrough_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "contract_flowthrough",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_contract_flowthrough_reference_flowthrough_calculation",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (reference_flowthrough_calculation_id) REFERENCES reference_flowthrough_calculation (reference_flowthrough_calculation_id)",
          "table": "contract_flowthrough",
          "referenced_table": "reference_flowthrough_calculation",
          "columns": [
            "reference_flowthrough_calculation_id"
          ],
          "referenced_columns": [
            "reference_flowthrough_calculation_id"
          ]
        }
      ],
      "triggers": [
        {
          "name": "after_update_contract_flowthrough_history",
          "def": "CREATE TRIGGER after_update_contract_flowthrough_history AFTER UPDATE ON contract_flowthrough\nFOR EACH ROW\nBEGIN\n    INSERT INTO `contract_flowthrough_history` (\n        `contract_flowthrough_id`,\n        `contract_id`,\n        `reference_flowthrough_calculation_id`,\n        `flowthrough_rate`,\n        `flowthrough_status`,\n        `has_automatic_shutoff`,\n        `recoupment_cap`,\n        `previous_flowthrough_status`,\n        `status_last_modified_by`,\n        `status_last_modified`,\n        `created_by`,\n        `created_at`,\n        `last_modified_by`,\n        `last_modified`,\n        `deleted_by`,\n        `deleted_at`\n    ) VALUES (\n        OLD.contract_flowthrough_id,\n        OLD.contract_id,\n        OLD.reference_flowthrough_calculation_id,\n        OLD.flowthrough_rate,\n        OLD.flowthrough_status,\n        OLD.has_automatic_shutoff,\n        OLD.recoupment_cap,\n        OLD.previous_flowthrough_status,\n        OLD.status_last_modified_by,\n        OLD.status_last_modified,\n        OLD.created_by,\n        OLD.created_at,\n        OLD.last_modified_by,\n        OLD.last_modified,\n        OLD.deleted_by,\n        OLD.deleted_at\n    );\nEND"
        }
      ],
      "def": "CREATE TABLE `contract_flowthrough` (\n  `contract_flowthrough_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `contract_id` mediumint unsigned NOT NULL,\n  `reference_flowthrough_calculation_id` tinyint unsigned NOT NULL,\n  `flowthrough_rate` decimal(5,2) NOT NULL,\n  `flowthrough_status` enum('active','shutoff','paused') NOT NULL DEFAULT 'active',\n  `has_automatic_shutoff` tinyint(1) NOT NULL DEFAULT '1',\n  `recoupment_cap` bigint DEFAULT NULL,\n  `previous_flowthrough_status` enum('active','shutoff','paused') DEFAULT NULL,\n  `status_last_modified_by` varchar(180) DEFAULT NULL,\n  `status_last_modified` datetime DEFAULT NULL,\n  `created_by` varchar(180) NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `deleted_by` varchar(180) DEFAULT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  PRIMARY KEY (`contract_flowthrough_id`),\n  KEY `fk_contract_flowthrough_contract` (`contract_id`),\n  KEY `fk_contract_flowthrough_reference_flowthrough_calculation` (`reference_flowthrough_calculation_id`),\n  CONSTRAINT `fk_contract_flowthrough_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_contract_flowthrough_reference_flowthrough_calculation` FOREIGN KEY (`reference_flowthrough_calculation_id`) REFERENCES `reference_flowthrough_calculation` (`reference_flowthrough_calculation_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci"
    },
    {
      "name": "contract_flowthrough_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "contract_flowthrough_history_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "contract_flowthrough_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "flowthrough_rate",
          "type": "decimal(5,2)",
          "nullable": false
        },
        {
          "name": "flowthrough_status",
          "type": "enum('active','shutoff','paused')",
          "nullable": false,
          "default": "active"
        },
        {
          "name": "has_automatic_shutoff",
          "type": "tinyint(1)",
          "nullable": false,
          "default": "1"
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "previous_flowthrough_status",
          "type": "enum('active','shutoff','paused')",
          "nullable": true
        },
        {
          "name": "recoupment_cap",
          "type": "bigint",
          "nullable": true
        },
        {
          "name": "reference_flowthrough_calculation_id",
          "type": "tinyint unsigned",
          "nullable": false
        },
        {
          "name": "status_last_modified",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "status_last_modified_by",
          "type": "varchar(180)",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (contract_flowthrough_history_id) USING BTREE",
          "table": "contract_flowthrough_history",
          "columns": [
            "contract_flowthrough_history_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (contract_flowthrough_history_id)",
          "table": "contract_flowthrough_history",
          "columns": [
            "contract_flowthrough_history_id"
          ]
        }
      ],
      "def": "CREATE TABLE `contract_flowthrough_history` (\n  `contract_flowthrough_history_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `contract_flowthrough_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned NOT NULL,\n  `reference_flowthrough_calculation_id` tinyint unsigned NOT NULL,\n  `flowthrough_rate` decimal(5,2) NOT NULL,\n  `flowthrough_status` enum('active','shutoff','paused') NOT NULL DEFAULT 'active',\n  `has_automatic_shutoff` tinyint(1) NOT NULL DEFAULT '1',\n  `recoupment_cap` bigint DEFAULT NULL,\n  `previous_flowthrough_status` enum('active','shutoff','paused') DEFAULT NULL,\n  `status_last_modified_by` varchar(180) DEFAULT NULL,\n  `status_last_modified` datetime DEFAULT NULL,\n  `created_by` varchar(180) NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `deleted_by` varchar(180) DEFAULT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  PRIMARY KEY (`contract_flowthrough_history_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci"
    },
    {
      "name": "contract_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "contract_history_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_name",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "contract_type",
          "type": "enum('distribution','legacy_distribution','neighbouring_rights')",
          "nullable": false,
          "default": "distribution"
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "execution_date",
          "type": "date",
          "nullable": true
        },
        {
          "name": "general_note",
          "type": "mediumtext",
          "nullable": true
        },
        {
          "name": "initial_start_date",
          "type": "date",
          "nullable": true
        },
        {
          "name": "is_excluded_from_accounting_run",
          "type": "tinyint(1)",
          "nullable": true,
          "default": "0"
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "reference_signing_entity_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "sap_created_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "summary_note",
          "type": "mediumtext",
          "nullable": true
        },
        {
          "name": "term_end",
          "type": "date",
          "nullable": true
        },
        {
          "name": "term_start",
          "type": "date",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "FK_contract_history_contract",
          "def": "KEY FK_contract_history_contract (contract_id) USING BTREE",
          "table": "contract_history",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (contract_history_id) USING BTREE",
          "table": "contract_history",
          "columns": [
            "contract_history_id"
          ]
        },
        {
          "name": "fk_contract_history_reference_signing_entity",
          "def": "KEY fk_contract_history_reference_signing_entity (reference_signing_entity_id) USING BTREE",
          "table": "contract_history",
          "columns": [
            "reference_signing_entity_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (contract_history_id)",
          "table": "contract_history",
          "columns": [
            "contract_history_id"
          ]
        },
        {
          "name": "fk_contract_history_reference_signing_entity",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (reference_signing_entity_id) REFERENCES reference_signing_entity (reference_signing_entity_id)",
          "table": "contract_history",
          "referenced_table": "reference_signing_entity",
          "columns": [
            "reference_signing_entity_id"
          ],
          "referenced_columns": [
            "reference_signing_entity_id"
          ]
        }
      ],
      "def": "CREATE TABLE `contract_history` (\n  `contract_history_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `contract_id` mediumint unsigned NOT NULL,\n  `reference_signing_entity_id` mediumint unsigned NOT NULL,\n  `contract_name` varchar(180) NOT NULL,\n  `contract_type` enum('distribution','legacy_distribution','neighbouring_rights') NOT NULL DEFAULT 'distribution',\n  `sap_created_at` datetime DEFAULT NULL,\n  `initial_start_date` date DEFAULT NULL,\n  `execution_date` date DEFAULT NULL,\n  `is_excluded_from_accounting_run` tinyint(1) DEFAULT '0',\n  `summary_note` mediumtext,\n  `general_note` mediumtext,\n  `term_start` date DEFAULT NULL,\n  `term_end` date DEFAULT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`contract_history_id`),\n  KEY `FK_contract_history_contract` (`contract_id`),\n  KEY `fk_contract_history_reference_signing_entity` (`reference_signing_entity_id`),\n  CONSTRAINT `fk_contract_history_reference_signing_entity` FOREIGN KEY (`reference_signing_entity_id`) REFERENCES `reference_signing_entity` (`reference_signing_entity_id`) ON DELETE RESTRICT ON UPDATE RESTRICT\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "contract_lifecycle",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "collection_end",
          "type": "date",
          "nullable": true
        },
        {
          "name": "collection_start",
          "type": "date",
          "nullable": true
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_lifecycle_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "contract_lifecycle_schedule_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "last_renewed",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "lifecycle_status",
          "type": "enum('init','active','to_be_terminated','terminated','in_collection_period','inactive')",
          "nullable": false,
          "default": "init"
        },
        {
          "name": "lifecycle_term_end",
          "type": "date",
          "nullable": true
        },
        {
          "name": "lifecycle_term_start",
          "type": "date",
          "nullable": false
        },
        {
          "name": "renewal_effective",
          "type": "date",
          "nullable": true
        },
        {
          "name": "termination_effective",
          "type": "date",
          "nullable": true
        },
        {
          "name": "termination_notice_deadline",
          "type": "date",
          "nullable": true
        },
        {
          "name": "termination_notice_received",
          "type": "date",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (contract_lifecycle_id) USING BTREE",
          "table": "contract_lifecycle",
          "columns": [
            "contract_lifecycle_id"
          ]
        },
        {
          "name": "fk_contract_lifecycle_contract",
          "def": "KEY fk_contract_lifecycle_contract (contract_id) USING BTREE",
          "table": "contract_lifecycle",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_contract_lifecycle_contract_lifecycle_schedule",
          "def": "KEY fk_contract_lifecycle_contract_lifecycle_schedule (contract_lifecycle_schedule_id) USING BTREE",
          "table": "contract_lifecycle",
          "columns": [
            "contract_lifecycle_schedule_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (contract_lifecycle_id)",
          "table": "contract_lifecycle",
          "columns": [
            "contract_lifecycle_id"
          ]
        },
        {
          "name": "fk_contract_lifecycle_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "contract_lifecycle",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_contract_lifecycle_contract_lifecycle_schedule",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_lifecycle_schedule_id) REFERENCES contract_lifecycle_schedule (contract_lifecycle_schedule_id)",
          "table": "contract_lifecycle",
          "referenced_table": "contract_lifecycle_schedule",
          "columns": [
            "contract_lifecycle_schedule_id"
          ],
          "referenced_columns": [
            "contract_lifecycle_schedule_id"
          ]
        }
      ],
      "triggers": [
        {
          "name": "after_update_contract_lifecycle",
          "def": "CREATE TRIGGER after_update_contract_lifecycle AFTER UPDATE ON contract_lifecycle\nFOR EACH ROW\nBEGIN\n    INSERT INTO `contract_lifecycle_history` (\n        `contract_lifecycle_id`,\n        `contract_id`,\n        `contract_lifecycle_schedule_id`,\n        `lifecycle_status`,\n        `lifecycle_term_start`,\n        `lifecycle_term_end`,\n        `renewal_effective`,\n        `termination_notice_deadline`,\n        `termination_notice_received`,\n        `termination_effective`,\n        `collection_start`,\n        `collection_end`,\n        `created_by`,\n        `created_at`,\n        `last_modified_by`,\n        `last_modified`,\n        `deleted_by`,\n        `deleted_at`\n    ) VALUES (\n        old.contract_lifecycle_id,\n        old.contract_id,\n        old.contract_lifecycle_schedule_id,\n        old.lifecycle_status,\n        old.lifecycle_term_start,\n        old.lifecycle_term_end,\n        old.renewal_effective,\n        old.termination_notice_deadline,\n        old.termination_notice_received,\n        old.termination_effective,\n        old.collection_start,\n        old.collection_end,\n        old.created_by,\n        old.created_at,\n        old.last_modified_by,\n        old.last_modified,\n        old.deleted_by,\n        old.deleted_at\n    );\nEND"
        }
      ],
      "def": "CREATE TABLE `contract_lifecycle` (\n  `contract_lifecycle_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `contract_id` mediumint unsigned NOT NULL,\n  `contract_lifecycle_schedule_id` mediumint unsigned NOT NULL,\n  `lifecycle_status` enum('init','active','to_be_terminated','terminated','in_collection_period','inactive') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'init',\n  `lifecycle_term_start` date NOT NULL,\n  `lifecycle_term_end` date DEFAULT NULL,\n  `renewal_effective` date DEFAULT NULL,\n  `termination_notice_deadline` date DEFAULT NULL,\n  `termination_notice_received` date DEFAULT NULL,\n  `termination_effective` date DEFAULT NULL,\n  `collection_start` date DEFAULT NULL,\n  `collection_end` date DEFAULT NULL,\n  `last_renewed` datetime DEFAULT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `deleted_by` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  PRIMARY KEY (`contract_lifecycle_id`),\n  KEY `fk_contract_lifecycle_contract` (`contract_id`),\n  KEY `fk_contract_lifecycle_contract_lifecycle_schedule` (`contract_lifecycle_schedule_id`),\n  CONSTRAINT `fk_contract_lifecycle_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_contract_lifecycle_contract_lifecycle_schedule` FOREIGN KEY (`contract_lifecycle_schedule_id`) REFERENCES `contract_lifecycle_schedule` (`contract_lifecycle_schedule_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "contract_lifecycle_bkup_20251015",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "collection_end",
          "type": "date",
          "nullable": true
        },
        {
          "name": "collection_start",
          "type": "date",
          "nullable": true
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_lifecycle_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "default": "0"
        },
        {
          "name": "contract_lifecycle_schedule_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "last_renewed",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "lifecycle_status",
          "type": "enum('init','active','to_be_terminated','terminated','in_collection_period','inactive')",
          "nullable": false,
          "default": "init"
        },
        {
          "name": "lifecycle_term_end",
          "type": "date",
          "nullable": true
        },
        {
          "name": "lifecycle_term_start",
          "type": "date",
          "nullable": false
        },
        {
          "name": "renewal_effective",
          "type": "date",
          "nullable": true
        },
        {
          "name": "termination_effective",
          "type": "date",
          "nullable": true
        },
        {
          "name": "termination_notice_deadline",
          "type": "date",
          "nullable": true
        },
        {
          "name": "termination_notice_received",
          "type": "date",
          "nullable": true
        }
      ],
      "def": "CREATE TABLE `contract_lifecycle_bkup_20251015` (\n  `contract_lifecycle_id` mediumint unsigned NOT NULL DEFAULT '0',\n  `contract_id` mediumint unsigned NOT NULL,\n  `contract_lifecycle_schedule_id` mediumint unsigned NOT NULL,\n  `lifecycle_status` enum('init','active','to_be_terminated','terminated','in_collection_period','inactive') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'init',\n  `lifecycle_term_start` date NOT NULL,\n  `lifecycle_term_end` date DEFAULT NULL,\n  `renewal_effective` date DEFAULT NULL,\n  `termination_notice_deadline` date DEFAULT NULL,\n  `termination_notice_received` date DEFAULT NULL,\n  `termination_effective` date DEFAULT NULL,\n  `collection_start` date DEFAULT NULL,\n  `collection_end` date DEFAULT NULL,\n  `last_renewed` datetime DEFAULT NULL,\n  `created_by` varchar(180) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `deleted_by` varchar(180) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `deleted_at` datetime DEFAULT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "contract_lifecycle_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "collection_end",
          "type": "date",
          "nullable": true
        },
        {
          "name": "collection_start",
          "type": "date",
          "nullable": true
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_lifecycle_history_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "contract_lifecycle_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_lifecycle_schedule_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "lifecycle_status",
          "type": "enum('init','active','to_be_terminated','terminated','in_collection_period','inactive')",
          "nullable": false,
          "default": "init"
        },
        {
          "name": "lifecycle_term_end",
          "type": "date",
          "nullable": true
        },
        {
          "name": "lifecycle_term_start",
          "type": "date",
          "nullable": false
        },
        {
          "name": "renewal_effective",
          "type": "date",
          "nullable": true
        },
        {
          "name": "termination_effective",
          "type": "date",
          "nullable": true
        },
        {
          "name": "termination_notice_deadline",
          "type": "date",
          "nullable": true
        },
        {
          "name": "termination_notice_received",
          "type": "date",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (contract_lifecycle_history_id) USING BTREE",
          "table": "contract_lifecycle_history",
          "columns": [
            "contract_lifecycle_history_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (contract_lifecycle_history_id)",
          "table": "contract_lifecycle_history",
          "columns": [
            "contract_lifecycle_history_id"
          ]
        }
      ],
      "def": "CREATE TABLE `contract_lifecycle_history` (\n  `contract_lifecycle_history_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `contract_lifecycle_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned NOT NULL,\n  `contract_lifecycle_schedule_id` mediumint unsigned NOT NULL,\n  `lifecycle_status` enum('init','active','to_be_terminated','terminated','in_collection_period','inactive') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'init',\n  `lifecycle_term_start` date NOT NULL,\n  `lifecycle_term_end` date DEFAULT NULL,\n  `renewal_effective` date DEFAULT NULL,\n  `termination_notice_deadline` date DEFAULT NULL,\n  `termination_notice_received` date DEFAULT NULL,\n  `termination_effective` date DEFAULT NULL,\n  `collection_start` date DEFAULT NULL,\n  `collection_end` date DEFAULT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `deleted_by` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  PRIMARY KEY (`contract_lifecycle_history_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "contract_lifecycle_schedule",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "collection_period_detail_id",
          "type": "smallint unsigned",
          "nullable": true
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_lifecycle_schedule_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "renewal_offset_detail_id",
          "type": "smallint unsigned",
          "nullable": true
        },
        {
          "name": "renewal_type",
          "type": "enum('continuously_active','renew_after_certain_date','renew_periodically')",
          "nullable": false
        },
        {
          "name": "schedule_end",
          "type": "date",
          "nullable": true
        },
        {
          "name": "termination_notice_detail_id",
          "type": "smallint unsigned",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (contract_lifecycle_schedule_id) USING BTREE",
          "table": "contract_lifecycle_schedule",
          "columns": [
            "contract_lifecycle_schedule_id"
          ]
        },
        {
          "name": "fk_collection_period_detail_id",
          "def": "KEY fk_collection_period_detail_id (collection_period_detail_id) USING BTREE",
          "table": "contract_lifecycle_schedule",
          "columns": [
            "collection_period_detail_id"
          ]
        },
        {
          "name": "fk_contract_id",
          "def": "KEY fk_contract_id (contract_id) USING BTREE",
          "table": "contract_lifecycle_schedule",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_renewal_offset_detail_id",
          "def": "KEY fk_renewal_offset_detail_id (renewal_offset_detail_id) USING BTREE",
          "table": "contract_lifecycle_schedule",
          "columns": [
            "renewal_offset_detail_id"
          ]
        },
        {
          "name": "fk_termination_notice_detail_id",
          "def": "KEY fk_termination_notice_detail_id (termination_notice_detail_id) USING BTREE",
          "table": "contract_lifecycle_schedule",
          "columns": [
            "termination_notice_detail_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (contract_lifecycle_schedule_id)",
          "table": "contract_lifecycle_schedule",
          "columns": [
            "contract_lifecycle_schedule_id"
          ]
        },
        {
          "name": "fk_collection_period_detail_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (collection_period_detail_id) REFERENCES contract_lifecycle_schedule_detail (contract_lifecycle_schedule_detail_id)",
          "table": "contract_lifecycle_schedule",
          "referenced_table": "contract_lifecycle_schedule_detail",
          "columns": [
            "collection_period_detail_id"
          ],
          "referenced_columns": [
            "contract_lifecycle_schedule_detail_id"
          ]
        },
        {
          "name": "fk_contract_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "contract_lifecycle_schedule",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_renewal_offset_detail_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (renewal_offset_detail_id) REFERENCES contract_lifecycle_schedule_detail (contract_lifecycle_schedule_detail_id)",
          "table": "contract_lifecycle_schedule",
          "referenced_table": "contract_lifecycle_schedule_detail",
          "columns": [
            "renewal_offset_detail_id"
          ],
          "referenced_columns": [
            "contract_lifecycle_schedule_detail_id"
          ]
        },
        {
          "name": "fk_termination_notice_detail_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (termination_notice_detail_id) REFERENCES contract_lifecycle_schedule_detail (contract_lifecycle_schedule_detail_id)",
          "table": "contract_lifecycle_schedule",
          "referenced_table": "contract_lifecycle_schedule_detail",
          "columns": [
            "termination_notice_detail_id"
          ],
          "referenced_columns": [
            "contract_lifecycle_schedule_detail_id"
          ]
        }
      ],
      "def": "CREATE TABLE `contract_lifecycle_schedule` (\n  `contract_lifecycle_schedule_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `contract_id` mediumint unsigned NOT NULL,\n  `termination_notice_detail_id` smallint unsigned DEFAULT NULL,\n  `renewal_offset_detail_id` smallint unsigned DEFAULT NULL,\n  `collection_period_detail_id` smallint unsigned DEFAULT NULL,\n  `renewal_type` enum('continuously_active','renew_after_certain_date','renew_periodically') COLLATE utf8mb4_general_ci NOT NULL,\n  `schedule_end` date DEFAULT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `deleted_by` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  PRIMARY KEY (`contract_lifecycle_schedule_id`),\n  KEY `fk_contract_id` (`contract_id`),\n  KEY `fk_termination_notice_detail_id` (`termination_notice_detail_id`),\n  KEY `fk_renewal_offset_detail_id` (`renewal_offset_detail_id`),\n  KEY `fk_collection_period_detail_id` (`collection_period_detail_id`),\n  CONSTRAINT `fk_collection_period_detail_id` FOREIGN KEY (`collection_period_detail_id`) REFERENCES `contract_lifecycle_schedule_detail` (`contract_lifecycle_schedule_detail_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_contract_id` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_renewal_offset_detail_id` FOREIGN KEY (`renewal_offset_detail_id`) REFERENCES `contract_lifecycle_schedule_detail` (`contract_lifecycle_schedule_detail_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_termination_notice_detail_id` FOREIGN KEY (`termination_notice_detail_id`) REFERENCES `contract_lifecycle_schedule_detail` (`contract_lifecycle_schedule_detail_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "contract_lifecycle_schedule_detail",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "contract_lifecycle_schedule_detail_id",
          "type": "smallint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "period_interval",
          "type": "smallint unsigned",
          "nullable": false
        },
        {
          "name": "period_type",
          "type": "enum('day','month','year')",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (contract_lifecycle_schedule_detail_id) USING BTREE",
          "table": "contract_lifecycle_schedule_detail",
          "columns": [
            "contract_lifecycle_schedule_detail_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (contract_lifecycle_schedule_detail_id)",
          "table": "contract_lifecycle_schedule_detail",
          "columns": [
            "contract_lifecycle_schedule_detail_id"
          ]
        }
      ],
      "def": "CREATE TABLE `contract_lifecycle_schedule_detail` (\n  `contract_lifecycle_schedule_detail_id` smallint unsigned NOT NULL AUTO_INCREMENT,\n  `period_interval` smallint unsigned NOT NULL,\n  `period_type` enum('day','month','year') COLLATE utf8mb4_general_ci NOT NULL,\n  PRIMARY KEY (`contract_lifecycle_schedule_detail_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "contract_mechanical_deduction",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "admin_fee",
          "type": "decimal(5,2)",
          "nullable": true
        },
        {
          "name": "admin_type",
          "type": "enum('both','business','customer')",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_mechanical_deduction_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "mechanical_type",
          "type": "set('digital','physical','ringtone')",
          "nullable": false
        },
        {
          "name": "territory",
          "type": "enum('USA','CAN','ROW')",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (contract_mechanical_deduction_id) USING BTREE",
          "table": "contract_mechanical_deduction",
          "columns": [
            "contract_mechanical_deduction_id"
          ]
        },
        {
          "name": "unique_contract_mech_deduction",
          "def": "UNIQUE KEY unique_contract_mech_deduction (contract_id, territory, deleted_at) USING BTREE",
          "table": "contract_mechanical_deduction",
          "columns": [
            "contract_id",
            "territory",
            "deleted_at"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (contract_mechanical_deduction_id)",
          "table": "contract_mechanical_deduction",
          "columns": [
            "contract_mechanical_deduction_id"
          ]
        },
        {
          "name": "fk_contract_mechanical_deduction_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "contract_mechanical_deduction",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "unique_contract_mech_deduction",
          "type": "UNIQUE",
          "def": "UNIQUE KEY unique_contract_mech_deduction (contract_id, territory, deleted_at)",
          "table": "contract_mechanical_deduction",
          "columns": [
            "contract_id",
            "territory",
            "deleted_at"
          ]
        }
      ],
      "triggers": [
        {
          "name": "after_update_contract_mechanical_deduction",
          "def": "CREATE TRIGGER after_update_contract_mechanical_deduction AFTER UPDATE ON contract_mechanical_deduction\nFOR EACH ROW\nBEGIN\n    INSERT INTO\n        `contract_mechanical_deduction_history`\n        (\n            `contract_mechanical_deduction_id`,\n            `contract_id`,\n            `territory`,\n            `mechanical_type`,\n            `admin_type`,\n            `admin_fee`,\n            `created_by`,\n            `created_at`,\n            `last_modified_by`,\n            `last_modified`,\n            `deleted_by`,\n            `deleted_at`\n        )\n    VALUES\n        (\n             old.contract_mechanical_deduction_id,\n             old.contract_id,\n             old.territory,\n             old.mechanical_type,\n             old.admin_type,\n             old.admin_fee,\n             old.created_by,\n             old.created_at,\n             old.last_modified_by,\n             old.last_modified,\n             old.deleted_by,\n             old.deleted_at\n        ); END"
        }
      ],
      "def": "CREATE TABLE `contract_mechanical_deduction` (\n  `contract_mechanical_deduction_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `contract_id` mediumint unsigned NOT NULL,\n  `territory` enum('USA','CAN','ROW') COLLATE utf8mb4_general_ci NOT NULL,\n  `mechanical_type` set('digital','physical','ringtone') COLLATE utf8mb4_general_ci NOT NULL,\n  `admin_type` enum('both','business','customer') COLLATE utf8mb4_general_ci NOT NULL,\n  `admin_fee` decimal(5,2) DEFAULT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `deleted_by` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  PRIMARY KEY (`contract_mechanical_deduction_id`),\n  UNIQUE KEY `unique_contract_mech_deduction` (`contract_id`,`territory`,`deleted_at`),\n  CONSTRAINT `fk_contract_mechanical_deduction_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "contract_mechanical_deduction_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "admin_fee",
          "type": "decimal(5,2)",
          "nullable": true
        },
        {
          "name": "admin_type",
          "type": "enum('both','business','customer')",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_mechanical_deduction_history_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "contract_mechanical_deduction_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "mechanical_type",
          "type": "set('digital','physical','ringtone')",
          "nullable": false
        },
        {
          "name": "territory",
          "type": "enum('USA','CAN','ROW')",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (contract_mechanical_deduction_history_id) USING BTREE",
          "table": "contract_mechanical_deduction_history",
          "columns": [
            "contract_mechanical_deduction_history_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (contract_mechanical_deduction_history_id)",
          "table": "contract_mechanical_deduction_history",
          "columns": [
            "contract_mechanical_deduction_history_id"
          ]
        }
      ],
      "def": "CREATE TABLE `contract_mechanical_deduction_history` (\n  `contract_mechanical_deduction_history_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `contract_mechanical_deduction_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned NOT NULL,\n  `territory` enum('USA','CAN','ROW') COLLATE utf8mb4_general_ci NOT NULL,\n  `mechanical_type` set('digital','physical','ringtone') COLLATE utf8mb4_general_ci NOT NULL,\n  `admin_type` enum('both','business','customer') COLLATE utf8mb4_general_ci NOT NULL,\n  `admin_fee` decimal(5,2) DEFAULT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `deleted_by` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  PRIMARY KEY (`contract_mechanical_deduction_history_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "contract_party",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_party_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "target_id",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "target_type",
          "type": "enum('contributor','label')",
          "nullable": false,
          "default": "contributor"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (contract_party_id) USING BTREE",
          "table": "contract_party",
          "columns": [
            "contract_party_id"
          ]
        },
        {
          "name": "fk_contract_party_contract",
          "def": "KEY fk_contract_party_contract (contract_id) USING BTREE",
          "table": "contract_party",
          "columns": [
            "contract_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (contract_party_id)",
          "table": "contract_party",
          "columns": [
            "contract_party_id"
          ]
        },
        {
          "name": "fk_contract_party_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "contract_party",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        }
      ],
      "triggers": [
        {
          "name": "after_insert_contract_party",
          "def": "CREATE TRIGGER after_insert_contract_party AFTER INSERT ON contract_party\nFOR EACH ROW\nBEGIN\n    IF (NEW.target_type = 'contributor') THEN\n        IF NOT EXISTS (\n            SELECT s.schedule_id FROM `schedule` AS s\n            INNER JOIN `schedule_attachment` AS sa ON s.schedule_id = sa.schedule_id\n            WHERE s.target_id = NEW.target_id AND s.target_type = 'contributor' AND\n            sa.target_id = NEW.target_id AND sa.target_type = 'contributor'\n        ) THEN\n            INSERT INTO `schedule` (\n                `schedule_name`,\n                `target_type`,\n                `target_id`,\n                `created_by`,\n                `created_at`,\n                `last_modified_by`,\n                `last_modified`\n            )\n            VALUES (\n                'Contributor Only Schedule',\n                'contributor',\n                NEW.target_id,\n                NEW.created_by,\n                NEW.created_at,\n                NEW.last_modified_by,\n                NEW.last_modified\n            );\n            SET @schedule_id = LAST_INSERT_ID();\n\n            INSERT INTO `schedule_attachment` (\n                `schedule_id`,\n                `target_type`,\n                `target_id`,\n                `created_by`,\n                `created_at`,\n                `last_modified_by`,\n                `last_modified`\n            )\n            VALUES (\n                @schedule_id,\n                'contributor',\n                NEW.target_id,\n                NEW.created_by,\n                NEW.created_at,\n                NEW.last_modified_by,\n                NEW.last_modified\n            );\n        END IF;\n    END IF;\nEND"
        },
        {
          "name": "after_update_contract_party",
          "def": "CREATE TRIGGER after_update_contract_party AFTER UPDATE ON contract_party\nFOR EACH ROW\nBEGIN\n    INSERT INTO `contract_party_history` (\n        `contract_party_id`,\n        `contract_id`,\n        `target_type`,\n        `target_id`,\n        `created_at`,\n        `created_by`,\n        `last_modified`,\n        `last_modified_by`,\n        `deleted_by`,\n        `deleted_at`\n    ) VALUES (\n        old.contract_party_id,\n        old.contract_id,\n        old.target_type,\n        old.target_id,\n        old.created_at,\n        old.created_by,\n        old.last_modified,\n        old.last_modified_by,\n        old.deleted_by,\n        old.deleted_at\n    );\nEND"
        }
      ],
      "def": "CREATE TABLE `contract_party` (\n  `contract_party_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `contract_id` mediumint unsigned NOT NULL,\n  `target_type` enum('contributor','label') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'contributor',\n  `target_id` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  PRIMARY KEY (`contract_party_id`),\n  KEY `fk_contract_party_contract` (`contract_id`),\n  CONSTRAINT `fk_contract_party_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE RESTRICT ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "contract_party_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_party_history_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "contract_party_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "target_id",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "target_type",
          "type": "enum('contributor','label')",
          "nullable": false,
          "default": "contributor"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (contract_party_history_id) USING BTREE",
          "table": "contract_party_history",
          "columns": [
            "contract_party_history_id"
          ]
        },
        {
          "name": "fk_contract_party_contract_party_history",
          "def": "KEY fk_contract_party_contract_party_history (contract_party_id) USING BTREE",
          "table": "contract_party_history",
          "columns": [
            "contract_party_id"
          ]
        },
        {
          "name": "fk_contract_party_history_contract",
          "def": "KEY fk_contract_party_history_contract (contract_id) USING BTREE",
          "table": "contract_party_history",
          "columns": [
            "contract_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (contract_party_history_id)",
          "table": "contract_party_history",
          "columns": [
            "contract_party_history_id"
          ]
        },
        {
          "name": "fk_contract_party_contract_party_history",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_party_id) REFERENCES contract_party (contract_party_id)",
          "table": "contract_party_history",
          "referenced_table": "contract_party",
          "columns": [
            "contract_party_id"
          ],
          "referenced_columns": [
            "contract_party_id"
          ]
        },
        {
          "name": "fk_contract_party_history_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "contract_party_history",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        }
      ],
      "def": "CREATE TABLE `contract_party_history` (\n  `contract_party_history_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `contract_party_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned NOT NULL,\n  `target_type` enum('contributor','label') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'contributor',\n  `target_id` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  PRIMARY KEY (`contract_party_history_id`),\n  KEY `fk_contract_party_contract_party_history` (`contract_party_id`),\n  KEY `fk_contract_party_history_contract` (`contract_id`),\n  CONSTRAINT `fk_contract_party_contract_party_history` FOREIGN KEY (`contract_party_id`) REFERENCES `contract_party` (`contract_party_id`) ON DELETE RESTRICT ON UPDATE CASCADE,\n  CONSTRAINT `fk_contract_party_history_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE RESTRICT ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "contract_reserve",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "conditions",
          "type": "json",
          "nullable": true
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_reserve_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "installments_in_months",
          "type": "tinyint",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "release_schedule",
          "type": "json",
          "nullable": false
        },
        {
          "name": "reserve_rate",
          "type": "decimal(5,2)",
          "nullable": false
        },
        {
          "name": "reserve_release_offset_in_months",
          "type": "tinyint",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (contract_reserve_id) USING BTREE",
          "table": "contract_reserve",
          "columns": [
            "contract_reserve_id"
          ]
        },
        {
          "name": "uidx_contract_reserve_deleted",
          "def": "UNIQUE KEY uidx_contract_reserve_deleted (contract_id, deleted_at) USING BTREE",
          "table": "contract_reserve",
          "columns": [
            "contract_id",
            "deleted_at"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (contract_reserve_id)",
          "table": "contract_reserve",
          "columns": [
            "contract_reserve_id"
          ]
        },
        {
          "name": "fk_contract_reserve_contract_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "contract_reserve",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "uidx_contract_reserve_deleted",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_contract_reserve_deleted (contract_id, deleted_at)",
          "table": "contract_reserve",
          "columns": [
            "contract_id",
            "deleted_at"
          ]
        }
      ],
      "def": "CREATE TABLE `contract_reserve` (\n  `contract_reserve_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `contract_id` mediumint unsigned NOT NULL,\n  `reserve_rate` decimal(5,2) NOT NULL,\n  `reserve_release_offset_in_months` tinyint NOT NULL,\n  `installments_in_months` tinyint NOT NULL,\n  `release_schedule` json NOT NULL,\n  `conditions` json DEFAULT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `deleted_by` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  PRIMARY KEY (`contract_reserve_id`),\n  UNIQUE KEY `uidx_contract_reserve_deleted` (`contract_id`,`deleted_at`),\n  CONSTRAINT `fk_contract_reserve_contract_id` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "contract_template",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "contract_exclusions",
          "type": "json",
          "nullable": false
        },
        {
          "name": "contract_template_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "contract_terms",
          "type": "json",
          "nullable": false
        },
        {
          "name": "contract_type",
          "type": "enum('distribution','legacy_distribution','neighbouring_rights')",
          "nullable": false,
          "default": "distribution"
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "reference_signing_entity_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "run_controller_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "template_name",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "term_duration_year",
          "type": "tinyint",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (contract_template_id) USING BTREE",
          "table": "contract_template",
          "columns": [
            "contract_template_id"
          ]
        },
        {
          "name": "fk_contract_template_reference_signing_entity",
          "def": "KEY fk_contract_template_reference_signing_entity (reference_signing_entity_id) USING BTREE",
          "table": "contract_template",
          "columns": [
            "reference_signing_entity_id"
          ]
        },
        {
          "name": "fk_contract_template_run_controller",
          "def": "KEY fk_contract_template_run_controller (run_controller_id) USING BTREE",
          "table": "contract_template",
          "columns": [
            "run_controller_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (contract_template_id)",
          "table": "contract_template",
          "columns": [
            "contract_template_id"
          ]
        },
        {
          "name": "fk_contract_template_reference_signing_entity",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (reference_signing_entity_id) REFERENCES reference_signing_entity (reference_signing_entity_id)",
          "table": "contract_template",
          "referenced_table": "reference_signing_entity",
          "columns": [
            "reference_signing_entity_id"
          ],
          "referenced_columns": [
            "reference_signing_entity_id"
          ]
        },
        {
          "name": "fk_contract_template_run_controller",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (run_controller_id) REFERENCES run_controller (run_controller_id)",
          "table": "contract_template",
          "referenced_table": "run_controller",
          "columns": [
            "run_controller_id"
          ],
          "referenced_columns": [
            "run_controller_id"
          ]
        }
      ],
      "def": "CREATE TABLE `contract_template` (\n  `contract_template_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `template_name` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `run_controller_id` mediumint unsigned DEFAULT NULL,\n  `reference_signing_entity_id` mediumint unsigned NOT NULL,\n  `term_duration_year` tinyint DEFAULT NULL,\n  `contract_type` enum('distribution','legacy_distribution','neighbouring_rights') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'distribution',\n  `contract_terms` json NOT NULL,\n  `contract_exclusions` json NOT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`contract_template_id`),\n  KEY `fk_contract_template_run_controller` (`run_controller_id`),\n  KEY `fk_contract_template_reference_signing_entity` (`reference_signing_entity_id`),\n  CONSTRAINT `fk_contract_template_reference_signing_entity` FOREIGN KEY (`reference_signing_entity_id`) REFERENCES `reference_signing_entity` (`reference_signing_entity_id`) ON DELETE RESTRICT ON UPDATE CASCADE,\n  CONSTRAINT `fk_contract_template_run_controller` FOREIGN KEY (`run_controller_id`) REFERENCES `run_controller` (`run_controller_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "contract_term",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "attachments",
          "type": "json",
          "nullable": true
        },
        {
          "name": "attachments_relations",
          "type": "json",
          "nullable": true
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_term_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "contract_term_name",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "is_base_term",
          "type": "tinyint(1)",
          "nullable": false,
          "default": "1"
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "term_type",
          "type": "enum('artist','catalog','contribution','label','product','track','contributor_schedule','contribution_schedule')",
          "nullable": false,
          "default": "label"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (contract_term_id) USING BTREE",
          "table": "contract_term",
          "columns": [
            "contract_term_id"
          ]
        },
        {
          "name": "fk_contract_term_contract",
          "def": "KEY fk_contract_term_contract (contract_id) USING BTREE",
          "table": "contract_term",
          "columns": [
            "contract_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (contract_term_id)",
          "table": "contract_term",
          "columns": [
            "contract_term_id"
          ]
        },
        {
          "name": "fk_contract_term_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "contract_term",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        }
      ],
      "triggers": [
        {
          "name": "after_update_contract_term",
          "def": "CREATE TRIGGER after_update_contract_term AFTER UPDATE ON contract_term\nFOR EACH ROW\nBEGIN\n    INSERT INTO `contract_term_history` (\n        `contract_term_id`,\n        `contract_id`,\n        `contract_term_name`,\n        `term_type`,\n        `attachments`,\n        `attachments_relations`,\n        `is_base_term` ,\n        `created_by`,\n        `created_at`,\n        `last_modified_by`,\n        `last_modified`,\n        `deleted_by`,\n        `deleted_at`\n    ) VALUES (\n        old.contract_term_id,\n        old.contract_id,\n        old.contract_term_name,\n        old.term_type,\n        old.attachments,\n        old.attachments_relations,\n        old.is_base_term ,\n        old.created_by,\n        old.created_at,\n        old.last_modified_by,\n        old.last_modified,\n        old.deleted_by,\n        old.deleted_at\n    );\nEND"
        }
      ],
      "def": "CREATE TABLE `contract_term` (\n  `contract_term_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `contract_id` mediumint unsigned NOT NULL,\n  `contract_term_name` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `term_type` enum('artist','catalog','contribution','label','product','track','contributor_schedule','contribution_schedule') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'label',\n  `attachments` json DEFAULT NULL,\n  `attachments_relations` json DEFAULT NULL,\n  `is_base_term` tinyint(1) NOT NULL DEFAULT '1',\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `deleted_by` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  PRIMARY KEY (`contract_term_id`),\n  KEY `fk_contract_term_contract` (`contract_id`),\n  CONSTRAINT `fk_contract_term_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "contract_term_condition",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "commission",
          "type": "decimal(5,2)",
          "nullable": false
        },
        {
          "name": "conditions",
          "type": "json",
          "nullable": false
        },
        {
          "name": "contract_term_condition_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "contract_term_condition_name",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "contract_term_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "priority",
          "type": "tinyint",
          "nullable": false,
          "default": "1"
        },
        {
          "name": "term_rate",
          "type": "decimal(5,2)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (contract_term_condition_id) USING BTREE",
          "table": "contract_term_condition",
          "columns": [
            "contract_term_condition_id"
          ]
        },
        {
          "name": "fk_contract_term_cond_term_cond",
          "def": "KEY fk_contract_term_cond_term_cond (contract_term_id) USING BTREE",
          "table": "contract_term_condition",
          "columns": [
            "contract_term_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (contract_term_condition_id)",
          "table": "contract_term_condition",
          "columns": [
            "contract_term_condition_id"
          ]
        },
        {
          "name": "fk_contract_term_cond_term_cond",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_term_id) REFERENCES contract_term (contract_term_id)",
          "table": "contract_term_condition",
          "referenced_table": "contract_term",
          "columns": [
            "contract_term_id"
          ],
          "referenced_columns": [
            "contract_term_id"
          ]
        }
      ],
      "triggers": [
        {
          "name": "after_update_contract_term_condition",
          "def": "CREATE TRIGGER after_update_contract_term_condition AFTER UPDATE ON contract_term_condition\nFOR EACH ROW\nBEGIN\n    INSERT INTO `contract_term_condition_history` (\n        `contract_term_condition_id`,\n        `contract_term_id`,\n        `contract_term_condition_name`,\n        `conditions`,\n        `term_rate`,\n        `commission`,\n        `priority`,\n        `created_by`,\n        `created_at`,\n        `last_modified_by`,\n        `last_modified`,\n        `deleted_by`,\n        `deleted_at`\n    ) VALUES (\n        old.contract_term_condition_id,\n        old.contract_term_id,\n        old.contract_term_condition_name,\n        old.conditions,\n        old.term_rate,\n        old.commission,\n        old.priority,\n        old.created_by,\n        old.created_at,\n        old.last_modified_by,\n        old.last_modified,\n        old.deleted_by,\n        old.deleted_at\n    );\nEND"
        }
      ],
      "def": "CREATE TABLE `contract_term_condition` (\n  `contract_term_condition_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `contract_term_id` mediumint unsigned NOT NULL,\n  `contract_term_condition_name` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `conditions` json NOT NULL,\n  `term_rate` decimal(5,2) NOT NULL,\n  `commission` decimal(5,2) NOT NULL,\n  `priority` tinyint NOT NULL DEFAULT '1',\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `deleted_by` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  PRIMARY KEY (`contract_term_condition_id`),\n  KEY `fk_contract_term_cond_term_cond` (`contract_term_id`),\n  CONSTRAINT `fk_contract_term_cond_term_cond` FOREIGN KEY (`contract_term_id`) REFERENCES `contract_term` (`contract_term_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "contract_term_condition_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "commission",
          "type": "decimal(5,2)",
          "nullable": true
        },
        {
          "name": "conditions",
          "type": "json",
          "nullable": false
        },
        {
          "name": "contract_term_condition_history_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "contract_term_condition_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_term_condition_name",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "contract_term_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "priority",
          "type": "tinyint",
          "nullable": false,
          "default": "1"
        },
        {
          "name": "term_rate",
          "type": "decimal(5,2)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (contract_term_condition_history_id) USING BTREE",
          "table": "contract_term_condition_history",
          "columns": [
            "contract_term_condition_history_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (contract_term_condition_history_id)",
          "table": "contract_term_condition_history",
          "columns": [
            "contract_term_condition_history_id"
          ]
        }
      ],
      "def": "CREATE TABLE `contract_term_condition_history` (\n  `contract_term_condition_history_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `contract_term_condition_id` mediumint unsigned NOT NULL,\n  `contract_term_id` mediumint unsigned NOT NULL,\n  `contract_term_condition_name` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `conditions` json NOT NULL,\n  `term_rate` decimal(5,2) NOT NULL,\n  `commission` decimal(5,2) DEFAULT NULL,\n  `priority` tinyint NOT NULL DEFAULT '1',\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `deleted_by` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  PRIMARY KEY (`contract_term_condition_history_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "contract_term_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "attachments",
          "type": "json",
          "nullable": true
        },
        {
          "name": "attachments_relations",
          "type": "json",
          "nullable": true
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_term_history_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "contract_term_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_term_name",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "is_base_term",
          "type": "tinyint(1)",
          "nullable": false,
          "default": "1"
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "term_type",
          "type": "enum('artist','catalog','contribution','label','product','track','contributor_schedule','contribution_schedule')",
          "nullable": false,
          "default": "label"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (contract_term_history_id) USING BTREE",
          "table": "contract_term_history",
          "columns": [
            "contract_term_history_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (contract_term_history_id)",
          "table": "contract_term_history",
          "columns": [
            "contract_term_history_id"
          ]
        }
      ],
      "def": "CREATE TABLE `contract_term_history` (\n  `contract_term_history_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `contract_term_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned NOT NULL,\n  `contract_term_name` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `term_type` enum('artist','catalog','contribution','label','product','track','contributor_schedule','contribution_schedule') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'label',\n  `attachments` json DEFAULT NULL,\n  `attachments_relations` json DEFAULT NULL,\n  `is_base_term` tinyint(1) NOT NULL DEFAULT '1',\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `deleted_by` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  PRIMARY KEY (`contract_term_history_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "contract_term_schedule",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "contract_term_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_term_schedule_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "schedule_id",
          "type": "mediumint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (contract_term_schedule_id) USING BTREE",
          "table": "contract_term_schedule",
          "columns": [
            "contract_term_schedule_id"
          ]
        },
        {
          "name": "fk_contract_term_schedule_contract_term",
          "def": "KEY fk_contract_term_schedule_contract_term (contract_term_id) USING BTREE",
          "table": "contract_term_schedule",
          "columns": [
            "contract_term_id"
          ]
        },
        {
          "name": "fk_contract_term_schedule_schedule",
          "def": "KEY fk_contract_term_schedule_schedule (schedule_id) USING BTREE",
          "table": "contract_term_schedule",
          "columns": [
            "schedule_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (contract_term_schedule_id)",
          "table": "contract_term_schedule",
          "columns": [
            "contract_term_schedule_id"
          ]
        },
        {
          "name": "fk_contract_term_schedule_contract_term",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_term_id) REFERENCES contract_term (contract_term_id)",
          "table": "contract_term_schedule",
          "referenced_table": "contract_term",
          "columns": [
            "contract_term_id"
          ],
          "referenced_columns": [
            "contract_term_id"
          ]
        },
        {
          "name": "fk_contract_term_schedule_schedule",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (schedule_id) REFERENCES schedule (schedule_id)",
          "table": "contract_term_schedule",
          "referenced_table": "schedule",
          "columns": [
            "schedule_id"
          ],
          "referenced_columns": [
            "schedule_id"
          ]
        }
      ],
      "triggers": [
        {
          "name": "after_update_contract_term_schedule",
          "def": "CREATE TRIGGER after_update_contract_term_schedule AFTER UPDATE ON contract_term_schedule\nFOR EACH ROW\nBEGIN\n    INSERT INTO `contract_term_schedule_history` (\n        `contract_term_schedule_id`,\n        `contract_term_id`,\n        `schedule_id`,\n        `created_by`,\n        `created_at`,\n        `last_modified_by`,\n        `last_modified`,\n        `deleted_by`,\n        `deleted_at`\n    ) VALUES (\n        old.contract_term_schedule_id,\n        old.contract_term_id,\n        old.schedule_id,\n        old.created_by,\n        old.created_at,\n        old.last_modified_by,\n        old.last_modified,\n        old.deleted_by,\n        old.deleted_at\n    );\nEND"
        }
      ],
      "def": "CREATE TABLE `contract_term_schedule` (\n  `contract_term_schedule_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `contract_term_id` mediumint unsigned NOT NULL,\n  `schedule_id` mediumint unsigned NOT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `deleted_by` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  PRIMARY KEY (`contract_term_schedule_id`),\n  KEY `fk_contract_term_schedule_contract_term` (`contract_term_id`),\n  KEY `fk_contract_term_schedule_schedule` (`schedule_id`),\n  CONSTRAINT `fk_contract_term_schedule_contract_term` FOREIGN KEY (`contract_term_id`) REFERENCES `contract_term` (`contract_term_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_contract_term_schedule_schedule` FOREIGN KEY (`schedule_id`) REFERENCES `schedule` (`schedule_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "contract_term_schedule_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "contract_term_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_term_schedule_history_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "contract_term_schedule_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "schedule_id",
          "type": "mediumint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (contract_term_schedule_history_id) USING BTREE",
          "table": "contract_term_schedule_history",
          "columns": [
            "contract_term_schedule_history_id"
          ]
        },
        {
          "name": "fk_contract_term_schedule_history_contract_term",
          "def": "KEY fk_contract_term_schedule_history_contract_term (contract_term_id) USING BTREE",
          "table": "contract_term_schedule_history",
          "columns": [
            "contract_term_id"
          ]
        },
        {
          "name": "fk_contract_term_schedule_history_schedule",
          "def": "KEY fk_contract_term_schedule_history_schedule (schedule_id) USING BTREE",
          "table": "contract_term_schedule_history",
          "columns": [
            "schedule_id"
          ]
        },
        {
          "name": "fl_contract_term_schedule_history_term_schedule",
          "def": "KEY fl_contract_term_schedule_history_term_schedule (contract_term_schedule_id) USING BTREE",
          "table": "contract_term_schedule_history",
          "columns": [
            "contract_term_schedule_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (contract_term_schedule_history_id)",
          "table": "contract_term_schedule_history",
          "columns": [
            "contract_term_schedule_history_id"
          ]
        },
        {
          "name": "fk_contract_term_schedule_history_contract_term",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_term_id) REFERENCES contract_term (contract_term_id)",
          "table": "contract_term_schedule_history",
          "referenced_table": "contract_term",
          "columns": [
            "contract_term_id"
          ],
          "referenced_columns": [
            "contract_term_id"
          ]
        },
        {
          "name": "fk_contract_term_schedule_history_schedule",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (schedule_id) REFERENCES schedule (schedule_id)",
          "table": "contract_term_schedule_history",
          "referenced_table": "schedule",
          "columns": [
            "schedule_id"
          ],
          "referenced_columns": [
            "schedule_id"
          ]
        },
        {
          "name": "fl_contract_term_schedule_history_term_schedule",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_term_schedule_id) REFERENCES contract_term_schedule (contract_term_schedule_id)",
          "table": "contract_term_schedule_history",
          "referenced_table": "contract_term_schedule",
          "columns": [
            "contract_term_schedule_id"
          ],
          "referenced_columns": [
            "contract_term_schedule_id"
          ]
        }
      ],
      "def": "CREATE TABLE `contract_term_schedule_history` (\n  `contract_term_schedule_history_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `contract_term_schedule_id` mediumint unsigned NOT NULL,\n  `contract_term_id` mediumint unsigned NOT NULL,\n  `schedule_id` mediumint unsigned NOT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `deleted_by` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  PRIMARY KEY (`contract_term_schedule_history_id`),\n  KEY `fl_contract_term_schedule_history_term_schedule` (`contract_term_schedule_id`),\n  KEY `fk_contract_term_schedule_history_contract_term` (`contract_term_id`),\n  KEY `fk_contract_term_schedule_history_schedule` (`schedule_id`),\n  CONSTRAINT `fk_contract_term_schedule_history_contract_term` FOREIGN KEY (`contract_term_id`) REFERENCES `contract_term` (`contract_term_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,\n  CONSTRAINT `fk_contract_term_schedule_history_schedule` FOREIGN KEY (`schedule_id`) REFERENCES `schedule` (`schedule_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,\n  CONSTRAINT `fl_contract_term_schedule_history_term_schedule` FOREIGN KEY (`contract_term_schedule_id`) REFERENCES `contract_term_schedule` (`contract_term_schedule_id`) ON DELETE RESTRICT ON UPDATE RESTRICT\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "deleted_contract",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "contract_data",
          "type": "json",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "deleted_contract_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (deleted_contract_id) USING BTREE",
          "table": "deleted_contract",
          "columns": [
            "deleted_contract_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (deleted_contract_id)",
          "table": "deleted_contract",
          "columns": [
            "deleted_contract_id"
          ]
        }
      ],
      "def": "CREATE TABLE `deleted_contract` (\n  `deleted_contract_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `contract_id` mediumint unsigned NOT NULL,\n  `contract_data` json NOT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`deleted_contract_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci"
    },
    {
      "name": "exchange_rate",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "exchange_rate_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "from_currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "rate",
          "type": "decimal(30,19)",
          "nullable": false
        },
        {
          "name": "statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "to_currency_code",
          "type": "char(3)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (exchange_rate_id) USING BTREE",
          "table": "exchange_rate",
          "columns": [
            "exchange_rate_id"
          ]
        },
        {
          "name": "idx_from_code",
          "def": "KEY idx_from_code (from_currency_code) USING BTREE",
          "table": "exchange_rate",
          "columns": [
            "from_currency_code"
          ]
        },
        {
          "name": "idx_to_code",
          "def": "KEY idx_to_code (to_currency_code) USING BTREE",
          "table": "exchange_rate",
          "columns": [
            "to_currency_code"
          ]
        },
        {
          "name": "uidx_statement_period_currencies",
          "def": "UNIQUE KEY uidx_statement_period_currencies (statement_period_id, from_currency_code, to_currency_code) USING BTREE",
          "table": "exchange_rate",
          "columns": [
            "statement_period_id",
            "from_currency_code",
            "to_currency_code"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (exchange_rate_id)",
          "table": "exchange_rate",
          "columns": [
            "exchange_rate_id"
          ]
        },
        {
          "name": "fk_exchange_rate_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "exchange_rate",
          "referenced_table": "statement_period",
          "columns": [
            "statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "uidx_statement_period_currencies",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_statement_period_currencies (statement_period_id, from_currency_code, to_currency_code)",
          "table": "exchange_rate",
          "columns": [
            "statement_period_id",
            "from_currency_code",
            "to_currency_code"
          ]
        }
      ],
      "def": "CREATE TABLE `exchange_rate` (\n  `exchange_rate_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `statement_period_id` mediumint unsigned NOT NULL,\n  `rate` decimal(30,19) NOT NULL,\n  `from_currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `to_currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`exchange_rate_id`),\n  UNIQUE KEY `uidx_statement_period_currencies` (`statement_period_id`,`from_currency_code`,`to_currency_code`),\n  KEY `idx_from_code` (`from_currency_code`),\n  KEY `idx_to_code` (`to_currency_code`),\n  CONSTRAINT `fk_exchange_rate_statement_period` FOREIGN KEY (`statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "file_upload",
      "type": "BASE TABLE",
      "comment": "Tracks file uploads including S3 location, status, and metadata",
      "columns": [
        {
          "name": "completed_at",
          "type": "datetime",
          "nullable": true,
          "comment": "Timestamp when the upload completed successfully."
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false,
          "default": "CURRENT_TIMESTAMP",
          "extra_def": "DEFAULT_GENERATED"
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "error_message",
          "type": "text",
          "nullable": true,
          "comment": "Error message if upload failed."
        },
        {
          "name": "expires_at",
          "type": "datetime",
          "nullable": true,
          "comment": "Expiration timestamp for the upload/presigned URL."
        },
        {
          "name": "file_key",
          "type": "varchar(36)",
          "nullable": false,
          "comment": "Unique identifier for the file upload (UUID)."
        },
        {
          "name": "file_size_bytes",
          "type": "bigint unsigned",
          "nullable": false,
          "comment": "File size in bytes."
        },
        {
          "name": "file_type",
          "type": "varchar(10)",
          "nullable": true,
          "comment": "File extension without leading dot and lowercase (e.g., csv, pdf, xlsx)."
        },
        {
          "name": "file_upload_config_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "comment": "Foreign key to file_upload_config table."
        },
        {
          "name": "file_upload_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment",
          "comment": "Primary key."
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false,
          "default": "CURRENT_TIMESTAMP",
          "extra_def": "DEFAULT_GENERATED on update CURRENT_TIMESTAMP"
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "md5sum",
          "type": "varchar(32)",
          "nullable": true,
          "comment": "MD5 sum of file contents for integrity verification and duplicate detection."
        },
        {
          "name": "mime_type",
          "type": "varchar(255)",
          "nullable": true,
          "comment": "MIME type of the file (e.g., text/csv, application/pdf)."
        },
        {
          "name": "multipart_upload_id",
          "type": "varchar(255)",
          "nullable": true,
          "comment": "S3 multipart upload ID for large file uploads."
        },
        {
          "name": "original_file_name",
          "type": "varchar(255)",
          "nullable": false,
          "comment": "Original filename from upload."
        },
        {
          "name": "s3_bucket",
          "type": "varchar(63)",
          "nullable": false,
          "comment": "S3 bucket name where the file is stored (e.g., prod-abacus-flowthrough)."
        },
        {
          "name": "s3_key",
          "type": "varchar(1024)",
          "nullable": false,
          "comment": "S3 object key/path for the uploaded file (e.g., uploads/2025/11/00000000-0000-0000-0000-000000000000.csv)."
        },
        {
          "name": "total_parts",
          "type": "smallint",
          "nullable": false,
          "default": "1",
          "comment": "Total number of parts for multipart uploads."
        },
        {
          "name": "upload_metadata",
          "type": "json",
          "nullable": true,
          "comment": "Additional metadata about the upload (flexible JSON structure)."
        },
        {
          "name": "upload_status",
          "type": "enum('init','complete','error','cancelled')",
          "nullable": false,
          "default": "init",
          "comment": "Current status of the upload. init: initiated, complete: successfully uploaded, error: failed, cancelled: cancelled by user."
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (file_upload_id) USING BTREE",
          "table": "file_upload",
          "columns": [
            "file_upload_id"
          ]
        },
        {
          "name": "fk_file_upload_config",
          "def": "KEY fk_file_upload_config (file_upload_config_id) USING BTREE",
          "table": "file_upload",
          "columns": [
            "file_upload_config_id"
          ]
        },
        {
          "name": "idx_md5sum",
          "def": "KEY idx_md5sum (md5sum) USING BTREE",
          "table": "file_upload",
          "columns": [
            "md5sum"
          ]
        },
        {
          "name": "uidx_file_key",
          "def": "UNIQUE KEY uidx_file_key (file_key) USING BTREE",
          "table": "file_upload",
          "columns": [
            "file_key"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (file_upload_id)",
          "table": "file_upload",
          "columns": [
            "file_upload_id"
          ]
        },
        {
          "name": "fk_file_upload_config",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (file_upload_config_id) REFERENCES file_upload_config (file_upload_config_id)",
          "table": "file_upload",
          "referenced_table": "file_upload_config",
          "columns": [
            "file_upload_config_id"
          ],
          "referenced_columns": [
            "file_upload_config_id"
          ]
        },
        {
          "name": "uidx_file_key",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_file_key (file_key)",
          "table": "file_upload",
          "columns": [
            "file_key"
          ]
        }
      ],
      "def": "CREATE TABLE `file_upload` (\n  `file_upload_id` mediumint unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key.',\n  `file_upload_config_id` mediumint unsigned NOT NULL COMMENT 'Foreign key to file_upload_config table.',\n  `file_key` varchar(36) NOT NULL COMMENT 'Unique identifier for the file upload (UUID).',\n  `original_file_name` varchar(255) NOT NULL COMMENT 'Original filename from upload.',\n  `file_size_bytes` bigint unsigned NOT NULL COMMENT 'File size in bytes.',\n  `file_type` varchar(10) DEFAULT NULL COMMENT 'File extension without leading dot and lowercase (e.g., csv, pdf, xlsx).',\n  `mime_type` varchar(255) DEFAULT NULL COMMENT 'MIME type of the file (e.g., text/csv, application/pdf).',\n  `s3_bucket` varchar(63) NOT NULL COMMENT 'S3 bucket name where the file is stored (e.g., prod-abacus-flowthrough).',\n  `s3_key` varchar(1024) NOT NULL COMMENT 'S3 object key/path for the uploaded file (e.g., uploads/2025/11/00000000-0000-0000-0000-000000000000.csv).',\n  `md5sum` varchar(32) DEFAULT NULL COMMENT 'MD5 sum of file contents for integrity verification and duplicate detection.',\n  `upload_status` enum('init','complete','error','cancelled') NOT NULL DEFAULT 'init' COMMENT 'Current status of the upload. init: initiated, complete: successfully uploaded, error: failed, cancelled: cancelled by user.',\n  `multipart_upload_id` varchar(255) DEFAULT NULL COMMENT 'S3 multipart upload ID for large file uploads.',\n  `total_parts` smallint NOT NULL DEFAULT '1' COMMENT 'Total number of parts for multipart uploads.',\n  `upload_metadata` json DEFAULT NULL COMMENT 'Additional metadata about the upload (flexible JSON structure).',\n  `error_message` text COMMENT 'Error message if upload failed.',\n  `completed_at` datetime DEFAULT NULL COMMENT 'Timestamp when the upload completed successfully.',\n  `expires_at` datetime DEFAULT NULL COMMENT 'Expiration timestamp for the upload/presigned URL.',\n  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,\n  `created_by` varchar(180) NOT NULL,\n  `last_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n  `last_modified_by` varchar(180) NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(180) DEFAULT NULL,\n  PRIMARY KEY (`file_upload_id`),\n  UNIQUE KEY `uidx_file_key` (`file_key`) COMMENT 'Ensures file_key is unique across all uploads.',\n  KEY `fk_file_upload_config` (`file_upload_config_id`),\n  KEY `idx_md5sum` (`md5sum`) COMMENT 'For duplicate file detection.',\n  CONSTRAINT `fk_file_upload_config` FOREIGN KEY (`file_upload_config_id`) REFERENCES `file_upload_config` (`file_upload_config_id`) ON DELETE RESTRICT\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='Tracks file uploads including S3 location, status, and metadata'"
    },
    {
      "name": "file_upload_config",
      "type": "BASE TABLE",
      "comment": "Configurations for different file upload types and their routing rules",
      "columns": [
        {
          "name": "allowed_file_types",
          "type": "json",
          "nullable": true,
          "comment": "Array of allowed file extensions, without leading dot and lowercase (e.g., [\"csv\", \"pdf\", \"xlsx\"]). NULL = allow all extensions."
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false,
          "default": "CURRENT_TIMESTAMP",
          "extra_def": "DEFAULT_GENERATED"
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "description",
          "type": "varchar(255)",
          "nullable": true,
          "comment": "Description of what this upload config is for."
        },
        {
          "name": "file_upload_config_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment",
          "comment": "Primary key."
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false,
          "default": "CURRENT_TIMESTAMP",
          "extra_def": "DEFAULT_GENERATED on update CURRENT_TIMESTAMP"
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "max_file_size_bytes",
          "type": "bigint unsigned",
          "nullable": false,
          "default": "10485760",
          "comment": "Maximum file size in bytes. Defaults to 10MB, S3 maximum is 5TB."
        },
        {
          "name": "min_multipart_chunk_size_bytes",
          "type": "bigint unsigned",
          "nullable": true,
          "default": "10485760",
          "comment": "Minimum chunk size for multipart uploads. Defaults to 10MB, S3 range is [5MB, 5GB]. Calculated chunk size should be \u003e= this value and stay within the S3 part limit (10,000)."
        },
        {
          "name": "multipart_threshold_bytes",
          "type": "bigint unsigned",
          "nullable": true,
          "default": "104857600",
          "comment": "File size threshold for multipart upload. Defaults to 100MB, S3 maximum is 5GB."
        },
        {
          "name": "s3_key_template",
          "type": "varchar(255)",
          "nullable": false,
          "default": "{file_key}.{ext}",
          "comment": "S3 path/key template"
        },
        {
          "name": "upload_type",
          "type": "enum('adjustments','flowthrough')",
          "nullable": false,
          "comment": "Type identifier for the upload. Defines which upload configuration to use."
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (file_upload_config_id) USING BTREE",
          "table": "file_upload_config",
          "columns": [
            "file_upload_config_id"
          ]
        },
        {
          "name": "uidx_upload_type_active",
          "def": "UNIQUE KEY uidx_upload_type_active (upload_type) USING BTREE",
          "table": "file_upload_config",
          "columns": [
            "upload_type"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (file_upload_config_id)",
          "table": "file_upload_config",
          "columns": [
            "file_upload_config_id"
          ]
        },
        {
          "name": "uidx_upload_type_active",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_upload_type_active (upload_type)",
          "table": "file_upload_config",
          "columns": [
            "upload_type"
          ]
        }
      ],
      "def": "CREATE TABLE `file_upload_config` (\n  `file_upload_config_id` mediumint unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key.',\n  `upload_type` enum('adjustments','flowthrough') NOT NULL COMMENT 'Type identifier for the upload. Defines which upload configuration to use.',\n  `s3_key_template` varchar(255) NOT NULL DEFAULT '{file_key}.{ext}' COMMENT 'S3 path/key template',\n  `allowed_file_types` json DEFAULT NULL COMMENT 'Array of allowed file extensions, without leading dot and lowercase (e.g., [\"csv\", \"pdf\", \"xlsx\"]). NULL = allow all extensions.',\n  `max_file_size_bytes` bigint unsigned NOT NULL DEFAULT '10485760' COMMENT 'Maximum file size in bytes. Defaults to 10MB, S3 maximum is 5TB.',\n  `multipart_threshold_bytes` bigint unsigned DEFAULT '104857600' COMMENT 'File size threshold for multipart upload. Defaults to 100MB, S3 maximum is 5GB.',\n  `min_multipart_chunk_size_bytes` bigint unsigned DEFAULT '10485760' COMMENT 'Minimum chunk size for multipart uploads. Defaults to 10MB, S3 range is [5MB, 5GB]. Calculated chunk size should be \u003e= this value and stay within the S3 part limit (10,000).',\n  `description` varchar(255) DEFAULT NULL COMMENT 'Description of what this upload config is for.',\n  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,\n  `created_by` varchar(180) NOT NULL,\n  `last_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n  `last_modified_by` varchar(180) NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(180) DEFAULT NULL,\n  PRIMARY KEY (`file_upload_config_id`),\n  UNIQUE KEY `uidx_upload_type_active` (`upload_type`,((case when (`deleted_at` is null) then 0 end))) COMMENT 'Ensures only one active (non-deleted) record per upload_type. Allows multiple soft-deleted records.'\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='Configurations for different file upload types and their routing rules'"
    },
    {
      "name": "historical_contract_advance",
      "type": "BASE TABLE",
      "comment": "Holds historical advanced payment information.",
      "columns": [
        {
          "name": "account_id",
          "type": "int",
          "nullable": false,
          "comment": "Abacus and Orchard Admin account id this advance is associated with."
        },
        {
          "name": "amount",
          "type": "double",
          "nullable": false,
          "comment": "Amount of advance."
        },
        {
          "name": "apply_to_period_id",
          "type": "smallint unsigned",
          "nullable": true,
          "comment": "The period the advance is applied to."
        },
        {
          "name": "currency",
          "type": "varchar(3)",
          "nullable": false,
          "comment": "Currency code for the advance amount."
        },
        {
          "name": "currency_id",
          "type": "smallint unsigned",
          "nullable": false,
          "comment": "Foreign key to currencies table."
        },
        {
          "name": "date_paid",
          "type": "date",
          "nullable": true,
          "comment": "Date the advance is paid."
        },
        {
          "name": "description",
          "type": "text",
          "nullable": true,
          "comment": "Description of the advance payment."
        },
        {
          "name": "due_type",
          "type": "varchar(100)",
          "nullable": false,
          "comment": "Indicates how the advance is due."
        },
        {
          "name": "exchange_rate",
          "type": "float",
          "nullable": true,
          "comment": "Exchange Rate in decimal between 0 and 1"
        },
        {
          "name": "id",
          "type": "int",
          "nullable": false,
          "extra_def": "auto_increment",
          "comment": "Primary key."
        },
        {
          "name": "oa_advance_id",
          "type": "int",
          "nullable": false,
          "comment": "Historical Orchard Admin advance payment ID."
        },
        {
          "name": "oa_contract_id",
          "type": "int",
          "nullable": false,
          "comment": "Orchard Admin contract id this advance is associated with."
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (id) USING BTREE",
          "table": "historical_contract_advance",
          "columns": [
            "id"
          ]
        },
        {
          "name": "account_id",
          "def": "KEY account_id (account_id) USING BTREE",
          "table": "historical_contract_advance",
          "columns": [
            "account_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (id)",
          "table": "historical_contract_advance",
          "columns": [
            "id"
          ]
        }
      ],
      "def": "CREATE TABLE `historical_contract_advance` (\n  `id` int NOT NULL AUTO_INCREMENT COMMENT 'Primary key.',\n  `oa_advance_id` int NOT NULL COMMENT 'Historical Orchard Admin advance payment ID.',\n  `oa_contract_id` int NOT NULL COMMENT 'Orchard Admin contract id this advance is associated with.',\n  `account_id` int NOT NULL COMMENT 'Abacus and Orchard Admin account id this advance is associated with.',\n  `amount` double NOT NULL COMMENT 'Amount of advance.',\n  `currency_id` smallint unsigned NOT NULL COMMENT 'Foreign key to currencies table.',\n  `currency` varchar(3) NOT NULL COMMENT 'Currency code for the advance amount.',\n  `due_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'Indicates how the advance is due.',\n  `date_paid` date DEFAULT NULL COMMENT 'Date the advance is paid.',\n  `exchange_rate` float DEFAULT NULL COMMENT 'Exchange Rate in decimal between 0 and 1',\n  `description` text COMMENT 'Description of the advance payment.',\n  `apply_to_period_id` smallint unsigned DEFAULT NULL COMMENT 'The period the advance is applied to.',\n  PRIMARY KEY (`id`),\n  KEY `account_id` (`account_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3 COMMENT='Holds historical advanced payment information.'"
    },
    {
      "name": "json_contract_file_import_status",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_id",
          "type": "int",
          "nullable": true
        },
        {
          "name": "aws_username",
          "type": "varchar(256)",
          "nullable": true
        },
        {
          "name": "contract_id",
          "type": "int",
          "nullable": true
        },
        {
          "name": "contract_name",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "errors",
          "type": "text",
          "nullable": true
        },
        {
          "name": "failed_entities",
          "type": "varchar(512)",
          "nullable": true
        },
        {
          "name": "import_status",
          "type": "enum('success','partial_success','fail')",
          "nullable": false
        },
        {
          "name": "import_user",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "imported_entities",
          "type": "varchar(1024)",
          "nullable": true
        },
        {
          "name": "ingestion_date",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "ingestion_duration",
          "type": "decimal(5,2)",
          "nullable": false
        },
        {
          "name": "jira_ticket",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "json_contract_file_import_status_id",
          "type": "int unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "json_file_s3_path",
          "type": "varchar(1024)",
          "nullable": false
        },
        {
          "name": "json_file_s3_version_id",
          "type": "varchar(1024)",
          "nullable": false
        },
        {
          "name": "overwrite",
          "type": "tinyint(1)",
          "nullable": false
        },
        {
          "name": "process_report_file_s3_path",
          "type": "varchar(1024)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (json_contract_file_import_status_id) USING BTREE",
          "table": "json_contract_file_import_status",
          "columns": [
            "json_contract_file_import_status_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (json_contract_file_import_status_id)",
          "table": "json_contract_file_import_status",
          "columns": [
            "json_contract_file_import_status_id"
          ]
        }
      ],
      "def": "CREATE TABLE `json_contract_file_import_status` (\n  `json_contract_file_import_status_id` int unsigned NOT NULL AUTO_INCREMENT,\n  `ingestion_date` datetime NOT NULL,\n  `contract_id` int DEFAULT NULL,\n  `contract_name` varchar(180) DEFAULT NULL,\n  `json_file_s3_path` varchar(1024) NOT NULL,\n  `json_file_s3_version_id` varchar(1024) NOT NULL,\n  `process_report_file_s3_path` varchar(1024) NOT NULL,\n  `import_status` enum('success','partial_success','fail') NOT NULL,\n  `failed_entities` varchar(512) DEFAULT NULL,\n  `errors` text,\n  `overwrite` tinyint(1) NOT NULL,\n  `ingestion_duration` decimal(5,2) NOT NULL,\n  `aws_username` varchar(256) DEFAULT NULL,\n  `import_user` varchar(180) DEFAULT NULL,\n  `jira_ticket` varchar(180) DEFAULT NULL,\n  `account_id` int DEFAULT NULL,\n  `imported_entities` varchar(1024) DEFAULT NULL,\n  PRIMARY KEY (`json_contract_file_import_status_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "ledger_account",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "abacus_event_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "currency_amount",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "current_balance",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "ledger_account_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "note",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "previous_balance",
          "type": "decimal(20,2)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (ledger_account_id) USING BTREE",
          "table": "ledger_account",
          "columns": [
            "ledger_account_id"
          ]
        },
        {
          "name": "fk_ledger_account_abacus_event",
          "def": "KEY fk_ledger_account_abacus_event (abacus_event_id) USING BTREE",
          "table": "ledger_account",
          "columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_ledger_account_account",
          "def": "KEY fk_ledger_account_account (account_id) USING BTREE",
          "table": "ledger_account",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_ledger_account_contract",
          "def": "KEY fk_ledger_account_contract (contract_id) USING BTREE",
          "table": "ledger_account",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "uidx_account_contract_event",
          "def": "UNIQUE KEY uidx_account_contract_event (abacus_event_id, account_id, contract_id) USING BTREE",
          "table": "ledger_account",
          "columns": [
            "abacus_event_id",
            "account_id",
            "contract_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (ledger_account_id)",
          "table": "ledger_account",
          "columns": [
            "ledger_account_id"
          ]
        },
        {
          "name": "fk_ledger_account_abacus_event",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)",
          "table": "ledger_account",
          "referenced_table": "abacus_event",
          "columns": [
            "abacus_event_id"
          ],
          "referenced_columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_ledger_account_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "ledger_account",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_ledger_account_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "ledger_account",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "uidx_account_contract_event",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_account_contract_event (abacus_event_id, account_id, contract_id)",
          "table": "ledger_account",
          "columns": [
            "abacus_event_id",
            "account_id",
            "contract_id"
          ]
        }
      ],
      "triggers": [
        {
          "name": "after_ledger_account_insert",
          "def": "CREATE TRIGGER after_ledger_account_insert AFTER INSERT ON ledger_account\nFOR EACH ROW\nBEGIN\n    INSERT INTO `ledger_account_current_balance`\n        (ledger_account_id, account_id, created_by, created_at, last_modified_by, last_modified)\n    VALUES\n        (NEW.ledger_account_id, NEW.account_id, NEW.created_by, NOW(), NEW.last_modified_by, NOW())\n    ON DUPLICATE KEY UPDATE\n        ledger_account_id = NEW.ledger_account_id,\n        last_modified_by = NEW.last_modified_by,\n        last_modified = NOW();\nEND"
        }
      ],
      "def": "CREATE TABLE `ledger_account` (\n  `ledger_account_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `abacus_event_id` mediumint unsigned NOT NULL,\n  `account_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned DEFAULT NULL,\n  `currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `currency_amount` decimal(20,2) NOT NULL,\n  `previous_balance` decimal(20,2) NOT NULL,\n  `current_balance` decimal(20,2) NOT NULL,\n  `note` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`ledger_account_id`),\n  UNIQUE KEY `uidx_account_contract_event` (`abacus_event_id`,`account_id`,`contract_id`),\n  KEY `fk_ledger_account_account` (`account_id`),\n  KEY `fk_ledger_account_contract` (`contract_id`),\n  KEY `fk_ledger_account_abacus_event` (`abacus_event_id`),\n  CONSTRAINT `fk_ledger_account_abacus_event` FOREIGN KEY (`abacus_event_id`) REFERENCES `abacus_event` (`abacus_event_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,\n  CONSTRAINT `fk_ledger_account_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_account_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "ledger_account_contract",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "abacus_event_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "currency_amount",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "current_balance",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "ledger_account_contract_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "note",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "previous_balance",
          "type": "decimal(20,2)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (ledger_account_contract_id) USING BTREE",
          "table": "ledger_account_contract",
          "columns": [
            "ledger_account_contract_id"
          ]
        },
        {
          "name": "fk_ledger_account_contract_abacus_event",
          "def": "KEY fk_ledger_account_contract_abacus_event (abacus_event_id) USING BTREE",
          "table": "ledger_account_contract",
          "columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_ledger_account_contract_account",
          "def": "KEY fk_ledger_account_contract_account (account_id) USING BTREE",
          "table": "ledger_account_contract",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_ledger_account_contract_contract",
          "def": "KEY fk_ledger_account_contract_contract (contract_id) USING BTREE",
          "table": "ledger_account_contract",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "uidx_ledger_account_contract_event",
          "def": "UNIQUE KEY uidx_ledger_account_contract_event (abacus_event_id, account_id, contract_id) USING BTREE",
          "table": "ledger_account_contract",
          "columns": [
            "abacus_event_id",
            "account_id",
            "contract_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (ledger_account_contract_id)",
          "table": "ledger_account_contract",
          "columns": [
            "ledger_account_contract_id"
          ]
        },
        {
          "name": "fk_ledger_account_contract_abacus_event",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)",
          "table": "ledger_account_contract",
          "referenced_table": "abacus_event",
          "columns": [
            "abacus_event_id"
          ],
          "referenced_columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_ledger_account_contract_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "ledger_account_contract",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_ledger_account_contract_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "ledger_account_contract",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "uidx_ledger_account_contract_event",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_ledger_account_contract_event (abacus_event_id, account_id, contract_id)",
          "table": "ledger_account_contract",
          "columns": [
            "abacus_event_id",
            "account_id",
            "contract_id"
          ]
        }
      ],
      "triggers": [
        {
          "name": "after_ledger_account_contract_insert",
          "def": "CREATE TRIGGER after_ledger_account_contract_insert AFTER INSERT ON ledger_account_contract\nFOR EACH ROW\nBEGIN\n    INSERT INTO `ledger_account_contract_current_balance`\n        (ledger_account_contract_id, account_id, contract_id, created_by, created_at, last_modified_by, last_modified)\n    VALUES\n        (NEW.ledger_account_contract_id, NEW.account_id, NEW.contract_id, NEW.created_by, NOW(), NEW.last_modified_by, NOW())\n    ON DUPLICATE KEY UPDATE\n        ledger_account_contract_id = NEW.ledger_account_contract_id,\n        last_modified_by = NEW.last_modified_by,\n        last_modified = NOW();\nEND"
        }
      ],
      "def": "CREATE TABLE `ledger_account_contract` (\n  `ledger_account_contract_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `abacus_event_id` mediumint unsigned NOT NULL,\n  `account_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned NOT NULL,\n  `currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `currency_amount` decimal(20,2) NOT NULL,\n  `previous_balance` decimal(20,2) NOT NULL,\n  `current_balance` decimal(20,2) NOT NULL,\n  `note` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`ledger_account_contract_id`),\n  UNIQUE KEY `uidx_ledger_account_contract_event` (`abacus_event_id`,`account_id`,`contract_id`),\n  KEY `fk_ledger_account_contract_account` (`account_id`),\n  KEY `fk_ledger_account_contract_contract` (`contract_id`),\n  KEY `fk_ledger_account_contract_abacus_event` (`abacus_event_id`),\n  CONSTRAINT `fk_ledger_account_contract_abacus_event` FOREIGN KEY (`abacus_event_id`) REFERENCES `abacus_event` (`abacus_event_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,\n  CONSTRAINT `fk_ledger_account_contract_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,\n  CONSTRAINT `fk_ledger_account_contract_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE RESTRICT ON UPDATE RESTRICT\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "ledger_account_contract_current_balance",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "ledger_account_contract_current_balance_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "ledger_account_contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (ledger_account_contract_current_balance_id) USING BTREE",
          "table": "ledger_account_contract_current_balance",
          "columns": [
            "ledger_account_contract_current_balance_id"
          ]
        },
        {
          "name": "fk_ledger_account_contract_current_balance_account",
          "def": "KEY fk_ledger_account_contract_current_balance_account (account_id) USING BTREE",
          "table": "ledger_account_contract_current_balance",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_ledger_account_contract_current_balance_contract",
          "def": "KEY fk_ledger_account_contract_current_balance_contract (contract_id) USING BTREE",
          "table": "ledger_account_contract_current_balance",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_ledger_account_contract_current_balance_ledger_",
          "def": "KEY fk_ledger_account_contract_current_balance_ledger_ (ledger_account_contract_id) USING BTREE",
          "table": "ledger_account_contract_current_balance",
          "columns": [
            "ledger_account_contract_id"
          ]
        },
        {
          "name": "uidx_contract_id",
          "def": "UNIQUE KEY uidx_contract_id (contract_id) USING BTREE",
          "table": "ledger_account_contract_current_balance",
          "columns": [
            "contract_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (ledger_account_contract_current_balance_id)",
          "table": "ledger_account_contract_current_balance",
          "columns": [
            "ledger_account_contract_current_balance_id"
          ]
        },
        {
          "name": "fk_ledger_account_contract_current_balance_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "ledger_account_contract_current_balance",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_ledger_account_contract_current_balance_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "ledger_account_contract_current_balance",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_ledger_account_contract_current_balance_ledger_",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (ledger_account_contract_id) REFERENCES ledger_account_contract (ledger_account_contract_id)",
          "table": "ledger_account_contract_current_balance",
          "referenced_table": "ledger_account_contract",
          "columns": [
            "ledger_account_contract_id"
          ],
          "referenced_columns": [
            "ledger_account_contract_id"
          ]
        },
        {
          "name": "uidx_contract_id",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_contract_id (contract_id)",
          "table": "ledger_account_contract_current_balance",
          "columns": [
            "contract_id"
          ]
        }
      ],
      "def": "CREATE TABLE `ledger_account_contract_current_balance` (\n  `ledger_account_contract_current_balance_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `ledger_account_contract_id` mediumint unsigned NOT NULL,\n  `account_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned NOT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`ledger_account_contract_current_balance_id`),\n  UNIQUE KEY `uidx_contract_id` (`contract_id`),\n  KEY `fk_ledger_account_contract_current_balance_ledger_` (`ledger_account_contract_id`),\n  KEY `fk_ledger_account_contract_current_balance_account` (`account_id`),\n  KEY `fk_ledger_account_contract_current_balance_contract` (`contract_id`),\n  CONSTRAINT `fk_ledger_account_contract_current_balance_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,\n  CONSTRAINT `fk_ledger_account_contract_current_balance_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,\n  CONSTRAINT `fk_ledger_account_contract_current_balance_ledger_` FOREIGN KEY (`ledger_account_contract_id`) REFERENCES `ledger_account_contract` (`ledger_account_contract_id`) ON DELETE RESTRICT ON UPDATE RESTRICT\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "ledger_account_current_balance",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "ledger_account_current_balance_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "ledger_account_id",
          "type": "mediumint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (ledger_account_current_balance_id) USING BTREE",
          "table": "ledger_account_current_balance",
          "columns": [
            "ledger_account_current_balance_id"
          ]
        },
        {
          "name": "fk_ledger_account_current_balance_account",
          "def": "KEY fk_ledger_account_current_balance_account (account_id) USING BTREE",
          "table": "ledger_account_current_balance",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_ledger_account_current_balance_ledger_account_",
          "def": "KEY fk_ledger_account_current_balance_ledger_account_ (ledger_account_id) USING BTREE",
          "table": "ledger_account_current_balance",
          "columns": [
            "ledger_account_id"
          ]
        },
        {
          "name": "uidx_account_id",
          "def": "UNIQUE KEY uidx_account_id (account_id) USING BTREE",
          "table": "ledger_account_current_balance",
          "columns": [
            "account_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (ledger_account_current_balance_id)",
          "table": "ledger_account_current_balance",
          "columns": [
            "ledger_account_current_balance_id"
          ]
        },
        {
          "name": "fk_ledger_account_current_balance_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "ledger_account_current_balance",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_ledger_account_current_balance_ledger_account_",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (ledger_account_id) REFERENCES ledger_account (ledger_account_id)",
          "table": "ledger_account_current_balance",
          "referenced_table": "ledger_account",
          "columns": [
            "ledger_account_id"
          ],
          "referenced_columns": [
            "ledger_account_id"
          ]
        },
        {
          "name": "uidx_account_id",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_account_id (account_id)",
          "table": "ledger_account_current_balance",
          "columns": [
            "account_id"
          ]
        }
      ],
      "def": "CREATE TABLE `ledger_account_current_balance` (\n  `ledger_account_current_balance_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `ledger_account_id` mediumint unsigned NOT NULL,\n  `account_id` mediumint unsigned NOT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`ledger_account_current_balance_id`),\n  UNIQUE KEY `uidx_account_id` (`account_id`),\n  KEY `fk_ledger_account_current_balance_ledger_account_` (`ledger_account_id`),\n  KEY `fk_ledger_account_current_balance_account` (`account_id`),\n  CONSTRAINT `fk_ledger_account_current_balance_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_account_current_balance_ledger_account_` FOREIGN KEY (`ledger_account_id`) REFERENCES `ledger_account` (`ledger_account_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "ledger_accounting_run_balance",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "abacus_event_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "accounting_run_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "adjusted_net_revenue",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "distribution_fee",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "ledger_accounting_run_balance_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "mechanical_deduction_admin_fee_total",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "mechanical_deduction_total",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "total_gross_revenue_amount",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "total_net_revenue_amount",
          "type": "decimal(20,2)",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (ledger_accounting_run_balance_id) USING BTREE",
          "table": "ledger_accounting_run_balance",
          "columns": [
            "ledger_accounting_run_balance_id"
          ]
        },
        {
          "name": "fk_abacus_event_ledger",
          "def": "KEY fk_abacus_event_ledger (abacus_event_id) USING BTREE",
          "table": "ledger_accounting_run_balance",
          "columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_accounting_run_ledger",
          "def": "KEY fk_accounting_run_ledger (accounting_run_id) USING BTREE",
          "table": "ledger_accounting_run_balance",
          "columns": [
            "accounting_run_id"
          ]
        },
        {
          "name": "fk_contract_ledger",
          "def": "KEY fk_contract_ledger (contract_id) USING BTREE",
          "table": "ledger_accounting_run_balance",
          "columns": [
            "contract_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (ledger_accounting_run_balance_id)",
          "table": "ledger_accounting_run_balance",
          "columns": [
            "ledger_accounting_run_balance_id"
          ]
        },
        {
          "name": "fk_abacus_event_ledger",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)",
          "table": "ledger_accounting_run_balance",
          "referenced_table": "abacus_event",
          "columns": [
            "abacus_event_id"
          ],
          "referenced_columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_accounting_run_ledger",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (accounting_run_id) REFERENCES accounting_run (accounting_run_id)",
          "table": "ledger_accounting_run_balance",
          "referenced_table": "accounting_run",
          "columns": [
            "accounting_run_id"
          ],
          "referenced_columns": [
            "accounting_run_id"
          ]
        },
        {
          "name": "fk_contract_ledger",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "ledger_accounting_run_balance",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        }
      ],
      "def": "CREATE TABLE `ledger_accounting_run_balance` (\n  `ledger_accounting_run_balance_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `accounting_run_id` mediumint unsigned NOT NULL,\n  `abacus_event_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned NOT NULL,\n  `currency_code` char(3) NOT NULL,\n  `total_gross_revenue_amount` decimal(20,2) DEFAULT NULL,\n  `total_net_revenue_amount` decimal(20,2) DEFAULT NULL,\n  `mechanical_deduction_total` decimal(20,2) DEFAULT NULL,\n  `mechanical_deduction_admin_fee_total` decimal(20,2) DEFAULT NULL,\n  `adjusted_net_revenue` decimal(20,2) NOT NULL,\n  `distribution_fee` decimal(20,2) DEFAULT NULL,\n  `created_at` datetime NOT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  PRIMARY KEY (`ledger_accounting_run_balance_id`),\n  KEY `fk_accounting_run_ledger` (`accounting_run_id`),\n  KEY `fk_abacus_event_ledger` (`abacus_event_id`),\n  KEY `fk_contract_ledger` (`contract_id`),\n  CONSTRAINT `fk_abacus_event_ledger` FOREIGN KEY (`abacus_event_id`) REFERENCES `abacus_event` (`abacus_event_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_accounting_run_ledger` FOREIGN KEY (`accounting_run_id`) REFERENCES `accounting_run` (`accounting_run_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_contract_ledger` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "ledger_accounting_run_vat",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "abacus_event_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "accounting_run_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "adjusted_net_revenue",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "country_of_tax_residence",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "distribution_fee",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "distribution_vat",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "distribution_vat_rate",
          "type": "decimal(5,2)",
          "nullable": true
        },
        {
          "name": "exempt_reason",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "gross_revenue",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "gross_vat",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "gross_vat_rate",
          "type": "decimal(5,2)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "ledger_accounting_run_vat_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "net_revenue",
          "type": "decimal(20,2)",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (ledger_accounting_run_vat_id) USING BTREE",
          "table": "ledger_accounting_run_vat",
          "columns": [
            "ledger_accounting_run_vat_id"
          ]
        },
        {
          "name": "fk_ledger_accounting_run_vat_acc_run",
          "def": "KEY fk_ledger_accounting_run_vat_acc_run (accounting_run_id) USING BTREE",
          "table": "ledger_accounting_run_vat",
          "columns": [
            "accounting_run_id"
          ]
        },
        {
          "name": "fk_ledger_accounting_run_vat_contract",
          "def": "KEY fk_ledger_accounting_run_vat_contract (contract_id) USING BTREE",
          "table": "ledger_accounting_run_vat",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_ledger_accounting_run_vat_event",
          "def": "KEY fk_ledger_accounting_run_vat_event (abacus_event_id) USING BTREE",
          "table": "ledger_accounting_run_vat",
          "columns": [
            "abacus_event_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (ledger_accounting_run_vat_id)",
          "table": "ledger_accounting_run_vat",
          "columns": [
            "ledger_accounting_run_vat_id"
          ]
        },
        {
          "name": "fk_ledger_accounting_run_vat_acc_run",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (accounting_run_id) REFERENCES accounting_run (accounting_run_id)",
          "table": "ledger_accounting_run_vat",
          "referenced_table": "accounting_run",
          "columns": [
            "accounting_run_id"
          ],
          "referenced_columns": [
            "accounting_run_id"
          ]
        },
        {
          "name": "fk_ledger_accounting_run_vat_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "ledger_accounting_run_vat",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_ledger_accounting_run_vat_event",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)",
          "table": "ledger_accounting_run_vat",
          "referenced_table": "abacus_event",
          "columns": [
            "abacus_event_id"
          ],
          "referenced_columns": [
            "abacus_event_id"
          ]
        }
      ],
      "def": "CREATE TABLE `ledger_accounting_run_vat` (\n  `ledger_accounting_run_vat_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `accounting_run_id` mediumint unsigned NOT NULL,\n  `abacus_event_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned NOT NULL,\n  `currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `country_of_tax_residence` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `gross_revenue` decimal(20,2) DEFAULT NULL,\n  `net_revenue` decimal(20,2) DEFAULT NULL,\n  `distribution_fee` decimal(20,2) DEFAULT NULL,\n  `gross_vat_rate` decimal(5,2) DEFAULT NULL,\n  `distribution_vat_rate` decimal(5,2) DEFAULT NULL,\n  `gross_vat` decimal(20,2) DEFAULT NULL,\n  `distribution_vat` decimal(20,2) DEFAULT NULL,\n  `adjusted_net_revenue` decimal(20,2) DEFAULT NULL,\n  `exempt_reason` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`ledger_accounting_run_vat_id`),\n  KEY `fk_ledger_accounting_run_vat_acc_run` (`accounting_run_id`),\n  KEY `fk_ledger_accounting_run_vat_event` (`abacus_event_id`),\n  KEY `fk_ledger_accounting_run_vat_contract` (`contract_id`),\n  CONSTRAINT `fk_ledger_accounting_run_vat_acc_run` FOREIGN KEY (`accounting_run_id`) REFERENCES `accounting_run` (`accounting_run_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_accounting_run_vat_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_accounting_run_vat_event` FOREIGN KEY (`abacus_event_id`) REFERENCES `abacus_event` (`abacus_event_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "ledger_adjustment",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "abacus_event_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "activity_statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "adjustment_amount",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "adjustment_currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "apply_to_statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "ledger_adjustment_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "note",
          "type": "mediumtext",
          "nullable": true
        },
        {
          "name": "reference_adjustment_type_id",
          "type": "tinyint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (ledger_adjustment_id) USING BTREE",
          "table": "ledger_adjustment",
          "columns": [
            "ledger_adjustment_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_abacus_event",
          "def": "KEY fk_ledger_adjustment_abacus_event (abacus_event_id) USING BTREE",
          "table": "ledger_adjustment",
          "columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_account",
          "def": "KEY fk_ledger_adjustment_account (account_id) USING BTREE",
          "table": "ledger_adjustment",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_activity_statement_period",
          "def": "KEY fk_ledger_adjustment_activity_statement_period (activity_statement_period_id) USING BTREE",
          "table": "ledger_adjustment",
          "columns": [
            "activity_statement_period_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_applied_to_statement_period",
          "def": "KEY fk_ledger_adjustment_applied_to_statement_period (apply_to_statement_period_id) USING BTREE",
          "table": "ledger_adjustment",
          "columns": [
            "apply_to_statement_period_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_contract",
          "def": "KEY fk_ledger_adjustment_contract (contract_id) USING BTREE",
          "table": "ledger_adjustment",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_reference_adjustment_type",
          "def": "KEY fk_ledger_adjustment_reference_adjustment_type (reference_adjustment_type_id) USING BTREE",
          "table": "ledger_adjustment",
          "columns": [
            "reference_adjustment_type_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (ledger_adjustment_id)",
          "table": "ledger_adjustment",
          "columns": [
            "ledger_adjustment_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_abacus_event",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)",
          "table": "ledger_adjustment",
          "referenced_table": "abacus_event",
          "columns": [
            "abacus_event_id"
          ],
          "referenced_columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "ledger_adjustment",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_activity_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (activity_statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "ledger_adjustment",
          "referenced_table": "statement_period",
          "columns": [
            "activity_statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_applied_to_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (apply_to_statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "ledger_adjustment",
          "referenced_table": "statement_period",
          "columns": [
            "apply_to_statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "ledger_adjustment",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_reference_adjustment_type",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (reference_adjustment_type_id) REFERENCES reference_adjustment_type (reference_adjustment_type_id)",
          "table": "ledger_adjustment",
          "referenced_table": "reference_adjustment_type",
          "columns": [
            "reference_adjustment_type_id"
          ],
          "referenced_columns": [
            "reference_adjustment_type_id"
          ]
        }
      ],
      "def": "CREATE TABLE `ledger_adjustment` (\n  `ledger_adjustment_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `abacus_event_id` mediumint unsigned NOT NULL,\n  `account_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned DEFAULT NULL,\n  `activity_statement_period_id` mediumint unsigned NOT NULL,\n  `apply_to_statement_period_id` mediumint unsigned NOT NULL,\n  `reference_adjustment_type_id` tinyint unsigned NOT NULL,\n  `adjustment_amount` decimal(20,2) NOT NULL,\n  `adjustment_currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `note` mediumtext COLLATE utf8mb4_general_ci,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`ledger_adjustment_id`),\n  KEY `fk_ledger_adjustment_abacus_event` (`abacus_event_id`),\n  KEY `fk_ledger_adjustment_account` (`account_id`),\n  KEY `fk_ledger_adjustment_contract` (`contract_id`),\n  KEY `fk_ledger_adjustment_activity_statement_period` (`activity_statement_period_id`),\n  KEY `fk_ledger_adjustment_applied_to_statement_period` (`apply_to_statement_period_id`),\n  KEY `fk_ledger_adjustment_reference_adjustment_type` (`reference_adjustment_type_id`),\n  CONSTRAINT `fk_ledger_adjustment_abacus_event` FOREIGN KEY (`abacus_event_id`) REFERENCES `abacus_event` (`abacus_event_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_adjustment_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_adjustment_activity_statement_period` FOREIGN KEY (`activity_statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_adjustment_applied_to_statement_period` FOREIGN KEY (`apply_to_statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_adjustment_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_adjustment_reference_adjustment_type` FOREIGN KEY (`reference_adjustment_type_id`) REFERENCES `reference_adjustment_type` (`reference_adjustment_type_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "ledger_adjustment_adjustment_detail",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "detail_count",
          "type": "smallint unsigned",
          "nullable": false
        },
        {
          "name": "ledger_adjustment_adjustment_detail_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "ledger_adjustment_detail_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "ledger_adjustment_id",
          "type": "mediumint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (ledger_adjustment_adjustment_detail_id) USING BTREE",
          "table": "ledger_adjustment_adjustment_detail",
          "columns": [
            "ledger_adjustment_adjustment_detail_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_adjustment_ledger_adjustment",
          "def": "KEY fk_ledger_adjustment_adjustment_ledger_adjustment (ledger_adjustment_id) USING BTREE",
          "table": "ledger_adjustment_adjustment_detail",
          "columns": [
            "ledger_adjustment_id"
          ]
        },
        {
          "name": "uidx_ledger_adjustment_detail_id",
          "def": "UNIQUE KEY uidx_ledger_adjustment_detail_id (ledger_adjustment_detail_id) USING BTREE",
          "table": "ledger_adjustment_adjustment_detail",
          "columns": [
            "ledger_adjustment_detail_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (ledger_adjustment_adjustment_detail_id)",
          "table": "ledger_adjustment_adjustment_detail",
          "columns": [
            "ledger_adjustment_adjustment_detail_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_adjustment_ledger_adjustment",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (ledger_adjustment_id) REFERENCES ledger_adjustment (ledger_adjustment_id)",
          "table": "ledger_adjustment_adjustment_detail",
          "referenced_table": "ledger_adjustment",
          "columns": [
            "ledger_adjustment_id"
          ],
          "referenced_columns": [
            "ledger_adjustment_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_adjustment_ledger_adjustment_detail",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (ledger_adjustment_detail_id) REFERENCES ledger_adjustment_detail (ledger_adjustment_detail_id)",
          "table": "ledger_adjustment_adjustment_detail",
          "referenced_table": "ledger_adjustment_detail",
          "columns": [
            "ledger_adjustment_detail_id"
          ],
          "referenced_columns": [
            "ledger_adjustment_detail_id"
          ]
        },
        {
          "name": "uidx_ledger_adjustment_detail_id",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_ledger_adjustment_detail_id (ledger_adjustment_detail_id)",
          "table": "ledger_adjustment_adjustment_detail",
          "columns": [
            "ledger_adjustment_detail_id"
          ]
        }
      ],
      "def": "CREATE TABLE `ledger_adjustment_adjustment_detail` (\n  `ledger_adjustment_adjustment_detail_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `ledger_adjustment_id` mediumint unsigned NOT NULL,\n  `ledger_adjustment_detail_id` mediumint unsigned NOT NULL,\n  `detail_count` smallint unsigned NOT NULL,\n  PRIMARY KEY (`ledger_adjustment_adjustment_detail_id`),\n  UNIQUE KEY `uidx_ledger_adjustment_detail_id` (`ledger_adjustment_detail_id`),\n  KEY `fk_ledger_adjustment_adjustment_ledger_adjustment` (`ledger_adjustment_id`),\n  CONSTRAINT `fk_ledger_adjustment_adjustment_ledger_adjustment` FOREIGN KEY (`ledger_adjustment_id`) REFERENCES `ledger_adjustment` (`ledger_adjustment_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_adjustment_adjustment_ledger_adjustment_detail` FOREIGN KEY (`ledger_adjustment_detail_id`) REFERENCES `ledger_adjustment_detail` (`ledger_adjustment_detail_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "ledger_adjustment_adjustment_detail_applied",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "ledger_adjustment_adjustment_detail_applied_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "ledger_adjustment_applied_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "ledger_adjustment_detail_applied_id",
          "type": "mediumint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (ledger_adjustment_adjustment_detail_applied_id) USING BTREE",
          "table": "ledger_adjustment_adjustment_detail_applied",
          "columns": [
            "ledger_adjustment_adjustment_detail_applied_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_applied",
          "def": "KEY fk_ledger_adjustment_applied (ledger_adjustment_applied_id) USING BTREE",
          "table": "ledger_adjustment_adjustment_detail_applied",
          "columns": [
            "ledger_adjustment_applied_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_detail_applied",
          "def": "KEY fk_ledger_adjustment_detail_applied (ledger_adjustment_detail_applied_id) USING BTREE",
          "table": "ledger_adjustment_adjustment_detail_applied",
          "columns": [
            "ledger_adjustment_detail_applied_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (ledger_adjustment_adjustment_detail_applied_id)",
          "table": "ledger_adjustment_adjustment_detail_applied",
          "columns": [
            "ledger_adjustment_adjustment_detail_applied_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_applied",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (ledger_adjustment_applied_id) REFERENCES ledger_adjustment_applied (ledger_adjustment_applied_id)",
          "table": "ledger_adjustment_adjustment_detail_applied",
          "referenced_table": "ledger_adjustment_applied",
          "columns": [
            "ledger_adjustment_applied_id"
          ],
          "referenced_columns": [
            "ledger_adjustment_applied_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_detail_applied",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (ledger_adjustment_detail_applied_id) REFERENCES ledger_adjustment_detail_applied (ledger_adjustment_detail_applied_id)",
          "table": "ledger_adjustment_adjustment_detail_applied",
          "referenced_table": "ledger_adjustment_detail_applied",
          "columns": [
            "ledger_adjustment_detail_applied_id"
          ],
          "referenced_columns": [
            "ledger_adjustment_detail_applied_id"
          ]
        }
      ],
      "def": "CREATE TABLE `ledger_adjustment_adjustment_detail_applied` (\n  `ledger_adjustment_adjustment_detail_applied_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `ledger_adjustment_applied_id` mediumint unsigned NOT NULL,\n  `ledger_adjustment_detail_applied_id` mediumint unsigned NOT NULL,\n  PRIMARY KEY (`ledger_adjustment_adjustment_detail_applied_id`),\n  KEY `fk_ledger_adjustment_applied` (`ledger_adjustment_applied_id`),\n  KEY `fk_ledger_adjustment_detail_applied` (`ledger_adjustment_detail_applied_id`),\n  CONSTRAINT `fk_ledger_adjustment_applied` FOREIGN KEY (`ledger_adjustment_applied_id`) REFERENCES `ledger_adjustment_applied` (`ledger_adjustment_applied_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_adjustment_detail_applied` FOREIGN KEY (`ledger_adjustment_detail_applied_id`) REFERENCES `ledger_adjustment_detail_applied` (`ledger_adjustment_detail_applied_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "ledger_adjustment_applied",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "abacus_event_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "adjustment_amount",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "adjustment_amount_payee_currency",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "adjustment_currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "adjustment_payee_currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "ledger_adjustment_applied_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "ledger_adjustment_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "worksheet_adjustment_id",
          "type": "mediumint unsigned",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (ledger_adjustment_applied_id) USING BTREE",
          "table": "ledger_adjustment_applied",
          "columns": [
            "ledger_adjustment_applied_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_applied_abacus_event",
          "def": "KEY fk_ledger_adjustment_applied_abacus_event (abacus_event_id) USING BTREE",
          "table": "ledger_adjustment_applied",
          "columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_applied_account",
          "def": "KEY fk_ledger_adjustment_applied_account (account_id) USING BTREE",
          "table": "ledger_adjustment_applied",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_applied_contract",
          "def": "KEY fk_ledger_adjustment_applied_contract (contract_id) USING BTREE",
          "table": "ledger_adjustment_applied",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_applied_ledger_adjustment",
          "def": "KEY fk_ledger_adjustment_applied_ledger_adjustment (ledger_adjustment_id) USING BTREE",
          "table": "ledger_adjustment_applied",
          "columns": [
            "ledger_adjustment_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_applied_statement_period",
          "def": "KEY fk_ledger_adjustment_applied_statement_period (statement_period_id) USING BTREE",
          "table": "ledger_adjustment_applied",
          "columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "idx_worksheet_adjustment_id",
          "def": "UNIQUE KEY idx_worksheet_adjustment_id (worksheet_adjustment_id) USING BTREE",
          "table": "ledger_adjustment_applied",
          "columns": [
            "worksheet_adjustment_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (ledger_adjustment_applied_id)",
          "table": "ledger_adjustment_applied",
          "columns": [
            "ledger_adjustment_applied_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_applied_abacus_event",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)",
          "table": "ledger_adjustment_applied",
          "referenced_table": "abacus_event",
          "columns": [
            "abacus_event_id"
          ],
          "referenced_columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_applied_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "ledger_adjustment_applied",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_applied_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "ledger_adjustment_applied",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_applied_ledger_adjustment",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (ledger_adjustment_id) REFERENCES ledger_adjustment (ledger_adjustment_id)",
          "table": "ledger_adjustment_applied",
          "referenced_table": "ledger_adjustment",
          "columns": [
            "ledger_adjustment_id"
          ],
          "referenced_columns": [
            "ledger_adjustment_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_applied_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "ledger_adjustment_applied",
          "referenced_table": "statement_period",
          "columns": [
            "statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_applied_worksheet_adjustment",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (worksheet_adjustment_id) REFERENCES worksheet_adjustment (worksheet_adjustment_id)",
          "table": "ledger_adjustment_applied",
          "referenced_table": "worksheet_adjustment",
          "columns": [
            "worksheet_adjustment_id"
          ],
          "referenced_columns": [
            "worksheet_adjustment_id"
          ]
        },
        {
          "name": "idx_worksheet_adjustment_id",
          "type": "UNIQUE",
          "def": "UNIQUE KEY idx_worksheet_adjustment_id (worksheet_adjustment_id)",
          "table": "ledger_adjustment_applied",
          "columns": [
            "worksheet_adjustment_id"
          ]
        }
      ],
      "def": "CREATE TABLE `ledger_adjustment_applied` (\n  `ledger_adjustment_applied_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `abacus_event_id` mediumint unsigned NOT NULL,\n  `account_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned DEFAULT NULL,\n  `statement_period_id` mediumint unsigned NOT NULL,\n  `ledger_adjustment_id` mediumint unsigned DEFAULT NULL,\n  `worksheet_adjustment_id` mediumint unsigned DEFAULT NULL,\n  `adjustment_amount` decimal(20,2) NOT NULL,\n  `adjustment_currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `adjustment_amount_payee_currency` decimal(20,2) NOT NULL,\n  `adjustment_payee_currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`ledger_adjustment_applied_id`),\n  UNIQUE KEY `idx_worksheet_adjustment_id` (`worksheet_adjustment_id`),\n  KEY `fk_ledger_adjustment_applied_abacus_event` (`abacus_event_id`),\n  KEY `fk_ledger_adjustment_applied_account` (`account_id`),\n  KEY `fk_ledger_adjustment_applied_contract` (`contract_id`),\n  KEY `fk_ledger_adjustment_applied_statement_period` (`statement_period_id`),\n  KEY `fk_ledger_adjustment_applied_ledger_adjustment` (`ledger_adjustment_id`),\n  CONSTRAINT `fk_ledger_adjustment_applied_abacus_event` FOREIGN KEY (`abacus_event_id`) REFERENCES `abacus_event` (`abacus_event_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_adjustment_applied_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_adjustment_applied_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_adjustment_applied_ledger_adjustment` FOREIGN KEY (`ledger_adjustment_id`) REFERENCES `ledger_adjustment` (`ledger_adjustment_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_adjustment_applied_statement_period` FOREIGN KEY (`statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_adjustment_applied_worksheet_adjustment` FOREIGN KEY (`worksheet_adjustment_id`) REFERENCES `worksheet_adjustment` (`worksheet_adjustment_id`) ON DELETE RESTRICT ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "ledger_adjustment_detail",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "activity_statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "amount",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "apply_to_statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "distribution_type",
          "type": "enum('digital','physical')",
          "nullable": false,
          "default": "digital"
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "ledger_adjustment_detail_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "note",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "reference_adjustment_type_id",
          "type": "tinyint unsigned",
          "nullable": false
        },
        {
          "name": "upc",
          "type": "varchar(20)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (ledger_adjustment_detail_id) USING BTREE",
          "table": "ledger_adjustment_detail",
          "columns": [
            "ledger_adjustment_detail_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_detail_account",
          "def": "KEY fk_ledger_adjustment_detail_account (account_id) USING BTREE",
          "table": "ledger_adjustment_detail",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_detail_activity_statement_period",
          "def": "KEY fk_ledger_adjustment_detail_activity_statement_period (activity_statement_period_id) USING BTREE",
          "table": "ledger_adjustment_detail",
          "columns": [
            "activity_statement_period_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_detail_apply_to_statement_period",
          "def": "KEY fk_ledger_adjustment_detail_apply_to_statement_period (apply_to_statement_period_id) USING BTREE",
          "table": "ledger_adjustment_detail",
          "columns": [
            "apply_to_statement_period_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_detail_contract",
          "def": "KEY fk_ledger_adjustment_detail_contract (contract_id) USING BTREE",
          "table": "ledger_adjustment_detail",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_type",
          "def": "KEY fk_ledger_adjustment_type (reference_adjustment_type_id) USING BTREE",
          "table": "ledger_adjustment_detail",
          "columns": [
            "reference_adjustment_type_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (ledger_adjustment_detail_id)",
          "table": "ledger_adjustment_detail",
          "columns": [
            "ledger_adjustment_detail_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_detail_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "ledger_adjustment_detail",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_detail_activity_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (activity_statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "ledger_adjustment_detail",
          "referenced_table": "statement_period",
          "columns": [
            "activity_statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_detail_apply_to_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (apply_to_statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "ledger_adjustment_detail",
          "referenced_table": "statement_period",
          "columns": [
            "apply_to_statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_detail_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "ledger_adjustment_detail",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_type",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (reference_adjustment_type_id) REFERENCES reference_adjustment_type (reference_adjustment_type_id)",
          "table": "ledger_adjustment_detail",
          "referenced_table": "reference_adjustment_type",
          "columns": [
            "reference_adjustment_type_id"
          ],
          "referenced_columns": [
            "reference_adjustment_type_id"
          ]
        }
      ],
      "def": "CREATE TABLE `ledger_adjustment_detail` (\n  `ledger_adjustment_detail_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `account_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned DEFAULT NULL,\n  `activity_statement_period_id` mediumint unsigned NOT NULL,\n  `apply_to_statement_period_id` mediumint unsigned NOT NULL,\n  `reference_adjustment_type_id` tinyint unsigned NOT NULL,\n  `currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `amount` decimal(20,2) NOT NULL,\n  `upc` varchar(20) COLLATE utf8mb4_general_ci NOT NULL,\n  `distribution_type` enum('digital','physical') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'digital',\n  `note` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`ledger_adjustment_detail_id`),\n  KEY `fk_ledger_adjustment_detail_account` (`account_id`),\n  KEY `fk_ledger_adjustment_detail_contract` (`contract_id`),\n  KEY `fk_ledger_adjustment_detail_activity_statement_period` (`activity_statement_period_id`),\n  KEY `fk_ledger_adjustment_detail_apply_to_statement_period` (`apply_to_statement_period_id`),\n  KEY `fk_ledger_adjustment_type` (`reference_adjustment_type_id`),\n  CONSTRAINT `fk_ledger_adjustment_detail_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_adjustment_detail_activity_statement_period` FOREIGN KEY (`activity_statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_adjustment_detail_apply_to_statement_period` FOREIGN KEY (`apply_to_statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_adjustment_detail_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_adjustment_type` FOREIGN KEY (`reference_adjustment_type_id`) REFERENCES `reference_adjustment_type` (`reference_adjustment_type_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "ledger_adjustment_detail_applied",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "adjustment_amount",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "adjustment_amount_payee_currency",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "adjustment_currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "adjustment_payee_currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "ledger_adjustment_detail_applied_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "ledger_adjustment_detail_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "worksheet_adjustment_detail_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "worksheet_adjustment_id",
          "type": "mediumint unsigned",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (ledger_adjustment_detail_applied_id) USING BTREE",
          "table": "ledger_adjustment_detail_applied",
          "columns": [
            "ledger_adjustment_detail_applied_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_detail_applied_ledger_adjustment_detail_id",
          "def": "KEY fk_ledger_adjustment_detail_applied_ledger_adjustment_detail_id (ledger_adjustment_detail_id) USING BTREE",
          "table": "ledger_adjustment_detail_applied",
          "columns": [
            "ledger_adjustment_detail_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_detail_worksheet_adjustment",
          "def": "KEY fk_ledger_adjustment_detail_worksheet_adjustment (worksheet_adjustment_id) USING BTREE",
          "table": "ledger_adjustment_detail_applied",
          "columns": [
            "worksheet_adjustment_id"
          ]
        },
        {
          "name": "idx_worksheet_adjustment_detail_id",
          "def": "UNIQUE KEY idx_worksheet_adjustment_detail_id (worksheet_adjustment_detail_id) USING BTREE",
          "table": "ledger_adjustment_detail_applied",
          "columns": [
            "worksheet_adjustment_detail_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (ledger_adjustment_detail_applied_id)",
          "table": "ledger_adjustment_detail_applied",
          "columns": [
            "ledger_adjustment_detail_applied_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_detail_applied_adjustment_detail",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (worksheet_adjustment_detail_id) REFERENCES worksheet_adjustment_detail (worksheet_adjustment_detail_id)",
          "table": "ledger_adjustment_detail_applied",
          "referenced_table": "worksheet_adjustment_detail",
          "columns": [
            "worksheet_adjustment_detail_id"
          ],
          "referenced_columns": [
            "worksheet_adjustment_detail_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_detail_applied_ledger_adjustment_detail_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (ledger_adjustment_detail_id) REFERENCES ledger_adjustment_detail (ledger_adjustment_detail_id)",
          "table": "ledger_adjustment_detail_applied",
          "referenced_table": "ledger_adjustment_detail",
          "columns": [
            "ledger_adjustment_detail_id"
          ],
          "referenced_columns": [
            "ledger_adjustment_detail_id"
          ]
        },
        {
          "name": "fk_ledger_adjustment_detail_worksheet_adjustment",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (worksheet_adjustment_id) REFERENCES worksheet_adjustment (worksheet_adjustment_id)",
          "table": "ledger_adjustment_detail_applied",
          "referenced_table": "worksheet_adjustment",
          "columns": [
            "worksheet_adjustment_id"
          ],
          "referenced_columns": [
            "worksheet_adjustment_id"
          ]
        },
        {
          "name": "idx_worksheet_adjustment_detail_id",
          "type": "UNIQUE",
          "def": "UNIQUE KEY idx_worksheet_adjustment_detail_id (worksheet_adjustment_detail_id)",
          "table": "ledger_adjustment_detail_applied",
          "columns": [
            "worksheet_adjustment_detail_id"
          ]
        }
      ],
      "def": "CREATE TABLE `ledger_adjustment_detail_applied` (\n  `ledger_adjustment_detail_applied_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `ledger_adjustment_detail_id` mediumint unsigned DEFAULT NULL,\n  `worksheet_adjustment_id` mediumint unsigned DEFAULT NULL,\n  `worksheet_adjustment_detail_id` mediumint unsigned DEFAULT NULL,\n  `adjustment_amount` decimal(20,2) NOT NULL,\n  `adjustment_currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `adjustment_amount_payee_currency` decimal(20,2) NOT NULL,\n  `adjustment_payee_currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`ledger_adjustment_detail_applied_id`),\n  UNIQUE KEY `idx_worksheet_adjustment_detail_id` (`worksheet_adjustment_detail_id`),\n  KEY `fk_ledger_adjustment_detail_applied_ledger_adjustment_detail_id` (`ledger_adjustment_detail_id`),\n  KEY `fk_ledger_adjustment_detail_worksheet_adjustment` (`worksheet_adjustment_id`),\n  CONSTRAINT `fk_ledger_adjustment_detail_applied_adjustment_detail` FOREIGN KEY (`worksheet_adjustment_detail_id`) REFERENCES `worksheet_adjustment_detail` (`worksheet_adjustment_detail_id`) ON DELETE RESTRICT ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_adjustment_detail_applied_ledger_adjustment_detail_id` FOREIGN KEY (`ledger_adjustment_detail_id`) REFERENCES `ledger_adjustment_detail` (`ledger_adjustment_detail_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_adjustment_detail_worksheet_adjustment` FOREIGN KEY (`worksheet_adjustment_id`) REFERENCES `worksheet_adjustment` (`worksheet_adjustment_id`) ON DELETE RESTRICT ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "ledger_contract_advance_applied",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "abacus_event_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "advance_amount",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "advance_amount_payee_currency",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "advance_currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "advance_payee_currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "amount_after_withholding_and_vat",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "amount_after_withholding_and_vat_payee_currency",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "contract_advance_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "exchange_rate",
          "type": "decimal(30,19)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "ledger_contract_advance_applied_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "us_source_income_rate",
          "type": "decimal(9,6) unsigned",
          "nullable": true
        },
        {
          "name": "vat_amount",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "vat_amount_payee_currency",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "withholding_tax_amount",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "withholding_tax_amount_payee_currency",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "worksheet_payment_contract_advance_id",
          "type": "mediumint unsigned",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (ledger_contract_advance_applied_id) USING BTREE",
          "table": "ledger_contract_advance_applied",
          "columns": [
            "ledger_contract_advance_applied_id"
          ]
        },
        {
          "name": "fk_abacus_event_contract_advance_applied",
          "def": "KEY fk_abacus_event_contract_advance_applied (abacus_event_id) USING BTREE",
          "table": "ledger_contract_advance_applied",
          "columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_account_contract_advance_applied",
          "def": "KEY fk_account_contract_advance_applied (account_id) USING BTREE",
          "table": "ledger_contract_advance_applied",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_contract_contract_advance_applied",
          "def": "KEY fk_contract_contract_advance_applied (contract_id) USING BTREE",
          "table": "ledger_contract_advance_applied",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_statement_period_contract_advance_applied",
          "def": "KEY fk_statement_period_contract_advance_applied (statement_period_id) USING BTREE",
          "table": "ledger_contract_advance_applied",
          "columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "unique_contract_worksheet_event",
          "def": "UNIQUE KEY unique_contract_worksheet_event (contract_advance_id, worksheet_payment_contract_advance_id, abacus_event_id) USING BTREE",
          "table": "ledger_contract_advance_applied",
          "columns": [
            "contract_advance_id",
            "worksheet_payment_contract_advance_id",
            "abacus_event_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (ledger_contract_advance_applied_id)",
          "table": "ledger_contract_advance_applied",
          "columns": [
            "ledger_contract_advance_applied_id"
          ]
        },
        {
          "name": "fk_abacus_event_contract_advance_applied",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)",
          "table": "ledger_contract_advance_applied",
          "referenced_table": "abacus_event",
          "columns": [
            "abacus_event_id"
          ],
          "referenced_columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_account_contract_advance_applied",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "ledger_contract_advance_applied",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_contract_advance_contract_advance_applied",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_advance_id) REFERENCES contract_advance (contract_advance_id)",
          "table": "ledger_contract_advance_applied",
          "referenced_table": "contract_advance",
          "columns": [
            "contract_advance_id"
          ],
          "referenced_columns": [
            "contract_advance_id"
          ]
        },
        {
          "name": "fk_contract_contract_advance_applied",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "ledger_contract_advance_applied",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_statement_period_contract_advance_applied",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "ledger_contract_advance_applied",
          "referenced_table": "statement_period",
          "columns": [
            "statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "unique_contract_worksheet_event",
          "type": "UNIQUE",
          "def": "UNIQUE KEY unique_contract_worksheet_event (contract_advance_id, worksheet_payment_contract_advance_id, abacus_event_id)",
          "table": "ledger_contract_advance_applied",
          "columns": [
            "contract_advance_id",
            "worksheet_payment_contract_advance_id",
            "abacus_event_id"
          ]
        }
      ],
      "def": "CREATE TABLE `ledger_contract_advance_applied` (\n  `ledger_contract_advance_applied_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `abacus_event_id` mediumint unsigned NOT NULL,\n  `account_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned NOT NULL,\n  `contract_advance_id` mediumint unsigned NOT NULL,\n  `statement_period_id` mediumint unsigned NOT NULL,\n  `worksheet_payment_contract_advance_id` mediumint unsigned DEFAULT NULL,\n  `advance_amount` decimal(20,2) NOT NULL,\n  `advance_currency_code` char(3) NOT NULL,\n  `advance_amount_payee_currency` decimal(20,2) NOT NULL,\n  `advance_payee_currency_code` char(3) NOT NULL,\n  `vat_amount` decimal(20,2) DEFAULT NULL,\n  `withholding_tax_amount` decimal(20,2) DEFAULT NULL,\n  `amount_after_withholding_and_vat` decimal(20,2) DEFAULT NULL,\n  `vat_amount_payee_currency` decimal(20,2) DEFAULT NULL,\n  `withholding_tax_amount_payee_currency` decimal(20,2) DEFAULT NULL,\n  `amount_after_withholding_and_vat_payee_currency` decimal(20,2) DEFAULT NULL,\n  `us_source_income_rate` decimal(9,6) unsigned DEFAULT NULL,\n  `exchange_rate` decimal(30,19) DEFAULT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`ledger_contract_advance_applied_id`),\n  UNIQUE KEY `unique_contract_worksheet_event` (`contract_advance_id`,`worksheet_payment_contract_advance_id`,`abacus_event_id`),\n  KEY `fk_abacus_event_contract_advance_applied` (`abacus_event_id`),\n  KEY `fk_account_contract_advance_applied` (`account_id`),\n  KEY `fk_contract_contract_advance_applied` (`contract_id`),\n  KEY `fk_statement_period_contract_advance_applied` (`statement_period_id`),\n  CONSTRAINT `fk_abacus_event_contract_advance_applied` FOREIGN KEY (`abacus_event_id`) REFERENCES `abacus_event` (`abacus_event_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_account_contract_advance_applied` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_contract_advance_contract_advance_applied` FOREIGN KEY (`contract_advance_id`) REFERENCES `contract_advance` (`contract_advance_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_contract_contract_advance_applied` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_statement_period_contract_advance_applied` FOREIGN KEY (`statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "ledger_correction",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "abacus_event_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "correction_statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "correction_type",
          "type": "enum('royalty_reversal','royalty_correction')",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "distribution_fee",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "gross_revenue",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "ledger_correction_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "mechanical_deduction_admin_fee_total",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "mechanical_deduction_total",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "net_revenue",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "note",
          "type": "mediumtext",
          "nullable": true
        },
        {
          "name": "statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "worksheet_correction_id",
          "type": "mediumint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (ledger_correction_id) USING BTREE",
          "table": "ledger_correction",
          "columns": [
            "ledger_correction_id"
          ]
        },
        {
          "name": "fk_ledger_correction_abacus_event",
          "def": "KEY fk_ledger_correction_abacus_event (abacus_event_id) USING BTREE",
          "table": "ledger_correction",
          "columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_ledger_correction_account",
          "def": "KEY fk_ledger_correction_account (account_id) USING BTREE",
          "table": "ledger_correction",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_ledger_correction_contract",
          "def": "KEY fk_ledger_correction_contract (contract_id) USING BTREE",
          "table": "ledger_correction",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_ledger_correction_correction_statement_period",
          "def": "KEY fk_ledger_correction_correction_statement_period (correction_statement_period_id) USING BTREE",
          "table": "ledger_correction",
          "columns": [
            "correction_statement_period_id"
          ]
        },
        {
          "name": "fk_ledger_correction_statement_period",
          "def": "KEY fk_ledger_correction_statement_period (statement_period_id) USING BTREE",
          "table": "ledger_correction",
          "columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_ledger_correction_worksheet_correction",
          "def": "KEY fk_ledger_correction_worksheet_correction (worksheet_correction_id) USING BTREE",
          "table": "ledger_correction",
          "columns": [
            "worksheet_correction_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (ledger_correction_id)",
          "table": "ledger_correction",
          "columns": [
            "ledger_correction_id"
          ]
        },
        {
          "name": "fk_ledger_correction_abacus_event",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)",
          "table": "ledger_correction",
          "referenced_table": "abacus_event",
          "columns": [
            "abacus_event_id"
          ],
          "referenced_columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_ledger_correction_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "ledger_correction",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_ledger_correction_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "ledger_correction",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_ledger_correction_correction_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (correction_statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "ledger_correction",
          "referenced_table": "statement_period",
          "columns": [
            "correction_statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_ledger_correction_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "ledger_correction",
          "referenced_table": "statement_period",
          "columns": [
            "statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_ledger_correction_worksheet_correction",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (worksheet_correction_id) REFERENCES worksheet_correction (worksheet_correction_id)",
          "table": "ledger_correction",
          "referenced_table": "worksheet_correction",
          "columns": [
            "worksheet_correction_id"
          ],
          "referenced_columns": [
            "worksheet_correction_id"
          ]
        }
      ],
      "def": "CREATE TABLE `ledger_correction` (\n  `ledger_correction_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `abacus_event_id` mediumint unsigned NOT NULL,\n  `worksheet_correction_id` mediumint unsigned NOT NULL,\n  `account_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned DEFAULT NULL,\n  `statement_period_id` mediumint unsigned NOT NULL,\n  `correction_statement_period_id` mediumint unsigned NOT NULL,\n  `correction_type` enum('royalty_reversal','royalty_correction') COLLATE utf8mb4_general_ci NOT NULL,\n  `currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `gross_revenue` decimal(20,2) NOT NULL,\n  `distribution_fee` decimal(20,2) NOT NULL,\n  `mechanical_deduction_total` decimal(20,2) DEFAULT NULL,\n  `mechanical_deduction_admin_fee_total` decimal(20,2) DEFAULT NULL,\n  `net_revenue` decimal(20,2) NOT NULL,\n  `note` mediumtext COLLATE utf8mb4_general_ci,\n  `created_at` datetime NOT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  PRIMARY KEY (`ledger_correction_id`),\n  KEY `fk_ledger_correction_abacus_event` (`abacus_event_id`),\n  KEY `fk_ledger_correction_worksheet_correction` (`worksheet_correction_id`),\n  KEY `fk_ledger_correction_account` (`account_id`),\n  KEY `fk_ledger_correction_contract` (`contract_id`),\n  KEY `fk_ledger_correction_statement_period` (`statement_period_id`),\n  KEY `fk_ledger_correction_correction_statement_period` (`correction_statement_period_id`),\n  CONSTRAINT `fk_ledger_correction_abacus_event` FOREIGN KEY (`abacus_event_id`) REFERENCES `abacus_event` (`abacus_event_id`) ON DELETE RESTRICT ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_correction_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE RESTRICT ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_correction_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE RESTRICT ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_correction_correction_statement_period` FOREIGN KEY (`correction_statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE RESTRICT ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_correction_statement_period` FOREIGN KEY (`statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE RESTRICT ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_correction_worksheet_correction` FOREIGN KEY (`worksheet_correction_id`) REFERENCES `worksheet_correction` (`worksheet_correction_id`) ON DELETE RESTRICT ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "ledger_deposit",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "abacus_event_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "ledger_deposit_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "remaining_amount",
          "type": "decimal(38,18)",
          "nullable": false
        },
        {
          "name": "rounded_amount",
          "type": "decimal(20,2)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (ledger_deposit_id) USING BTREE",
          "table": "ledger_deposit",
          "columns": [
            "ledger_deposit_id"
          ]
        },
        {
          "name": "fk_abacus_event_ledger_deposit",
          "def": "KEY fk_abacus_event_ledger_deposit (abacus_event_id) USING BTREE",
          "table": "ledger_deposit",
          "columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_contract_ledger_deposit",
          "def": "KEY fk_contract_ledger_deposit (contract_id) USING BTREE",
          "table": "ledger_deposit",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_ledger_deposit_account",
          "def": "KEY fk_ledger_deposit_account (account_id) USING BTREE",
          "table": "ledger_deposit",
          "columns": [
            "account_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (ledger_deposit_id)",
          "table": "ledger_deposit",
          "columns": [
            "ledger_deposit_id"
          ]
        },
        {
          "name": "fk_abacus_event_ledger_deposit",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)",
          "table": "ledger_deposit",
          "referenced_table": "abacus_event",
          "columns": [
            "abacus_event_id"
          ],
          "referenced_columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_contract_ledger_deposit",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "ledger_deposit",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_ledger_deposit_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "ledger_deposit",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        }
      ],
      "def": "CREATE TABLE `ledger_deposit` (\n  `ledger_deposit_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `account_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned DEFAULT NULL,\n  `abacus_event_id` mediumint unsigned NOT NULL,\n  `currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `rounded_amount` decimal(20,2) NOT NULL,\n  `remaining_amount` decimal(38,18) NOT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`ledger_deposit_id`),\n  KEY `fk_contract_ledger_deposit` (`contract_id`),\n  KEY `fk_abacus_event_ledger_deposit` (`abacus_event_id`),\n  KEY `fk_ledger_deposit_account` (`account_id`),\n  CONSTRAINT `fk_abacus_event_ledger_deposit` FOREIGN KEY (`abacus_event_id`) REFERENCES `abacus_event` (`abacus_event_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,\n  CONSTRAINT `fk_contract_ledger_deposit` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_deposit_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "ledger_reserve_release",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "abacus_event_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "installment_amount",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "ledger_reserve_release_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "ledger_reserve_release_schedule_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (ledger_reserve_release_id) USING BTREE",
          "table": "ledger_reserve_release",
          "columns": [
            "ledger_reserve_release_id"
          ]
        },
        {
          "name": "fk_ledger_reserve_release_abacus_event_id",
          "def": "KEY fk_ledger_reserve_release_abacus_event_id (abacus_event_id) USING BTREE",
          "table": "ledger_reserve_release",
          "columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_ledger_reserve_release_statement_period_id",
          "def": "KEY fk_ledger_reserve_release_statement_period_id (statement_period_id) USING BTREE",
          "table": "ledger_reserve_release",
          "columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "uidx_ledger_reserve_release_schedule_id",
          "def": "UNIQUE KEY uidx_ledger_reserve_release_schedule_id (ledger_reserve_release_schedule_id) USING BTREE",
          "table": "ledger_reserve_release",
          "columns": [
            "ledger_reserve_release_schedule_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (ledger_reserve_release_id)",
          "table": "ledger_reserve_release",
          "columns": [
            "ledger_reserve_release_id"
          ]
        },
        {
          "name": "fk_ledger_reserve_release_abacus_event_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)",
          "table": "ledger_reserve_release",
          "referenced_table": "abacus_event",
          "columns": [
            "abacus_event_id"
          ],
          "referenced_columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_ledger_reserve_release_schedule_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (ledger_reserve_release_schedule_id) REFERENCES ledger_reserve_release_schedule (ledger_reserve_release_schedule_id)",
          "table": "ledger_reserve_release",
          "referenced_table": "ledger_reserve_release_schedule",
          "columns": [
            "ledger_reserve_release_schedule_id"
          ],
          "referenced_columns": [
            "ledger_reserve_release_schedule_id"
          ]
        },
        {
          "name": "fk_ledger_reserve_release_statement_period_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "ledger_reserve_release",
          "referenced_table": "statement_period",
          "columns": [
            "statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "uidx_ledger_reserve_release_schedule_id",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_ledger_reserve_release_schedule_id (ledger_reserve_release_schedule_id)",
          "table": "ledger_reserve_release",
          "columns": [
            "ledger_reserve_release_schedule_id"
          ]
        }
      ],
      "def": "CREATE TABLE `ledger_reserve_release` (\n  `ledger_reserve_release_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `abacus_event_id` mediumint unsigned NOT NULL,\n  `statement_period_id` mediumint unsigned NOT NULL,\n  `ledger_reserve_release_schedule_id` mediumint unsigned NOT NULL,\n  `installment_amount` decimal(20,2) NOT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`ledger_reserve_release_id`),\n  UNIQUE KEY `uidx_ledger_reserve_release_schedule_id` (`ledger_reserve_release_schedule_id`),\n  KEY `fk_ledger_reserve_release_abacus_event_id` (`abacus_event_id`),\n  KEY `fk_ledger_reserve_release_statement_period_id` (`statement_period_id`),\n  CONSTRAINT `fk_ledger_reserve_release_abacus_event_id` FOREIGN KEY (`abacus_event_id`) REFERENCES `abacus_event` (`abacus_event_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_reserve_release_schedule_id` FOREIGN KEY (`ledger_reserve_release_schedule_id`) REFERENCES `ledger_reserve_release_schedule` (`ledger_reserve_release_schedule_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_reserve_release_statement_period_id` FOREIGN KEY (`statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "ledger_reserve_release_schedule",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "abacus_event_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "early_release_date",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "installment_amount",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "ledger_reserve_release_schedule_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "ledger_reserve_taken_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "outstanding_amount_after_installment",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "release_statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "taken_statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (ledger_reserve_release_schedule_id) USING BTREE",
          "table": "ledger_reserve_release_schedule",
          "columns": [
            "ledger_reserve_release_schedule_id"
          ]
        },
        {
          "name": "fk_release_schedule_abacus_event",
          "def": "KEY fk_release_schedule_abacus_event (abacus_event_id) USING BTREE",
          "table": "ledger_reserve_release_schedule",
          "columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_release_schedule_account",
          "def": "KEY fk_release_schedule_account (account_id) USING BTREE",
          "table": "ledger_reserve_release_schedule",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_release_schedule_reserve_taken",
          "def": "KEY fk_release_schedule_reserve_taken (ledger_reserve_taken_id) USING BTREE",
          "table": "ledger_reserve_release_schedule",
          "columns": [
            "ledger_reserve_taken_id"
          ]
        },
        {
          "name": "fk_release_schedule_statement_period_release",
          "def": "KEY fk_release_schedule_statement_period_release (release_statement_period_id) USING BTREE",
          "table": "ledger_reserve_release_schedule",
          "columns": [
            "release_statement_period_id"
          ]
        },
        {
          "name": "fk_release_schedule_statement_period_taken",
          "def": "KEY fk_release_schedule_statement_period_taken (taken_statement_period_id) USING BTREE",
          "table": "ledger_reserve_release_schedule",
          "columns": [
            "taken_statement_period_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (ledger_reserve_release_schedule_id)",
          "table": "ledger_reserve_release_schedule",
          "columns": [
            "ledger_reserve_release_schedule_id"
          ]
        },
        {
          "name": "fk_release_schedule_abacus_event",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)",
          "table": "ledger_reserve_release_schedule",
          "referenced_table": "abacus_event",
          "columns": [
            "abacus_event_id"
          ],
          "referenced_columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_release_schedule_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "ledger_reserve_release_schedule",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_release_schedule_reserve_taken",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (ledger_reserve_taken_id) REFERENCES ledger_reserve_taken (ledger_reserve_taken_id)",
          "table": "ledger_reserve_release_schedule",
          "referenced_table": "ledger_reserve_taken",
          "columns": [
            "ledger_reserve_taken_id"
          ],
          "referenced_columns": [
            "ledger_reserve_taken_id"
          ]
        },
        {
          "name": "fk_release_schedule_statement_period_release",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (release_statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "ledger_reserve_release_schedule",
          "referenced_table": "statement_period",
          "columns": [
            "release_statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_release_schedule_statement_period_taken",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (taken_statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "ledger_reserve_release_schedule",
          "referenced_table": "statement_period",
          "columns": [
            "taken_statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        }
      ],
      "def": "CREATE TABLE `ledger_reserve_release_schedule` (\n  `ledger_reserve_release_schedule_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `abacus_event_id` mediumint unsigned NOT NULL,\n  `account_id` mediumint unsigned NOT NULL,\n  `taken_statement_period_id` mediumint unsigned NOT NULL,\n  `release_statement_period_id` mediumint unsigned NOT NULL,\n  `ledger_reserve_taken_id` mediumint unsigned NOT NULL,\n  `currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `installment_amount` decimal(20,2) NOT NULL,\n  `outstanding_amount_after_installment` decimal(20,2) NOT NULL,\n  `early_release_date` datetime DEFAULT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`ledger_reserve_release_schedule_id`),\n  KEY `fk_release_schedule_abacus_event` (`abacus_event_id`),\n  KEY `fk_release_schedule_account` (`account_id`),\n  KEY `fk_release_schedule_statement_period_taken` (`taken_statement_period_id`),\n  KEY `fk_release_schedule_statement_period_release` (`release_statement_period_id`),\n  KEY `fk_release_schedule_reserve_taken` (`ledger_reserve_taken_id`),\n  CONSTRAINT `fk_release_schedule_abacus_event` FOREIGN KEY (`abacus_event_id`) REFERENCES `abacus_event` (`abacus_event_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_release_schedule_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_release_schedule_reserve_taken` FOREIGN KEY (`ledger_reserve_taken_id`) REFERENCES `ledger_reserve_taken` (`ledger_reserve_taken_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_release_schedule_statement_period_release` FOREIGN KEY (`release_statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_release_schedule_statement_period_taken` FOREIGN KEY (`taken_statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "ledger_reserve_taken",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "abacus_event_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "accounting_run_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_reserve_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "gross_returns",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "gross_sales",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "ledger_reserve_taken_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "net_revenue",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "net_revenue_after_reserve",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "reserve_amount",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (ledger_reserve_taken_id) USING BTREE",
          "table": "ledger_reserve_taken",
          "columns": [
            "ledger_reserve_taken_id"
          ]
        },
        {
          "name": "fk_ledger_reserve_taken_abacus_event_id",
          "def": "KEY fk_ledger_reserve_taken_abacus_event_id (abacus_event_id) USING BTREE",
          "table": "ledger_reserve_taken",
          "columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_ledger_reserve_taken_accounting_run_id",
          "def": "KEY fk_ledger_reserve_taken_accounting_run_id (accounting_run_id) USING BTREE",
          "table": "ledger_reserve_taken",
          "columns": [
            "accounting_run_id"
          ]
        },
        {
          "name": "fk_ledger_reserve_taken_contract_reserve_id",
          "def": "KEY fk_ledger_reserve_taken_contract_reserve_id (contract_reserve_id) USING BTREE",
          "table": "ledger_reserve_taken",
          "columns": [
            "contract_reserve_id"
          ]
        },
        {
          "name": "fk_ledger_reserve_taken_statement_period_id",
          "def": "KEY fk_ledger_reserve_taken_statement_period_id (statement_period_id) USING BTREE",
          "table": "ledger_reserve_taken",
          "columns": [
            "statement_period_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (ledger_reserve_taken_id)",
          "table": "ledger_reserve_taken",
          "columns": [
            "ledger_reserve_taken_id"
          ]
        },
        {
          "name": "fk_ledger_reserve_taken_abacus_event_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)",
          "table": "ledger_reserve_taken",
          "referenced_table": "abacus_event",
          "columns": [
            "abacus_event_id"
          ],
          "referenced_columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_ledger_reserve_taken_accounting_run_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (accounting_run_id) REFERENCES accounting_run (accounting_run_id)",
          "table": "ledger_reserve_taken",
          "referenced_table": "accounting_run",
          "columns": [
            "accounting_run_id"
          ],
          "referenced_columns": [
            "accounting_run_id"
          ]
        },
        {
          "name": "fk_ledger_reserve_taken_contract_reserve_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_reserve_id) REFERENCES contract_reserve (contract_reserve_id)",
          "table": "ledger_reserve_taken",
          "referenced_table": "contract_reserve",
          "columns": [
            "contract_reserve_id"
          ],
          "referenced_columns": [
            "contract_reserve_id"
          ]
        },
        {
          "name": "fk_ledger_reserve_taken_statement_period_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "ledger_reserve_taken",
          "referenced_table": "statement_period",
          "columns": [
            "statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        }
      ],
      "def": "CREATE TABLE `ledger_reserve_taken` (\n  `ledger_reserve_taken_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `abacus_event_id` mediumint unsigned NOT NULL,\n  `contract_reserve_id` mediumint unsigned NOT NULL,\n  `accounting_run_id` mediumint unsigned NOT NULL,\n  `statement_period_id` mediumint unsigned NOT NULL,\n  `currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `gross_sales` decimal(20,2) NOT NULL,\n  `gross_returns` decimal(20,2) NOT NULL,\n  `net_revenue` decimal(20,2) NOT NULL,\n  `reserve_amount` decimal(20,2) NOT NULL,\n  `net_revenue_after_reserve` decimal(20,2) NOT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`ledger_reserve_taken_id`),\n  KEY `fk_ledger_reserve_taken_abacus_event_id` (`abacus_event_id`),\n  KEY `fk_ledger_reserve_taken_contract_reserve_id` (`contract_reserve_id`),\n  KEY `fk_ledger_reserve_taken_accounting_run_id` (`accounting_run_id`),\n  KEY `fk_ledger_reserve_taken_statement_period_id` (`statement_period_id`),\n  CONSTRAINT `fk_ledger_reserve_taken_abacus_event_id` FOREIGN KEY (`abacus_event_id`) REFERENCES `abacus_event` (`abacus_event_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_reserve_taken_accounting_run_id` FOREIGN KEY (`accounting_run_id`) REFERENCES `accounting_run` (`accounting_run_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_reserve_taken_contract_reserve_id` FOREIGN KEY (`contract_reserve_id`) REFERENCES `contract_reserve` (`contract_reserve_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_reserve_taken_statement_period_id` FOREIGN KEY (`statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "ledger_vat_summary",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "abacus_event_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "abacus_exempt_reason",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "activity_statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "base_amount_payee_currency",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "description",
          "type": "mediumtext",
          "nullable": true
        },
        {
          "name": "is_reporting_only",
          "type": "tinyint(1)",
          "nullable": false,
          "default": "0",
          "comment": "this entry is for reporting only and does not affect the ledger"
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "ledger_vat_summary_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "net_amount_payee_currency",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "payee_currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "vat_amount_payee_currency",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "vat_amount_vat_currency",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "vat_category",
          "type": "enum('gross_revenue','distribution_fee','closing_balance','commission')",
          "nullable": false
        },
        {
          "name": "vat_currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "vat_rate",
          "type": "decimal(5,2)",
          "nullable": true
        },
        {
          "name": "wht_amount_payee_currency",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "wht_amount_vat_currency",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "wht_rate",
          "type": "decimal(5,2)",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (ledger_vat_summary_id) USING BTREE",
          "table": "ledger_vat_summary",
          "columns": [
            "ledger_vat_summary_id"
          ]
        },
        {
          "name": "fk_ledger_vat_summary_account",
          "def": "KEY fk_ledger_vat_summary_account (account_id) USING BTREE",
          "table": "ledger_vat_summary",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_ledger_vat_summary_activity_statement_period",
          "def": "KEY fk_ledger_vat_summary_activity_statement_period (activity_statement_period_id) USING BTREE",
          "table": "ledger_vat_summary",
          "columns": [
            "activity_statement_period_id"
          ]
        },
        {
          "name": "fk_ledger_vat_summary_contract",
          "def": "KEY fk_ledger_vat_summary_contract (contract_id) USING BTREE",
          "table": "ledger_vat_summary",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_ledger_vat_summary_event",
          "def": "KEY fk_ledger_vat_summary_event (abacus_event_id) USING BTREE",
          "table": "ledger_vat_summary",
          "columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_ledger_vat_summary_statement_period",
          "def": "KEY fk_ledger_vat_summary_statement_period (statement_period_id) USING BTREE",
          "table": "ledger_vat_summary",
          "columns": [
            "statement_period_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (ledger_vat_summary_id)",
          "table": "ledger_vat_summary",
          "columns": [
            "ledger_vat_summary_id"
          ]
        },
        {
          "name": "fk_ledger_vat_summary_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "ledger_vat_summary",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_ledger_vat_summary_activity_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (activity_statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "ledger_vat_summary",
          "referenced_table": "statement_period",
          "columns": [
            "activity_statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_ledger_vat_summary_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "ledger_vat_summary",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_ledger_vat_summary_event",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)",
          "table": "ledger_vat_summary",
          "referenced_table": "abacus_event",
          "columns": [
            "abacus_event_id"
          ],
          "referenced_columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_ledger_vat_summary_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "ledger_vat_summary",
          "referenced_table": "statement_period",
          "columns": [
            "statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        }
      ],
      "def": "CREATE TABLE `ledger_vat_summary` (\n  `ledger_vat_summary_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `statement_period_id` mediumint unsigned NOT NULL,\n  `activity_statement_period_id` mediumint unsigned NOT NULL,\n  `abacus_event_id` mediumint unsigned NOT NULL,\n  `account_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned NOT NULL,\n  `vat_category` enum('gross_revenue','distribution_fee','closing_balance','commission') COLLATE utf8mb4_general_ci NOT NULL,\n  `payee_currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `vat_currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `base_amount_payee_currency` decimal(20,2) NOT NULL,\n  `vat_rate` decimal(5,2) DEFAULT NULL,\n  `vat_amount_payee_currency` decimal(20,2) DEFAULT NULL,\n  `vat_amount_vat_currency` decimal(20,2) DEFAULT NULL,\n  `net_amount_payee_currency` decimal(20,2) NOT NULL,\n  `wht_rate` decimal(5,2) DEFAULT NULL,\n  `wht_amount_vat_currency` decimal(20,2) DEFAULT NULL,\n  `wht_amount_payee_currency` decimal(20,2) DEFAULT NULL,\n  `abacus_exempt_reason` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `description` mediumtext COLLATE utf8mb4_general_ci,\n  `is_reporting_only` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'this entry is for reporting only and does not affect the ledger',\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`ledger_vat_summary_id`),\n  KEY `fk_ledger_vat_summary_event` (`abacus_event_id`),\n  KEY `fk_ledger_vat_summary_account` (`account_id`),\n  KEY `fk_ledger_vat_summary_contract` (`contract_id`),\n  KEY `fk_ledger_vat_summary_statement_period` (`statement_period_id`),\n  KEY `fk_ledger_vat_summary_activity_statement_period` (`activity_statement_period_id`),\n  CONSTRAINT `fk_ledger_vat_summary_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_vat_summary_activity_statement_period` FOREIGN KEY (`activity_statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_vat_summary_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_vat_summary_event` FOREIGN KEY (`abacus_event_id`) REFERENCES `abacus_event` (`abacus_event_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_ledger_vat_summary_statement_period` FOREIGN KEY (`statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "legacy_contract",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "legacy_contract_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "oa_contract_id",
          "type": "int",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (legacy_contract_id) USING BTREE",
          "table": "legacy_contract",
          "columns": [
            "legacy_contract_id"
          ]
        },
        {
          "name": "fk_legacy_contract_contract",
          "def": "KEY fk_legacy_contract_contract (contract_id) USING BTREE",
          "table": "legacy_contract",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "idx_oa_contract_id",
          "def": "KEY idx_oa_contract_id (oa_contract_id) USING BTREE",
          "table": "legacy_contract",
          "columns": [
            "oa_contract_id"
          ]
        },
        {
          "name": "unique_legacy_contract",
          "def": "UNIQUE KEY unique_legacy_contract (contract_id, oa_contract_id) USING BTREE",
          "table": "legacy_contract",
          "columns": [
            "contract_id",
            "oa_contract_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (legacy_contract_id)",
          "table": "legacy_contract",
          "columns": [
            "legacy_contract_id"
          ]
        },
        {
          "name": "fk_legacy_contract_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "legacy_contract",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "unique_legacy_contract",
          "type": "UNIQUE",
          "def": "UNIQUE KEY unique_legacy_contract (contract_id, oa_contract_id)",
          "table": "legacy_contract",
          "columns": [
            "contract_id",
            "oa_contract_id"
          ]
        }
      ],
      "def": "CREATE TABLE `legacy_contract` (\n  `legacy_contract_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `contract_id` mediumint unsigned NOT NULL,\n  `oa_contract_id` int DEFAULT NULL,\n  PRIMARY KEY (`legacy_contract_id`),\n  UNIQUE KEY `unique_legacy_contract` (`contract_id`,`oa_contract_id`),\n  KEY `fk_legacy_contract_contract` (`contract_id`),\n  KEY `idx_oa_contract_id` (`oa_contract_id`),\n  CONSTRAINT `fk_legacy_contract_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "oa_territory_backfilled_accounts",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "accounts",
          "type": "json",
          "nullable": false
        },
        {
          "name": "audit_id",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "backfill_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (backfill_id) USING BTREE",
          "table": "oa_territory_backfilled_accounts",
          "columns": [
            "backfill_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (backfill_id)",
          "table": "oa_territory_backfilled_accounts",
          "columns": [
            "backfill_id"
          ]
        }
      ],
      "def": "CREATE TABLE `oa_territory_backfilled_accounts` (\n  `backfill_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `accounts` json NOT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `created_at` datetime NOT NULL,\n  `audit_id` varchar(255) DEFAULT NULL,\n  PRIMARY KEY (`backfill_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "payee",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "payee_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "payee_name",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "payee_type",
          "type": "enum('collaborator')",
          "nullable": false
        },
        {
          "name": "payoneer_assigned_id",
          "type": "bigint unsigned",
          "nullable": true
        },
        {
          "name": "payoneer_client_reference_id",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "payoneer_program_id",
          "type": "int unsigned",
          "nullable": false
        },
        {
          "name": "reference_payment_type_id",
          "type": "smallint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (payee_id) USING BTREE",
          "table": "payee",
          "columns": [
            "payee_id"
          ]
        },
        {
          "name": "fk_payee_payoneer_program_id",
          "def": "KEY fk_payee_payoneer_program_id (payoneer_program_id) USING BTREE",
          "table": "payee",
          "columns": [
            "payoneer_program_id"
          ]
        },
        {
          "name": "fk_payee_reference_payment_type_id",
          "def": "KEY fk_payee_reference_payment_type_id (reference_payment_type_id) USING BTREE",
          "table": "payee",
          "columns": [
            "reference_payment_type_id"
          ]
        },
        {
          "name": "uidx_payee_payoneer_client_reference_id",
          "def": "UNIQUE KEY uidx_payee_payoneer_client_reference_id (payoneer_client_reference_id) USING BTREE",
          "table": "payee",
          "columns": [
            "payoneer_client_reference_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (payee_id)",
          "table": "payee",
          "columns": [
            "payee_id"
          ]
        },
        {
          "name": "fk_payee_payoneer_program_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (payoneer_program_id) REFERENCES reference_payoneer_program (payoneer_program_id)",
          "table": "payee",
          "referenced_table": "reference_payoneer_program",
          "columns": [
            "payoneer_program_id"
          ],
          "referenced_columns": [
            "payoneer_program_id"
          ]
        },
        {
          "name": "fk_payee_reference_payment_type_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (reference_payment_type_id) REFERENCES reference_payment_type (reference_payment_type_id)",
          "table": "payee",
          "referenced_table": "reference_payment_type",
          "columns": [
            "reference_payment_type_id"
          ],
          "referenced_columns": [
            "reference_payment_type_id"
          ]
        },
        {
          "name": "uidx_payee_payoneer_client_reference_id",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_payee_payoneer_client_reference_id (payoneer_client_reference_id)",
          "table": "payee",
          "columns": [
            "payoneer_client_reference_id"
          ]
        }
      ],
      "triggers": [
        {
          "name": "after_payee",
          "def": "CREATE TRIGGER after_payee AFTER UPDATE ON payee\nFOR EACH ROW\nBEGIN\nINSERT INTO `payee_history`\n(\n    `payee_id`,\n    `reference_payment_type_id`,\n    `payoneer_client_reference_id`,\n    `payoneer_program_id`,\n    `payoneer_assigned_id`,\n    `payee_name`,\n    `payee_type`,\n    `created_by`,\n    `created_at`,\n    `last_modified_by`,\n    `last_modified`\n)\nVALUES\n(\n    old.`payee_id`,\n    old.`reference_payment_type_id`,\n    old.`payoneer_client_reference_id`,\n    old.`payoneer_program_id`,\n    old.`payoneer_assigned_id`,\n    old.`payee_name`,\n    old.`payee_type`,\n    old.`created_by`,\n    old.`created_at`,\n    old.`last_modified_by`,\n    old.`last_modified`\n);\nEND"
        }
      ],
      "def": "CREATE TABLE `payee` (\n  `payee_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `reference_payment_type_id` smallint unsigned NOT NULL,\n  `payoneer_client_reference_id` varchar(255) NOT NULL,\n  `payoneer_program_id` int unsigned NOT NULL,\n  `payoneer_assigned_id` bigint unsigned DEFAULT NULL,\n  `payee_name` varchar(255) DEFAULT NULL,\n  `payee_type` enum('collaborator') NOT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`payee_id`),\n  UNIQUE KEY `uidx_payee_payoneer_client_reference_id` (`payoneer_client_reference_id`),\n  KEY `fk_payee_reference_payment_type_id` (`reference_payment_type_id`),\n  KEY `fk_payee_payoneer_program_id` (`payoneer_program_id`),\n  CONSTRAINT `fk_payee_payoneer_program_id` FOREIGN KEY (`payoneer_program_id`) REFERENCES `reference_payoneer_program` (`payoneer_program_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_payee_reference_payment_type_id` FOREIGN KEY (`reference_payment_type_id`) REFERENCES `reference_payment_type` (`reference_payment_type_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci"
    },
    {
      "name": "payee_collaborator",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "collaborator_id",
          "type": "int",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "payee_collaborator_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "payee_id",
          "type": "mediumint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (payee_collaborator_id) USING BTREE",
          "table": "payee_collaborator",
          "columns": [
            "payee_collaborator_id"
          ]
        },
        {
          "name": "collaborator_id",
          "def": "UNIQUE KEY collaborator_id (collaborator_id) USING BTREE",
          "table": "payee_collaborator",
          "columns": [
            "collaborator_id"
          ]
        },
        {
          "name": "fk_payee_collaborator_account_id",
          "def": "KEY fk_payee_collaborator_account_id (account_id) USING BTREE",
          "table": "payee_collaborator",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_payee_collaborator_payee_id",
          "def": "KEY fk_payee_collaborator_payee_id (payee_id) USING BTREE",
          "table": "payee_collaborator",
          "columns": [
            "payee_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (payee_collaborator_id)",
          "table": "payee_collaborator",
          "columns": [
            "payee_collaborator_id"
          ]
        },
        {
          "name": "collaborator_id",
          "type": "UNIQUE",
          "def": "UNIQUE KEY collaborator_id (collaborator_id)",
          "table": "payee_collaborator",
          "columns": [
            "collaborator_id"
          ]
        },
        {
          "name": "fk_payee_collaborator_account_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "payee_collaborator",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_payee_collaborator_payee_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (payee_id) REFERENCES payee (payee_id)",
          "table": "payee_collaborator",
          "referenced_table": "payee",
          "columns": [
            "payee_id"
          ],
          "referenced_columns": [
            "payee_id"
          ]
        }
      ],
      "def": "CREATE TABLE `payee_collaborator` (\n  `payee_collaborator_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `collaborator_id` int NOT NULL,\n  `payee_id` mediumint unsigned NOT NULL,\n  `account_id` mediumint unsigned NOT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`payee_collaborator_id`),\n  UNIQUE KEY `collaborator_id` (`collaborator_id`),\n  KEY `fk_payee_collaborator_payee_id` (`payee_id`),\n  KEY `fk_payee_collaborator_account_id` (`account_id`),\n  CONSTRAINT `fk_payee_collaborator_account_id` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_payee_collaborator_payee_id` FOREIGN KEY (`payee_id`) REFERENCES `payee` (`payee_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci"
    },
    {
      "name": "payee_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "payee_history_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "payee_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "payee_name",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "payee_type",
          "type": "enum('collaborator')",
          "nullable": false
        },
        {
          "name": "payoneer_assigned_id",
          "type": "bigint unsigned",
          "nullable": true
        },
        {
          "name": "payoneer_client_reference_id",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "payoneer_program_id",
          "type": "int unsigned",
          "nullable": false
        },
        {
          "name": "reference_payment_type_id",
          "type": "smallint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (payee_history_id) USING BTREE",
          "table": "payee_history",
          "columns": [
            "payee_history_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (payee_history_id)",
          "table": "payee_history",
          "columns": [
            "payee_history_id"
          ]
        }
      ],
      "def": "CREATE TABLE `payee_history` (\n  `payee_history_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `payee_id` mediumint unsigned NOT NULL,\n  `reference_payment_type_id` smallint unsigned NOT NULL,\n  `payoneer_client_reference_id` varchar(255) NOT NULL,\n  `payoneer_program_id` int unsigned NOT NULL,\n  `payoneer_assigned_id` bigint unsigned DEFAULT NULL,\n  `payee_name` varchar(255) DEFAULT NULL,\n  `payee_type` enum('collaborator') NOT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`payee_history_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci"
    },
    {
      "name": "payee_kyc_notification",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "entity_reference_id",
          "type": "varchar(36)",
          "nullable": true
        },
        {
          "name": "entity_reference_type_id",
          "type": "tinyint",
          "nullable": true
        },
        {
          "name": "file_upload_link",
          "type": "varchar(1000)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "payee_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "payee_kyc_notification_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "possible_sub_requirement_types",
          "type": "varchar(1000)",
          "nullable": true
        },
        {
          "name": "requirement_id",
          "type": "varchar(1000)",
          "nullable": true
        },
        {
          "name": "requirement_type_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "sub_requirement_id",
          "type": "varchar(1000)",
          "nullable": true
        },
        {
          "name": "sub_requirement_status_id",
          "type": "tinyint",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (payee_kyc_notification_id) USING BTREE",
          "table": "payee_kyc_notification",
          "columns": [
            "payee_kyc_notification_id"
          ]
        },
        {
          "name": "fk_apkn_payee_id",
          "def": "KEY fk_apkn_payee_id (payee_id) USING BTREE",
          "table": "payee_kyc_notification",
          "columns": [
            "payee_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (payee_kyc_notification_id)",
          "table": "payee_kyc_notification",
          "columns": [
            "payee_kyc_notification_id"
          ]
        },
        {
          "name": "fk_apkn_payee_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (payee_id) REFERENCES payee (payee_id)",
          "table": "payee_kyc_notification",
          "referenced_table": "payee",
          "columns": [
            "payee_id"
          ],
          "referenced_columns": [
            "payee_id"
          ]
        }
      ],
      "triggers": [
        {
          "name": "after_payee_kyc_notification",
          "def": "CREATE TRIGGER after_payee_kyc_notification AFTER UPDATE ON payee_kyc_notification\nFOR EACH ROW\nBEGIN\n    INSERT INTO `payee_kyc_notification_history`(\n        `payee_kyc_notification_id`,\n        `payee_id`,\n        `file_upload_link`,\n        `requirement_id`,\n        `requirement_type_id`,\n        `sub_requirement_id`,\n        `possible_sub_requirement_types`,\n        `sub_requirement_status_id`,\n        `entity_reference_id`,\n        `entity_reference_type_id`,\n        `created_at`,\n        `created_by`,\n        `last_modified`,\n        `last_modified_by`,\n        `deleted_at`,\n        `deleted_by`\n    ) VALUES (\n        old.`payee_kyc_notification_id`,\n        old.`payee_id`,\n        old.`file_upload_link`,\n        old.`requirement_id`,\n        old.`requirement_type_id`,\n        old.`sub_requirement_id`,\n        old.`possible_sub_requirement_types`,\n        old.`sub_requirement_status_id`,\n        old.`entity_reference_id`,\n        old.`entity_reference_type_id`,\n        old.`created_at`,\n        old.`created_by`,\n        old.`last_modified`,\n        old.`last_modified_by`,\n        old.`deleted_at`,\n        old.`deleted_by`\n    );\nEND"
        }
      ],
      "def": "CREATE TABLE `payee_kyc_notification` (\n  `payee_kyc_notification_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `payee_id` mediumint unsigned NOT NULL,\n  `file_upload_link` varchar(1000) NOT NULL,\n  `requirement_id` varchar(1000) DEFAULT NULL,\n  `requirement_type_id` mediumint unsigned DEFAULT NULL,\n  `sub_requirement_id` varchar(1000) DEFAULT NULL,\n  `possible_sub_requirement_types` varchar(1000) DEFAULT NULL,\n  `sub_requirement_status_id` tinyint DEFAULT NULL,\n  `entity_reference_id` varchar(36) DEFAULT NULL,\n  `entity_reference_type_id` tinyint DEFAULT NULL,\n  `created_at` datetime NOT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(255) DEFAULT NULL,\n  PRIMARY KEY (`payee_kyc_notification_id`),\n  KEY `fk_apkn_payee_id` (`payee_id`),\n  CONSTRAINT `fk_apkn_payee_id` FOREIGN KEY (`payee_id`) REFERENCES `payee` (`payee_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci"
    },
    {
      "name": "payee_kyc_notification_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "entity_reference_id",
          "type": "varchar(36)",
          "nullable": true
        },
        {
          "name": "entity_reference_type_id",
          "type": "tinyint",
          "nullable": true
        },
        {
          "name": "file_upload_link",
          "type": "varchar(1000)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "payee_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "payee_kyc_notification_history_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "payee_kyc_notification_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "possible_sub_requirement_types",
          "type": "varchar(1000)",
          "nullable": true
        },
        {
          "name": "requirement_id",
          "type": "varchar(1000)",
          "nullable": true
        },
        {
          "name": "requirement_type_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "sub_requirement_id",
          "type": "varchar(1000)",
          "nullable": true
        },
        {
          "name": "sub_requirement_status_id",
          "type": "tinyint",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (payee_kyc_notification_history_id) USING BTREE",
          "table": "payee_kyc_notification_history",
          "columns": [
            "payee_kyc_notification_history_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (payee_kyc_notification_history_id)",
          "table": "payee_kyc_notification_history",
          "columns": [
            "payee_kyc_notification_history_id"
          ]
        }
      ],
      "def": "CREATE TABLE `payee_kyc_notification_history` (\n  `payee_kyc_notification_history_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `payee_kyc_notification_id` mediumint unsigned NOT NULL,\n  `payee_id` mediumint unsigned NOT NULL,\n  `file_upload_link` varchar(1000) NOT NULL,\n  `requirement_id` varchar(1000) DEFAULT NULL,\n  `requirement_type_id` mediumint unsigned DEFAULT NULL,\n  `sub_requirement_id` varchar(1000) DEFAULT NULL,\n  `possible_sub_requirement_types` varchar(1000) DEFAULT NULL,\n  `sub_requirement_status_id` tinyint DEFAULT NULL,\n  `entity_reference_id` varchar(36) DEFAULT NULL,\n  `entity_reference_type_id` tinyint DEFAULT NULL,\n  `created_at` datetime NOT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(255) DEFAULT NULL,\n  PRIMARY KEY (`payee_kyc_notification_history_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci"
    },
    {
      "name": "payment_entity_payoneer_program",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "agreement_type_id",
          "type": "tinyint unsigned",
          "nullable": false
        },
        {
          "name": "payment_currency",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "payment_entity_payoneer_program_id",
          "type": "smallint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "payoneer_program_id",
          "type": "int unsigned",
          "nullable": false
        },
        {
          "name": "reference_payment_entity_id",
          "type": "mediumint unsigned",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (payment_entity_payoneer_program_id) USING BTREE",
          "table": "payment_entity_payoneer_program",
          "columns": [
            "payment_entity_payoneer_program_id"
          ]
        },
        {
          "name": "fk_payment_entity_payoneer_program_agreement_type",
          "def": "KEY fk_payment_entity_payoneer_program_agreement_type (agreement_type_id) USING BTREE",
          "table": "payment_entity_payoneer_program",
          "columns": [
            "agreement_type_id"
          ]
        },
        {
          "name": "fk_payoneer_program_payment_entity",
          "def": "KEY fk_payoneer_program_payment_entity (payoneer_program_id) USING BTREE",
          "table": "payment_entity_payoneer_program",
          "columns": [
            "payoneer_program_id"
          ]
        },
        {
          "name": "fk_payoneer_program_reference_payment_entity",
          "def": "KEY fk_payoneer_program_reference_payment_entity (reference_payment_entity_id) USING BTREE",
          "table": "payment_entity_payoneer_program",
          "columns": [
            "reference_payment_entity_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (payment_entity_payoneer_program_id)",
          "table": "payment_entity_payoneer_program",
          "columns": [
            "payment_entity_payoneer_program_id"
          ]
        },
        {
          "name": "fk_payment_entity_payoneer_program_agreement_type",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (agreement_type_id) REFERENCES reference_agreement_type (reference_agreement_type_id)",
          "table": "payment_entity_payoneer_program",
          "referenced_table": "reference_agreement_type",
          "columns": [
            "agreement_type_id"
          ],
          "referenced_columns": [
            "reference_agreement_type_id"
          ]
        },
        {
          "name": "fk_payoneer_program_payment_entity",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (payoneer_program_id) REFERENCES reference_payoneer_program (payoneer_program_id)",
          "table": "payment_entity_payoneer_program",
          "referenced_table": "reference_payoneer_program",
          "columns": [
            "payoneer_program_id"
          ],
          "referenced_columns": [
            "payoneer_program_id"
          ]
        },
        {
          "name": "fk_payoneer_program_reference_payment_entity",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (reference_payment_entity_id) REFERENCES reference_payment_entity (reference_payment_entity_id)",
          "table": "payment_entity_payoneer_program",
          "referenced_table": "reference_payment_entity",
          "columns": [
            "reference_payment_entity_id"
          ],
          "referenced_columns": [
            "reference_payment_entity_id"
          ]
        }
      ],
      "def": "CREATE TABLE `payment_entity_payoneer_program` (\n  `payment_entity_payoneer_program_id` smallint unsigned NOT NULL AUTO_INCREMENT,\n  `payoneer_program_id` int unsigned NOT NULL,\n  `reference_payment_entity_id` mediumint unsigned DEFAULT NULL,\n  `payment_currency` char(3) NOT NULL,\n  `agreement_type_id` tinyint unsigned NOT NULL,\n  PRIMARY KEY (`payment_entity_payoneer_program_id`),\n  KEY `fk_payoneer_program_payment_entity` (`payoneer_program_id`),\n  KEY `fk_payment_entity_payoneer_program_agreement_type` (`agreement_type_id`),\n  KEY `fk_payoneer_program_reference_payment_entity` (`reference_payment_entity_id`),\n  CONSTRAINT `fk_payment_entity_payoneer_program_agreement_type` FOREIGN KEY (`agreement_type_id`) REFERENCES `reference_agreement_type` (`reference_agreement_type_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_payoneer_program_payment_entity` FOREIGN KEY (`payoneer_program_id`) REFERENCES `reference_payoneer_program` (`payoneer_program_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_payoneer_program_reference_payment_entity` FOREIGN KEY (`reference_payment_entity_id`) REFERENCES `reference_payment_entity` (`reference_payment_entity_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "payment_group",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "group_criteria",
          "type": "json",
          "nullable": true
        },
        {
          "name": "group_name",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "is_reusable",
          "type": "tinyint(1)",
          "nullable": false,
          "default": "0"
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "payment_group_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (payment_group_id) USING BTREE",
          "table": "payment_group",
          "columns": [
            "payment_group_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (payment_group_id)",
          "table": "payment_group",
          "columns": [
            "payment_group_id"
          ]
        }
      ],
      "def": "CREATE TABLE `payment_group` (\n  `payment_group_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `group_name` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `group_criteria` json DEFAULT NULL,\n  `is_reusable` tinyint(1) NOT NULL DEFAULT '0',\n  `created_at` datetime NOT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  PRIMARY KEY (`payment_group_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "payment_group_payment",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "payment_group_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "payment_group_payment_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "payment_name",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (payment_group_payment_id) USING BTREE",
          "table": "payment_group_payment",
          "columns": [
            "payment_group_payment_id"
          ]
        },
        {
          "name": "fk_payment_group_payment_statement_period",
          "def": "KEY fk_payment_group_payment_statement_period (statement_period_id) USING BTREE",
          "table": "payment_group_payment",
          "columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "idx_payment_group_id",
          "def": "KEY idx_payment_group_id (payment_group_id) USING BTREE",
          "table": "payment_group_payment",
          "columns": [
            "payment_group_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (payment_group_payment_id)",
          "table": "payment_group_payment",
          "columns": [
            "payment_group_payment_id"
          ]
        },
        {
          "name": "fk_payment_group_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (payment_group_id) REFERENCES payment_group (payment_group_id)",
          "table": "payment_group_payment",
          "referenced_table": "payment_group",
          "columns": [
            "payment_group_id"
          ],
          "referenced_columns": [
            "payment_group_id"
          ]
        },
        {
          "name": "fk_payment_group_payment_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "payment_group_payment",
          "referenced_table": "statement_period",
          "columns": [
            "statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        }
      ],
      "triggers": [
        {
          "name": "before_insert_payment_group_payment",
          "def": "CREATE TRIGGER before_insert_payment_group_payment BEFORE INSERT ON payment_group_payment\nFOR EACH ROW\nBEGIN\n    IF NEW.statement_period_id IS NULL THEN\n        SET NEW.statement_period_id = COALESCE(\n            (SELECT statement_period_id FROM statement_period WHERE statement_period_status = 'current'),\n            (SELECT MIN(statement_period_id) FROM statement_period WHERE statement_period_status = 'open')\n        );\n    END IF;\nEND"
        }
      ],
      "def": "CREATE TABLE `payment_group_payment` (\n  `payment_group_payment_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `payment_group_id` mediumint unsigned NOT NULL,\n  `statement_period_id` mediumint unsigned NOT NULL,\n  `payment_name` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  PRIMARY KEY (`payment_group_payment_id`),\n  KEY `idx_payment_group_id` (`payment_group_id`),\n  KEY `fk_payment_group_payment_statement_period` (`statement_period_id`),\n  CONSTRAINT `fk_payment_group_id` FOREIGN KEY (`payment_group_id`) REFERENCES `payment_group` (`payment_group_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_payment_group_payment_statement_period` FOREIGN KEY (`statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "payment_group_payment_account",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "balance_after_tax",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "contracts_payable",
          "type": "json",
          "nullable": true
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "current_balance",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "current_statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "last_payment",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "last_statement_period_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "note",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "payment_group_payment_account_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "payment_group_payment_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "payoneer_program_id",
          "type": "int unsigned",
          "nullable": false
        },
        {
          "name": "prior_payment_group_payment_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "tax_withholding",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "vat_amount",
          "type": "decimal(20,2)",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (payment_group_payment_account_id) USING BTREE",
          "table": "payment_group_payment_account",
          "columns": [
            "payment_group_payment_account_id"
          ]
        },
        {
          "name": "fk_payment_account_current_statement_period",
          "def": "KEY fk_payment_account_current_statement_period (current_statement_period_id) USING BTREE",
          "table": "payment_group_payment_account",
          "columns": [
            "current_statement_period_id"
          ]
        },
        {
          "name": "fk_payment_account_last_statement_period",
          "def": "KEY fk_payment_account_last_statement_period (last_statement_period_id) USING BTREE",
          "table": "payment_group_payment_account",
          "columns": [
            "last_statement_period_id"
          ]
        },
        {
          "name": "fk_payment_account_reference_payoneer_program",
          "def": "KEY fk_payment_account_reference_payoneer_program (payoneer_program_id) USING BTREE",
          "table": "payment_group_payment_account",
          "columns": [
            "payoneer_program_id"
          ]
        },
        {
          "name": "idx_account_id",
          "def": "KEY idx_account_id (account_id) USING BTREE",
          "table": "payment_group_payment_account",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "idx_group_payment_id",
          "def": "KEY idx_group_payment_id (payment_group_payment_id) USING BTREE",
          "table": "payment_group_payment_account",
          "columns": [
            "payment_group_payment_id"
          ]
        },
        {
          "name": "uidx_group_payment_account",
          "def": "UNIQUE KEY uidx_group_payment_account (payment_group_payment_id, account_id) USING BTREE",
          "table": "payment_group_payment_account",
          "columns": [
            "payment_group_payment_id",
            "account_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (payment_group_payment_account_id)",
          "table": "payment_group_payment_account",
          "columns": [
            "payment_group_payment_account_id"
          ]
        },
        {
          "name": "fk_group_account_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "payment_group_payment_account",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_group_account_group_payment",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (payment_group_payment_id) REFERENCES payment_group_payment (payment_group_payment_id)",
          "table": "payment_group_payment_account",
          "referenced_table": "payment_group_payment",
          "columns": [
            "payment_group_payment_id"
          ],
          "referenced_columns": [
            "payment_group_payment_id"
          ]
        },
        {
          "name": "fk_payment_account_current_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (current_statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "payment_group_payment_account",
          "referenced_table": "statement_period",
          "columns": [
            "current_statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_payment_account_last_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (last_statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "payment_group_payment_account",
          "referenced_table": "statement_period",
          "columns": [
            "last_statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_payment_account_reference_payoneer_program",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (payoneer_program_id) REFERENCES reference_payoneer_program (payoneer_program_id)",
          "table": "payment_group_payment_account",
          "referenced_table": "reference_payoneer_program",
          "columns": [
            "payoneer_program_id"
          ],
          "referenced_columns": [
            "payoneer_program_id"
          ]
        },
        {
          "name": "uidx_group_payment_account",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_group_payment_account (payment_group_payment_id, account_id)",
          "table": "payment_group_payment_account",
          "columns": [
            "payment_group_payment_id",
            "account_id"
          ]
        }
      ],
      "def": "CREATE TABLE `payment_group_payment_account` (\n  `payment_group_payment_account_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `payment_group_payment_id` mediumint unsigned NOT NULL,\n  `prior_payment_group_payment_id` mediumint unsigned DEFAULT NULL,\n  `account_id` mediumint unsigned NOT NULL,\n  `payoneer_program_id` int unsigned NOT NULL,\n  `last_statement_period_id` mediumint unsigned DEFAULT NULL,\n  `current_statement_period_id` mediumint unsigned NOT NULL,\n  `currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_payment` decimal(20,2) NOT NULL,\n  `contracts_payable` json DEFAULT NULL,\n  `current_balance` decimal(20,2) NOT NULL,\n  `tax_withholding` decimal(20,2) DEFAULT NULL,\n  `vat_amount` decimal(20,2) DEFAULT NULL,\n  `balance_after_tax` decimal(20,2) NOT NULL,\n  `note` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `created_at` datetime NOT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  PRIMARY KEY (`payment_group_payment_account_id`),\n  UNIQUE KEY `uidx_group_payment_account` (`payment_group_payment_id`,`account_id`),\n  KEY `idx_group_payment_id` (`payment_group_payment_id`),\n  KEY `idx_account_id` (`account_id`),\n  KEY `fk_payment_account_reference_payoneer_program` (`payoneer_program_id`),\n  KEY `fk_payment_account_last_statement_period` (`last_statement_period_id`),\n  KEY `fk_payment_account_current_statement_period` (`current_statement_period_id`),\n  CONSTRAINT `fk_group_account_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_group_account_group_payment` FOREIGN KEY (`payment_group_payment_id`) REFERENCES `payment_group_payment` (`payment_group_payment_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_payment_account_current_statement_period` FOREIGN KEY (`current_statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_payment_account_last_statement_period` FOREIGN KEY (`last_statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_payment_account_reference_payoneer_program` FOREIGN KEY (`payoneer_program_id`) REFERENCES `reference_payoneer_program` (`payoneer_program_id`) ON DELETE RESTRICT ON UPDATE RESTRICT\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "payment_group_payment_account_detail",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "payable_amount_post_tax",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "payable_amount_pre_tax",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "payment_group_payment_account_detail_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "payment_group_payment_account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "tax_withholding_amount",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "vat_amount",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "worksheet_account_contract_payable_after_tax_id",
          "type": "mediumint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (payment_group_payment_account_detail_id) USING BTREE",
          "table": "payment_group_payment_account_detail",
          "columns": [
            "payment_group_payment_account_detail_id"
          ]
        },
        {
          "name": "fk_pgpad_account",
          "def": "KEY fk_pgpad_account (account_id) USING BTREE",
          "table": "payment_group_payment_account_detail",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_pgpad_contract",
          "def": "KEY fk_pgpad_contract (contract_id) USING BTREE",
          "table": "payment_group_payment_account_detail",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_pgpad_payment_group_payment_account",
          "def": "KEY fk_pgpad_payment_group_payment_account (payment_group_payment_account_id) USING BTREE",
          "table": "payment_group_payment_account_detail",
          "columns": [
            "payment_group_payment_account_id"
          ]
        },
        {
          "name": "fk_pgpad_wacpat",
          "def": "KEY fk_pgpad_wacpat (worksheet_account_contract_payable_after_tax_id) USING BTREE",
          "table": "payment_group_payment_account_detail",
          "columns": [
            "worksheet_account_contract_payable_after_tax_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (payment_group_payment_account_detail_id)",
          "table": "payment_group_payment_account_detail",
          "columns": [
            "payment_group_payment_account_detail_id"
          ]
        },
        {
          "name": "fk_pgpad_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "payment_group_payment_account_detail",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_pgpad_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "payment_group_payment_account_detail",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_pgpad_payment_group_payment_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (payment_group_payment_account_id) REFERENCES payment_group_payment_account (payment_group_payment_account_id)",
          "table": "payment_group_payment_account_detail",
          "referenced_table": "payment_group_payment_account",
          "columns": [
            "payment_group_payment_account_id"
          ],
          "referenced_columns": [
            "payment_group_payment_account_id"
          ]
        },
        {
          "name": "fk_pgpad_wacpat",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (worksheet_account_contract_payable_after_tax_id) REFERENCES worksheet_account_contract_payable_after_tax (worksheet_account_contract_payable_after_tax_id)",
          "table": "payment_group_payment_account_detail",
          "referenced_table": "worksheet_account_contract_payable_after_tax",
          "columns": [
            "worksheet_account_contract_payable_after_tax_id"
          ],
          "referenced_columns": [
            "worksheet_account_contract_payable_after_tax_id"
          ]
        }
      ],
      "def": "CREATE TABLE `payment_group_payment_account_detail` (\n  `payment_group_payment_account_detail_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `payment_group_payment_account_id` mediumint unsigned NOT NULL,\n  `worksheet_account_contract_payable_after_tax_id` mediumint unsigned NOT NULL,\n  `account_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned NOT NULL,\n  `payable_amount_pre_tax` decimal(20,2) NOT NULL,\n  `tax_withholding_amount` decimal(20,2) DEFAULT NULL,\n  `vat_amount` decimal(20,2) DEFAULT NULL,\n  `payable_amount_post_tax` decimal(20,2) NOT NULL,\n  `currency_code` char(3) NOT NULL,\n  `created_at` datetime NOT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(255) DEFAULT NULL,\n  PRIMARY KEY (`payment_group_payment_account_detail_id`),\n  KEY `fk_pgpad_payment_group_payment_account` (`payment_group_payment_account_id`),\n  KEY `fk_pgpad_wacpat` (`worksheet_account_contract_payable_after_tax_id`),\n  KEY `fk_pgpad_account` (`account_id`),\n  KEY `fk_pgpad_contract` (`contract_id`),\n  CONSTRAINT `fk_pgpad_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_pgpad_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_pgpad_payment_group_payment_account` FOREIGN KEY (`payment_group_payment_account_id`) REFERENCES `payment_group_payment_account` (`payment_group_payment_account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_pgpad_wacpat` FOREIGN KEY (`worksheet_account_contract_payable_after_tax_id`) REFERENCES `worksheet_account_contract_payable_after_tax` (`worksheet_account_contract_payable_after_tax_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "payment_group_payment_batch",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "batch_num",
          "type": "tinyint",
          "nullable": false,
          "default": "1"
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "payment_group_payment_batch_id",
          "type": "bigint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "payment_group_payment_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "payoneer_program_id",
          "type": "int unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (payment_group_payment_batch_id) USING BTREE",
          "table": "payment_group_payment_batch",
          "columns": [
            "payment_group_payment_batch_id"
          ]
        },
        {
          "name": "fk_payment_batch_payment_group_payment",
          "def": "KEY fk_payment_batch_payment_group_payment (payment_group_payment_id) USING BTREE",
          "table": "payment_group_payment_batch",
          "columns": [
            "payment_group_payment_id"
          ]
        },
        {
          "name": "fk_payment_batch_reference_payoneer_program",
          "def": "KEY fk_payment_batch_reference_payoneer_program (payoneer_program_id) USING BTREE",
          "table": "payment_group_payment_batch",
          "columns": [
            "payoneer_program_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (payment_group_payment_batch_id)",
          "table": "payment_group_payment_batch",
          "columns": [
            "payment_group_payment_batch_id"
          ]
        },
        {
          "name": "fk_payment_batch_payment_group_payment",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (payment_group_payment_id) REFERENCES payment_group_payment (payment_group_payment_id)",
          "table": "payment_group_payment_batch",
          "referenced_table": "payment_group_payment",
          "columns": [
            "payment_group_payment_id"
          ],
          "referenced_columns": [
            "payment_group_payment_id"
          ]
        },
        {
          "name": "fk_payment_batch_reference_payoneer_program",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (payoneer_program_id) REFERENCES reference_payoneer_program (payoneer_program_id)",
          "table": "payment_group_payment_batch",
          "referenced_table": "reference_payoneer_program",
          "columns": [
            "payoneer_program_id"
          ],
          "referenced_columns": [
            "payoneer_program_id"
          ]
        }
      ],
      "def": "CREATE TABLE `payment_group_payment_batch` (\n  `payment_group_payment_batch_id` bigint unsigned NOT NULL AUTO_INCREMENT,\n  `payment_group_payment_id` mediumint unsigned NOT NULL,\n  `payoneer_program_id` int unsigned NOT NULL,\n  `batch_num` tinyint NOT NULL DEFAULT '1',\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`payment_group_payment_batch_id`),\n  KEY `fk_payment_batch_payment_group_payment` (`payment_group_payment_id`),\n  KEY `fk_payment_batch_reference_payoneer_program` (`payoneer_program_id`),\n  CONSTRAINT `fk_payment_batch_payment_group_payment` FOREIGN KEY (`payment_group_payment_id`) REFERENCES `payment_group_payment` (`payment_group_payment_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_payment_batch_reference_payoneer_program` FOREIGN KEY (`payoneer_program_id`) REFERENCES `reference_payoneer_program` (`payoneer_program_id`) ON DELETE RESTRICT ON UPDATE RESTRICT\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "payment_group_payment_batch_account",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "payment_group_payment_account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "payment_group_payment_batch_account_id",
          "type": "bigint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "payment_group_payment_batch_id",
          "type": "bigint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (payment_group_payment_batch_account_id) USING BTREE",
          "table": "payment_group_payment_batch_account",
          "columns": [
            "payment_group_payment_batch_account_id"
          ]
        },
        {
          "name": "fk_payment_batch_account_payment_group_payment_batch",
          "def": "KEY fk_payment_batch_account_payment_group_payment_batch (payment_group_payment_batch_id) USING BTREE",
          "table": "payment_group_payment_batch_account",
          "columns": [
            "payment_group_payment_batch_id"
          ]
        },
        {
          "name": "fk_payment_group_payment_account",
          "def": "KEY fk_payment_group_payment_account (payment_group_payment_account_id) USING BTREE",
          "table": "payment_group_payment_batch_account",
          "columns": [
            "payment_group_payment_account_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (payment_group_payment_batch_account_id)",
          "table": "payment_group_payment_batch_account",
          "columns": [
            "payment_group_payment_batch_account_id"
          ]
        },
        {
          "name": "fk_payment_batch_account_payment_group_payment_batch",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (payment_group_payment_batch_id) REFERENCES payment_group_payment_batch (payment_group_payment_batch_id)",
          "table": "payment_group_payment_batch_account",
          "referenced_table": "payment_group_payment_batch",
          "columns": [
            "payment_group_payment_batch_id"
          ],
          "referenced_columns": [
            "payment_group_payment_batch_id"
          ]
        },
        {
          "name": "fk_payment_group_payment_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (payment_group_payment_account_id) REFERENCES payment_group_payment_account (payment_group_payment_account_id)",
          "table": "payment_group_payment_batch_account",
          "referenced_table": "payment_group_payment_account",
          "columns": [
            "payment_group_payment_account_id"
          ],
          "referenced_columns": [
            "payment_group_payment_account_id"
          ]
        }
      ],
      "def": "CREATE TABLE `payment_group_payment_batch_account` (\n  `payment_group_payment_batch_account_id` bigint unsigned NOT NULL AUTO_INCREMENT,\n  `payment_group_payment_account_id` mediumint unsigned NOT NULL,\n  `payment_group_payment_batch_id` bigint unsigned NOT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`payment_group_payment_batch_account_id`),\n  KEY `fk_payment_group_payment_account` (`payment_group_payment_account_id`),\n  KEY `fk_payment_batch_account_payment_group_payment_batch` (`payment_group_payment_batch_id`),\n  CONSTRAINT `fk_payment_batch_account_payment_group_payment_batch` FOREIGN KEY (`payment_group_payment_batch_id`) REFERENCES `payment_group_payment_batch` (`payment_group_payment_batch_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_payment_group_payment_account` FOREIGN KEY (`payment_group_payment_account_id`) REFERENCES `payment_group_payment_account` (`payment_group_payment_account_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "payment_hold",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "is_on_hold",
          "type": "tinyint(1)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "payment_hold_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "reason",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "start_date",
          "type": "date",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (payment_hold_id) USING BTREE",
          "table": "payment_hold",
          "columns": [
            "payment_hold_id"
          ]
        },
        {
          "name": "uidx_account_id",
          "def": "UNIQUE KEY uidx_account_id (account_id) USING BTREE",
          "table": "payment_hold",
          "columns": [
            "account_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (payment_hold_id)",
          "table": "payment_hold",
          "columns": [
            "payment_hold_id"
          ]
        },
        {
          "name": "fk_account_payment_hold",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "payment_hold",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "uidx_account_id",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_account_id (account_id)",
          "table": "payment_hold",
          "columns": [
            "account_id"
          ]
        }
      ],
      "triggers": [
        {
          "name": "after_update_payment_hold",
          "def": "CREATE TRIGGER after_update_payment_hold AFTER UPDATE ON payment_hold\nFOR EACH ROW\nBEGIN\n    INSERT INTO `payment_hold_history`(\n        `payment_hold_id`,\n        `account_id`,\n        `is_on_hold`,\n        `start_date`,\n        `end_date`,\n        `reason`,\n        `created_by`,\n        `created_at`,\n        `last_modified_by`,\n        `last_modified`\n    ) VALUES (\n        old.payment_hold_id,\n        old.account_id,\n        old.is_on_hold,\n        old.start_date,\n        new.start_date,\n        old.reason,\n        old.created_by,\n        old.created_at,\n        old.last_modified_by,\n        old.last_modified\n    );\nEND"
        }
      ],
      "def": "CREATE TABLE `payment_hold` (\n  `payment_hold_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `account_id` mediumint unsigned NOT NULL,\n  `is_on_hold` tinyint(1) NOT NULL,\n  `start_date` date NOT NULL,\n  `reason` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`payment_hold_id`),\n  UNIQUE KEY `uidx_account_id` (`account_id`),\n  CONSTRAINT `fk_account_payment_hold` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "payment_hold_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "end_date",
          "type": "date",
          "nullable": true
        },
        {
          "name": "is_on_hold",
          "type": "tinyint(1)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "payment_hold_history_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "payment_hold_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "reason",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "start_date",
          "type": "date",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (payment_hold_history_id) USING BTREE",
          "table": "payment_hold_history",
          "columns": [
            "payment_hold_history_id"
          ]
        },
        {
          "name": "fk_account_payment_hold_history",
          "def": "KEY fk_account_payment_hold_history (account_id) USING BTREE",
          "table": "payment_hold_history",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_payment_hold_payment_hold_history",
          "def": "KEY fk_payment_hold_payment_hold_history (payment_hold_id) USING BTREE",
          "table": "payment_hold_history",
          "columns": [
            "payment_hold_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (payment_hold_history_id)",
          "table": "payment_hold_history",
          "columns": [
            "payment_hold_history_id"
          ]
        },
        {
          "name": "fk_account_payment_hold_history",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "payment_hold_history",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_payment_hold_payment_hold_history",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (payment_hold_id) REFERENCES payment_hold (payment_hold_id)",
          "table": "payment_hold_history",
          "referenced_table": "payment_hold",
          "columns": [
            "payment_hold_id"
          ],
          "referenced_columns": [
            "payment_hold_id"
          ]
        }
      ],
      "def": "CREATE TABLE `payment_hold_history` (\n  `payment_hold_history_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `payment_hold_id` mediumint unsigned NOT NULL,\n  `account_id` mediumint unsigned NOT NULL,\n  `is_on_hold` tinyint(1) NOT NULL,\n  `start_date` date NOT NULL,\n  `end_date` date DEFAULT NULL,\n  `reason` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`payment_hold_history_id`),\n  KEY `fk_payment_hold_payment_hold_history` (`payment_hold_id`),\n  KEY `fk_account_payment_hold_history` (`account_id`),\n  CONSTRAINT `fk_account_payment_hold_history` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_payment_hold_payment_hold_history` FOREIGN KEY (`payment_hold_id`) REFERENCES `payment_hold` (`payment_hold_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "payment_minimum",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "check_amount",
          "type": "decimal(6,2)",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "payment_minimum_id",
          "type": "tinyint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "western_union_amount",
          "type": "decimal(6,2)",
          "nullable": true
        },
        {
          "name": "wire_transfer_amount",
          "type": "decimal(6,2)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (payment_minimum_id) USING BTREE",
          "table": "payment_minimum",
          "columns": [
            "payment_minimum_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (payment_minimum_id)",
          "table": "payment_minimum",
          "columns": [
            "payment_minimum_id"
          ]
        }
      ],
      "def": "CREATE TABLE `payment_minimum` (\n  `payment_minimum_id` tinyint unsigned NOT NULL AUTO_INCREMENT,\n  `currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `check_amount` decimal(6,2) NOT NULL,\n  `wire_transfer_amount` decimal(6,2) NOT NULL,\n  `western_union_amount` decimal(6,2) DEFAULT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`payment_minimum_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "reference_adjustment_type",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "oa_category_name",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "reference_adjustment_type_id",
          "type": "tinyint unsigned",
          "nullable": false
        },
        {
          "name": "type_name",
          "type": "varchar(255)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (reference_adjustment_type_id) USING BTREE",
          "table": "reference_adjustment_type",
          "columns": [
            "reference_adjustment_type_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (reference_adjustment_type_id)",
          "table": "reference_adjustment_type",
          "columns": [
            "reference_adjustment_type_id"
          ]
        }
      ],
      "def": "CREATE TABLE `reference_adjustment_type` (\n  `reference_adjustment_type_id` tinyint unsigned NOT NULL,\n  `type_name` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `oa_category_name` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  PRIMARY KEY (`reference_adjustment_type_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "reference_advance_payment_method",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "is_internal",
          "type": "tinyint(1)",
          "nullable": true,
          "default": "0"
        },
        {
          "name": "payment_method",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "reference_advance_payment_method_id",
          "type": "smallint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (reference_advance_payment_method_id) USING BTREE",
          "table": "reference_advance_payment_method",
          "columns": [
            "reference_advance_payment_method_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (reference_advance_payment_method_id)",
          "table": "reference_advance_payment_method",
          "columns": [
            "reference_advance_payment_method_id"
          ]
        }
      ],
      "def": "CREATE TABLE `reference_advance_payment_method` (\n  `reference_advance_payment_method_id` smallint unsigned NOT NULL AUTO_INCREMENT,\n  `payment_method` varchar(255) NOT NULL,\n  `is_internal` tinyint(1) DEFAULT '0',\n  PRIMARY KEY (`reference_advance_payment_method_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "reference_agreement_type",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "agreement_type",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "reference_agreement_type_id",
          "type": "tinyint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (reference_agreement_type_id) USING BTREE",
          "table": "reference_agreement_type",
          "columns": [
            "reference_agreement_type_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (reference_agreement_type_id)",
          "table": "reference_agreement_type",
          "columns": [
            "reference_agreement_type_id"
          ]
        }
      ],
      "def": "CREATE TABLE `reference_agreement_type` (\n  `reference_agreement_type_id` tinyint unsigned NOT NULL AUTO_INCREMENT,\n  `agreement_type` varchar(180) NOT NULL,\n  PRIMARY KEY (`reference_agreement_type_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "reference_external_source",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "external_source",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "external_source_id",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "parent_table_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "parent_table_name",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "reference_external_source_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (reference_external_source_id) USING BTREE",
          "table": "reference_external_source",
          "columns": [
            "reference_external_source_id"
          ]
        },
        {
          "name": "composite_external_source",
          "def": "KEY composite_external_source (external_source_id, external_source, parent_table_name) USING BTREE",
          "table": "reference_external_source",
          "columns": [
            "external_source_id",
            "external_source",
            "parent_table_name"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (reference_external_source_id)",
          "table": "reference_external_source",
          "columns": [
            "reference_external_source_id"
          ]
        }
      ],
      "def": "CREATE TABLE `reference_external_source` (\n  `reference_external_source_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `parent_table_id` mediumint unsigned NOT NULL,\n  `parent_table_name` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `external_source_id` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `external_source` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`reference_external_source_id`),\n  KEY `composite_external_source` (`external_source_id`,`external_source`,`parent_table_name`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "reference_flowthrough_calculation",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "flowthrough_calculation",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "flowthrough_calculation_example",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "flowthrough_calculation_example_summary",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "flowthrough_calculation_name",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "reference_flowthrough_calculation_id",
          "type": "tinyint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (reference_flowthrough_calculation_id) USING BTREE",
          "table": "reference_flowthrough_calculation",
          "columns": [
            "reference_flowthrough_calculation_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (reference_flowthrough_calculation_id)",
          "table": "reference_flowthrough_calculation",
          "columns": [
            "reference_flowthrough_calculation_id"
          ]
        }
      ],
      "def": "CREATE TABLE `reference_flowthrough_calculation` (\n  `reference_flowthrough_calculation_id` tinyint unsigned NOT NULL AUTO_INCREMENT,\n  `flowthrough_calculation_name` varchar(180) NOT NULL,\n  `flowthrough_calculation` varchar(180) NOT NULL,\n  `flowthrough_calculation_example` varchar(180) NOT NULL,\n  `flowthrough_calculation_example_summary` varchar(180) NOT NULL,\n  PRIMARY KEY (`reference_flowthrough_calculation_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci"
    },
    {
      "name": "reference_mechanical_rate",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "base_rate",
          "type": "decimal(10,4)",
          "nullable": false
        },
        {
          "name": "country_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "effective_start_date",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "minute_rate",
          "type": "decimal(10,4)",
          "nullable": false
        },
        {
          "name": "reference_mechanical_rate_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "ringtone_rate",
          "type": "decimal(10,4)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (reference_mechanical_rate_id) USING BTREE",
          "table": "reference_mechanical_rate",
          "columns": [
            "reference_mechanical_rate_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (reference_mechanical_rate_id)",
          "table": "reference_mechanical_rate",
          "columns": [
            "reference_mechanical_rate_id"
          ]
        }
      ],
      "def": "CREATE TABLE `reference_mechanical_rate` (\n  `reference_mechanical_rate_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `country_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `base_rate` decimal(10,4) NOT NULL,\n  `minute_rate` decimal(10,4) NOT NULL,\n  `ringtone_rate` decimal(10,4) NOT NULL,\n  `effective_start_date` datetime NOT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`reference_mechanical_rate_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "reference_payable_detail_type",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "detail_group_name",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "detail_type_name",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "reference_payable_detail_type_id",
          "type": "tinyint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (reference_payable_detail_type_id) USING BTREE",
          "table": "reference_payable_detail_type",
          "columns": [
            "reference_payable_detail_type_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (reference_payable_detail_type_id)",
          "table": "reference_payable_detail_type",
          "columns": [
            "reference_payable_detail_type_id"
          ]
        }
      ],
      "def": "CREATE TABLE `reference_payable_detail_type` (\n  `reference_payable_detail_type_id` tinyint unsigned NOT NULL,\n  `detail_type_name` varchar(255) NOT NULL,\n  `detail_group_name` varchar(255) NOT NULL,\n  PRIMARY KEY (`reference_payable_detail_type_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "reference_payment_entity",
      "type": "BASE TABLE",
      "comment": "AKA \"paid_by\"; meant to replace signing_entity table",
      "columns": [
        {
          "name": "country_of_tax_reporting",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "payment_entity_name",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "reference_payment_entity_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (reference_payment_entity_id) USING BTREE",
          "table": "reference_payment_entity",
          "columns": [
            "reference_payment_entity_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (reference_payment_entity_id)",
          "table": "reference_payment_entity",
          "columns": [
            "reference_payment_entity_id"
          ]
        }
      ],
      "def": "CREATE TABLE `reference_payment_entity` (\n  `reference_payment_entity_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `payment_entity_name` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `country_of_tax_reporting` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`reference_payment_entity_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='AKA \"paid_by\"; meant to replace signing_entity table'"
    },
    {
      "name": "reference_payment_type",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "is_internal",
          "type": "tinyint(1)",
          "nullable": true,
          "default": "0"
        },
        {
          "name": "notes",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "payment_service",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "payment_type",
          "type": "enum('advance','bulk_payouts')",
          "nullable": false
        },
        {
          "name": "reference_payment_type_id",
          "type": "smallint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (reference_payment_type_id) USING BTREE",
          "table": "reference_payment_type",
          "columns": [
            "reference_payment_type_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (reference_payment_type_id)",
          "table": "reference_payment_type",
          "columns": [
            "reference_payment_type_id"
          ]
        }
      ],
      "def": "CREATE TABLE `reference_payment_type` (\n  `reference_payment_type_id` smallint unsigned NOT NULL AUTO_INCREMENT,\n  `payment_type` enum('advance','bulk_payouts') NOT NULL,\n  `payment_service` varchar(255) NOT NULL,\n  `is_internal` tinyint(1) DEFAULT '0',\n  `notes` varchar(255) DEFAULT NULL,\n  PRIMARY KEY (`reference_payment_type_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "reference_payoneer_program",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "funding_currency",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "payoneer_program_id",
          "type": "int unsigned",
          "nullable": false
        },
        {
          "name": "payoneer_program_name",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "reference_payment_type_id",
          "type": "smallint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (payoneer_program_id) USING BTREE",
          "table": "reference_payoneer_program",
          "columns": [
            "payoneer_program_id"
          ]
        },
        {
          "name": "fk_reference_payoneer_program_reference_payment_type_id",
          "def": "KEY fk_reference_payoneer_program_reference_payment_type_id (reference_payment_type_id) USING BTREE",
          "table": "reference_payoneer_program",
          "columns": [
            "reference_payment_type_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (payoneer_program_id)",
          "table": "reference_payoneer_program",
          "columns": [
            "payoneer_program_id"
          ]
        },
        {
          "name": "fk_reference_payoneer_program_reference_payment_type_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (reference_payment_type_id) REFERENCES reference_payment_type (reference_payment_type_id)",
          "table": "reference_payoneer_program",
          "referenced_table": "reference_payment_type",
          "columns": [
            "reference_payment_type_id"
          ],
          "referenced_columns": [
            "reference_payment_type_id"
          ]
        }
      ],
      "def": "CREATE TABLE `reference_payoneer_program` (\n  `payoneer_program_id` int unsigned NOT NULL,\n  `payoneer_program_name` varchar(255) NOT NULL,\n  `funding_currency` char(3) NOT NULL,\n  `reference_payment_type_id` smallint unsigned NOT NULL,\n  PRIMARY KEY (`payoneer_program_id`),\n  KEY `fk_reference_payoneer_program_reference_payment_type_id` (`reference_payment_type_id`),\n  CONSTRAINT `fk_reference_payoneer_program_reference_payment_type_id` FOREIGN KEY (`reference_payment_type_id`) REFERENCES `reference_payment_type` (`reference_payment_type_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "reference_sap_profit_center",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "business_group",
          "type": "varchar(3)",
          "nullable": false,
          "default": "ORC"
        },
        {
          "name": "company_code",
          "type": "varchar(8)",
          "nullable": false
        },
        {
          "name": "profit_center",
          "type": "varchar(10)",
          "nullable": false
        },
        {
          "name": "reference_sap_profit_center_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (reference_sap_profit_center_id) USING BTREE",
          "table": "reference_sap_profit_center",
          "columns": [
            "reference_sap_profit_center_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (reference_sap_profit_center_id)",
          "table": "reference_sap_profit_center",
          "columns": [
            "reference_sap_profit_center_id"
          ]
        }
      ],
      "def": "CREATE TABLE `reference_sap_profit_center` (\n  `reference_sap_profit_center_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `profit_center` varchar(10) COLLATE utf8mb4_general_ci NOT NULL,\n  `company_code` varchar(8) COLLATE utf8mb4_general_ci NOT NULL,\n  `business_group` varchar(3) COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'ORC',\n  PRIMARY KEY (`reference_sap_profit_center_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "reference_signing_entity",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "address",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "company_code",
          "type": "varchar(8)",
          "nullable": false
        },
        {
          "name": "company_registration_number",
          "type": "varchar(30)",
          "nullable": true
        },
        {
          "name": "legal_name",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "reference_payment_entity_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "reference_sap_profit_center_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "reference_signing_entity_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "tax_entity_company_code",
          "type": "varchar(8)",
          "nullable": true
        },
        {
          "name": "vat_number",
          "type": "varchar(30)",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (reference_signing_entity_id) USING BTREE",
          "table": "reference_signing_entity",
          "columns": [
            "reference_signing_entity_id"
          ]
        },
        {
          "name": "fk_reference_sap_profit_center_signing_entity",
          "def": "KEY fk_reference_sap_profit_center_signing_entity (reference_sap_profit_center_id) USING BTREE",
          "table": "reference_signing_entity",
          "columns": [
            "reference_sap_profit_center_id"
          ]
        },
        {
          "name": "fk_reference_signing_entity_payment_entity",
          "def": "KEY fk_reference_signing_entity_payment_entity (reference_payment_entity_id) USING BTREE",
          "table": "reference_signing_entity",
          "columns": [
            "reference_payment_entity_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (reference_signing_entity_id)",
          "table": "reference_signing_entity",
          "columns": [
            "reference_signing_entity_id"
          ]
        },
        {
          "name": "fk_reference_sap_profit_center_signing_entity",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (reference_sap_profit_center_id) REFERENCES reference_sap_profit_center (reference_sap_profit_center_id)",
          "table": "reference_signing_entity",
          "referenced_table": "reference_sap_profit_center",
          "columns": [
            "reference_sap_profit_center_id"
          ],
          "referenced_columns": [
            "reference_sap_profit_center_id"
          ]
        },
        {
          "name": "fk_reference_signing_entity_payment_entity",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (reference_payment_entity_id) REFERENCES reference_payment_entity (reference_payment_entity_id)",
          "table": "reference_signing_entity",
          "referenced_table": "reference_payment_entity",
          "columns": [
            "reference_payment_entity_id"
          ],
          "referenced_columns": [
            "reference_payment_entity_id"
          ]
        }
      ],
      "def": "CREATE TABLE `reference_signing_entity` (\n  `reference_signing_entity_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `reference_payment_entity_id` mediumint unsigned NOT NULL,\n  `company_code` varchar(8) COLLATE utf8mb4_general_ci NOT NULL,\n  `tax_entity_company_code` varchar(8) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `legal_name` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `vat_number` varchar(30) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `company_registration_number` varchar(30) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `address` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `reference_sap_profit_center_id` mediumint unsigned NOT NULL,\n  PRIMARY KEY (`reference_signing_entity_id`),\n  KEY `fk_reference_signing_entity_payment_entity` (`reference_payment_entity_id`),\n  KEY `fk_reference_sap_profit_center_signing_entity` (`reference_sap_profit_center_id`),\n  CONSTRAINT `fk_reference_sap_profit_center_signing_entity` FOREIGN KEY (`reference_sap_profit_center_id`) REFERENCES `reference_sap_profit_center` (`reference_sap_profit_center_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_reference_signing_entity_payment_entity` FOREIGN KEY (`reference_payment_entity_id`) REFERENCES `reference_payment_entity` (`reference_payment_entity_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "reference_tax_withholding",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "country_of_tax_residence",
          "type": "char(3)",
          "nullable": true
        },
        {
          "name": "country_of_withholding",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "is_resource_provisioned",
          "type": "tinyint(1)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "reference_tax_withholding_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "tax_rate",
          "type": "decimal(5,2)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (reference_tax_withholding_id) USING BTREE",
          "table": "reference_tax_withholding",
          "columns": [
            "reference_tax_withholding_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (reference_tax_withholding_id)",
          "table": "reference_tax_withholding",
          "columns": [
            "reference_tax_withholding_id"
          ]
        }
      ],
      "def": "CREATE TABLE `reference_tax_withholding` (\n  `reference_tax_withholding_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `country_of_withholding` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `country_of_tax_residence` char(3) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `tax_rate` decimal(5,2) NOT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `is_resource_provisioned` tinyint(1) DEFAULT NULL,\n  PRIMARY KEY (`reference_tax_withholding_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "reference_transaction_type",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "reference_transaction_type_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "transaction_type_code",
          "type": "varchar(4)",
          "nullable": false
        },
        {
          "name": "transaction_type_name",
          "type": "varchar(180)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (reference_transaction_type_id) USING BTREE",
          "table": "reference_transaction_type",
          "columns": [
            "reference_transaction_type_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (reference_transaction_type_id)",
          "table": "reference_transaction_type",
          "columns": [
            "reference_transaction_type_id"
          ]
        }
      ],
      "def": "CREATE TABLE `reference_transaction_type` (\n  `reference_transaction_type_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `transaction_type_name` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `transaction_type_code` varchar(4) COLLATE utf8mb4_general_ci NOT NULL,\n  PRIMARY KEY (`reference_transaction_type_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "reference_transaction_type_group",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "reference_transaction_type_group_id",
          "type": "tinyint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "transaction_type_group_name",
          "type": "varchar(180)",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (reference_transaction_type_group_id) USING BTREE",
          "table": "reference_transaction_type_group",
          "columns": [
            "reference_transaction_type_group_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (reference_transaction_type_group_id)",
          "table": "reference_transaction_type_group",
          "columns": [
            "reference_transaction_type_group_id"
          ]
        }
      ],
      "def": "CREATE TABLE `reference_transaction_type_group` (\n  `reference_transaction_type_group_id` tinyint unsigned NOT NULL AUTO_INCREMENT,\n  `transaction_type_group_name` varchar(180) DEFAULT NULL,\n  PRIMARY KEY (`reference_transaction_type_group_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "reference_transaction_type_group_transaction_type",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "reference_transaction_type_group_admin",
          "type": "enum('contract_admin','workstation','tax_admin','contract_mechanical_admin','presentational')",
          "nullable": true
        },
        {
          "name": "reference_transaction_type_group_id",
          "type": "tinyint unsigned",
          "nullable": false
        },
        {
          "name": "reference_transaction_type_group_transaction_type_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "reference_transaction_type_id",
          "type": "mediumint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (reference_transaction_type_group_transaction_type_id) USING BTREE",
          "table": "reference_transaction_type_group_transaction_type",
          "columns": [
            "reference_transaction_type_group_transaction_type_id"
          ]
        },
        {
          "name": "idx_reference_transaction_type_group_id",
          "def": "KEY idx_reference_transaction_type_group_id (reference_transaction_type_group_id) USING BTREE",
          "table": "reference_transaction_type_group_transaction_type",
          "columns": [
            "reference_transaction_type_group_id"
          ]
        },
        {
          "name": "idx_reference_transaction_type_id",
          "def": "KEY idx_reference_transaction_type_id (reference_transaction_type_id) USING BTREE",
          "table": "reference_transaction_type_group_transaction_type",
          "columns": [
            "reference_transaction_type_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (reference_transaction_type_group_transaction_type_id)",
          "table": "reference_transaction_type_group_transaction_type",
          "columns": [
            "reference_transaction_type_group_transaction_type_id"
          ]
        },
        {
          "name": "fk_type_group_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (reference_transaction_type_group_id) REFERENCES reference_transaction_type_group (reference_transaction_type_group_id)",
          "table": "reference_transaction_type_group_transaction_type",
          "referenced_table": "reference_transaction_type_group",
          "columns": [
            "reference_transaction_type_group_id"
          ],
          "referenced_columns": [
            "reference_transaction_type_group_id"
          ]
        },
        {
          "name": "fk_type_transaction_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (reference_transaction_type_id) REFERENCES reference_transaction_type (reference_transaction_type_id)",
          "table": "reference_transaction_type_group_transaction_type",
          "referenced_table": "reference_transaction_type",
          "columns": [
            "reference_transaction_type_id"
          ],
          "referenced_columns": [
            "reference_transaction_type_id"
          ]
        }
      ],
      "def": "CREATE TABLE `reference_transaction_type_group_transaction_type` (\n  `reference_transaction_type_group_transaction_type_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `reference_transaction_type_group_id` tinyint unsigned NOT NULL,\n  `reference_transaction_type_id` mediumint unsigned NOT NULL,\n  `reference_transaction_type_group_admin` enum('contract_admin','workstation','tax_admin','contract_mechanical_admin','presentational') DEFAULT NULL,\n  PRIMARY KEY (`reference_transaction_type_group_transaction_type_id`),\n  KEY `idx_reference_transaction_type_group_id` (`reference_transaction_type_group_id`),\n  KEY `idx_reference_transaction_type_id` (`reference_transaction_type_id`),\n  CONSTRAINT `fk_type_group_id` FOREIGN KEY (`reference_transaction_type_group_id`) REFERENCES `reference_transaction_type_group` (`reference_transaction_type_group_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_type_transaction_id` FOREIGN KEY (`reference_transaction_type_id`) REFERENCES `reference_transaction_type` (`reference_transaction_type_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "reference_vat_rate",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "country_of_tax_policy",
          "type": "char(3)",
          "nullable": true
        },
        {
          "name": "country_of_tax_residence",
          "type": "char(3)",
          "nullable": true
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "effective_date",
          "type": "date",
          "nullable": true
        },
        {
          "name": "is_sba_signed",
          "type": "tinyint(1)",
          "nullable": true
        },
        {
          "name": "is_tax_applicable",
          "type": "tinyint(1)",
          "nullable": true
        },
        {
          "name": "is_vat_registered_in_country_of_tax_policy",
          "type": "tinyint(1)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "reference_vat_rate_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "tax_rate",
          "type": "decimal(5,2)",
          "nullable": true
        },
        {
          "name": "transaction_type",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "vat_type",
          "type": "enum('client','supplier')",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (reference_vat_rate_id) USING BTREE",
          "table": "reference_vat_rate",
          "columns": [
            "reference_vat_rate_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (reference_vat_rate_id)",
          "table": "reference_vat_rate",
          "columns": [
            "reference_vat_rate_id"
          ]
        }
      ],
      "def": "CREATE TABLE `reference_vat_rate` (\n  `reference_vat_rate_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `vat_type` enum('client','supplier') COLLATE utf8mb4_general_ci NOT NULL,\n  `country_of_tax_residence` char(3) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `country_of_tax_policy` char(3) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `is_sba_signed` tinyint(1) DEFAULT NULL,\n  `is_tax_applicable` tinyint(1) DEFAULT NULL,\n  `is_vat_registered_in_country_of_tax_policy` tinyint(1) DEFAULT NULL,\n  `transaction_type` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `tax_rate` decimal(5,2) DEFAULT NULL,\n  `effective_date` date DEFAULT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`reference_vat_rate_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "reference_worksheet_flowthrough_error",
      "type": "BASE TABLE",
      "comment": "Reference table for worksheet_flowthrough error codes.",
      "columns": [
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false,
          "default": "CURRENT_TIMESTAMP",
          "extra_def": "DEFAULT_GENERATED"
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true,
          "comment": "When the error was deprecated."
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true,
          "comment": "Who deprecated the error."
        },
        {
          "name": "description",
          "type": "varchar(255)",
          "nullable": false,
          "comment": "Description of the error. Example: Account ID not found."
        },
        {
          "name": "error_code",
          "type": "varchar(50)",
          "nullable": false,
          "comment": "The error code. Example: ACCOUNT_ID_NOT_FOUND."
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false,
          "default": "CURRENT_TIMESTAMP",
          "extra_def": "DEFAULT_GENERATED on update CURRENT_TIMESTAMP"
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (error_code) USING BTREE",
          "table": "reference_worksheet_flowthrough_error",
          "columns": [
            "error_code"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (error_code)",
          "table": "reference_worksheet_flowthrough_error",
          "columns": [
            "error_code"
          ]
        }
      ],
      "def": "CREATE TABLE `reference_worksheet_flowthrough_error` (\n  `error_code` varchar(50) NOT NULL COMMENT 'The error code. Example: ACCOUNT_ID_NOT_FOUND.',\n  `description` varchar(255) NOT NULL COMMENT 'Description of the error. Example: Account ID not found.',\n  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,\n  `created_by` varchar(180) NOT NULL,\n  `last_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n  `last_modified_by` varchar(180) NOT NULL,\n  `deleted_at` datetime DEFAULT NULL COMMENT 'When the error was deprecated.',\n  `deleted_by` varchar(180) DEFAULT NULL COMMENT 'Who deprecated the error.',\n  PRIMARY KEY (`error_code`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='Reference table for worksheet_flowthrough error codes.'"
    },
    {
      "name": "report_custom",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "dimension_column",
          "type": "enum('territory','statement_period','financial_detail')",
          "nullable": false
        },
        {
          "name": "dimension_row",
          "type": "enum('product','statement_period','service','recording','territory','product_artist','collection_society','transaction_type','track','imprint','subaccount')",
          "nullable": false
        },
        {
          "name": "file_location",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "file_type",
          "type": "enum('csv','xls','txt')",
          "nullable": false,
          "default": "csv"
        },
        {
          "name": "number_format",
          "type": "enum('us','eu')",
          "nullable": false,
          "default": "us"
        },
        {
          "name": "report_custom_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "report_custom_status",
          "type": "enum('in_progress','complete','error')",
          "nullable": false,
          "default": "in_progress"
        },
        {
          "name": "revenue_type",
          "type": "enum('distribution','neighbouring_rights')",
          "nullable": false,
          "default": "distribution"
        },
        {
          "name": "statement_period_ids",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "subaccount_id",
          "type": "int",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (report_custom_id) USING BTREE",
          "table": "report_custom",
          "columns": [
            "report_custom_id"
          ]
        },
        {
          "name": "fk_report_custom_account",
          "def": "KEY fk_report_custom_account (account_id) USING BTREE",
          "table": "report_custom",
          "columns": [
            "account_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (report_custom_id)",
          "table": "report_custom",
          "columns": [
            "report_custom_id"
          ]
        },
        {
          "name": "fk_report_custom_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "report_custom",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        }
      ],
      "def": "CREATE TABLE `report_custom` (\n  `report_custom_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `account_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned DEFAULT NULL,\n  `subaccount_id` int DEFAULT NULL,\n  `statement_period_ids` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `revenue_type` enum('distribution','neighbouring_rights') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'distribution',\n  `report_custom_status` enum('in_progress','complete','error') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'in_progress',\n  `dimension_row` enum('product','statement_period','service','recording','territory','product_artist','collection_society','transaction_type','track','imprint','subaccount') COLLATE utf8mb4_general_ci NOT NULL,\n  `dimension_column` enum('territory','statement_period','financial_detail') COLLATE utf8mb4_general_ci NOT NULL,\n  `number_format` enum('us','eu') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'us',\n  `file_type` enum('csv','xls','txt') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'csv',\n  `file_location` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  PRIMARY KEY (`report_custom_id`),\n  KEY `fk_report_custom_account` (`account_id`),\n  CONSTRAINT `fk_report_custom_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE RESTRICT ON UPDATE RESTRICT\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "report_payment",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "report_export_url",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "report_payment_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "report_type",
          "type": "enum('approval')",
          "nullable": false
        },
        {
          "name": "target_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "target_type",
          "type": "varchar(64)",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (report_payment_id) USING BTREE",
          "table": "report_payment",
          "columns": [
            "report_payment_id"
          ]
        },
        {
          "name": "uidx_report_payment",
          "def": "UNIQUE KEY uidx_report_payment (target_type, target_id, report_type) USING BTREE",
          "table": "report_payment",
          "columns": [
            "target_type",
            "target_id",
            "report_type"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (report_payment_id)",
          "table": "report_payment",
          "columns": [
            "report_payment_id"
          ]
        },
        {
          "name": "uidx_report_payment",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_report_payment (target_type, target_id, report_type)",
          "table": "report_payment",
          "columns": [
            "target_type",
            "target_id",
            "report_type"
          ]
        }
      ],
      "def": "CREATE TABLE `report_payment` (\n  `report_payment_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `target_type` varchar(64) DEFAULT NULL,\n  `target_id` mediumint unsigned NOT NULL,\n  `report_type` enum('approval') NOT NULL,\n  `report_export_url` varchar(180) NOT NULL,\n  `created_by` varchar(180) NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`report_payment_id`),\n  UNIQUE KEY `uidx_report_payment` (`target_type`,`target_id`,`report_type`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "report_payment_group_payment",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "payment_group_payment_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "report_export_url",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "report_payment_group_payment_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "report_type",
          "type": "varchar(32)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (report_payment_group_payment_id) USING BTREE",
          "table": "report_payment_group_payment",
          "columns": [
            "report_payment_group_payment_id"
          ]
        },
        {
          "name": "uidx_payment_group_payment_report",
          "def": "UNIQUE KEY uidx_payment_group_payment_report (payment_group_payment_id, report_type) USING BTREE",
          "table": "report_payment_group_payment",
          "columns": [
            "payment_group_payment_id",
            "report_type"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (report_payment_group_payment_id)",
          "table": "report_payment_group_payment",
          "columns": [
            "report_payment_group_payment_id"
          ]
        },
        {
          "name": "fk_report_payment_group_payment",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (payment_group_payment_id) REFERENCES payment_group_payment (payment_group_payment_id)",
          "table": "report_payment_group_payment",
          "referenced_table": "payment_group_payment",
          "columns": [
            "payment_group_payment_id"
          ],
          "referenced_columns": [
            "payment_group_payment_id"
          ]
        },
        {
          "name": "uidx_payment_group_payment_report",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_payment_group_payment_report (payment_group_payment_id, report_type)",
          "table": "report_payment_group_payment",
          "columns": [
            "payment_group_payment_id",
            "report_type"
          ]
        }
      ],
      "def": "CREATE TABLE `report_payment_group_payment` (\n  `report_payment_group_payment_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `payment_group_payment_id` mediumint unsigned NOT NULL,\n  `report_type` varchar(32) COLLATE utf8mb4_general_ci NOT NULL,\n  `report_export_url` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`report_payment_group_payment_id`),\n  UNIQUE KEY `uidx_payment_group_payment_report` (`payment_group_payment_id`,`report_type`),\n  CONSTRAINT `fk_report_payment_group_payment` FOREIGN KEY (`payment_group_payment_id`) REFERENCES `payment_group_payment` (`payment_group_payment_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "run_controller",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "contract_type",
          "type": "enum('distribution','legacy_distribution','neighbouring_rights')",
          "nullable": false,
          "default": "distribution"
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "run_controller_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "run_controller_name",
          "type": "varchar(255)",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (run_controller_id) USING BTREE",
          "table": "run_controller",
          "columns": [
            "run_controller_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (run_controller_id)",
          "table": "run_controller",
          "columns": [
            "run_controller_id"
          ]
        }
      ],
      "def": "CREATE TABLE `run_controller` (\n  `run_controller_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `run_controller_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `contract_type` enum('distribution','legacy_distribution','neighbouring_rights') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'distribution',\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `deleted_by` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  PRIMARY KEY (`run_controller_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "run_controller_contract",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "audit_id",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "run_controller_contract_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "run_controller_id",
          "type": "mediumint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (run_controller_contract_id) USING BTREE",
          "table": "run_controller_contract",
          "columns": [
            "run_controller_contract_id"
          ]
        },
        {
          "name": "fk_run_controller_contract_run_controller",
          "def": "KEY fk_run_controller_contract_run_controller (run_controller_id) USING BTREE",
          "table": "run_controller_contract",
          "columns": [
            "run_controller_id"
          ]
        },
        {
          "name": "run_controller_contract_contract_unique",
          "def": "UNIQUE KEY run_controller_contract_contract_unique (contract_id) USING BTREE",
          "table": "run_controller_contract",
          "columns": [
            "contract_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (run_controller_contract_id)",
          "table": "run_controller_contract",
          "columns": [
            "run_controller_contract_id"
          ]
        },
        {
          "name": "fk_run_controller_contract_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "run_controller_contract",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_run_controller_contract_run_controller",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (run_controller_id) REFERENCES run_controller (run_controller_id)",
          "table": "run_controller_contract",
          "referenced_table": "run_controller",
          "columns": [
            "run_controller_id"
          ],
          "referenced_columns": [
            "run_controller_id"
          ]
        },
        {
          "name": "run_controller_contract_contract_unique",
          "type": "UNIQUE",
          "def": "UNIQUE KEY run_controller_contract_contract_unique (contract_id)",
          "table": "run_controller_contract",
          "columns": [
            "contract_id"
          ]
        }
      ],
      "triggers": [
        {
          "name": "after_update_run_controller_contract",
          "def": "CREATE TRIGGER after_update_run_controller_contract AFTER UPDATE ON run_controller_contract\nFOR EACH ROW\nBEGIN\n    INSERT INTO `run_controller_contract_history`(\n        `run_controller_contract_id`,\n        `run_controller_id`,\n        `contract_id`,\n        `created_by`,\n        `created_at`,\n        `last_modified_by`,\n        `last_modified`,\n        `audit_id`\n    ) VALUES (\n                 old.run_controller_contract_id,\n                 old.run_controller_id,\n                 old.contract_id,\n                 old.created_by,\n                 old.created_at,\n                 old.last_modified_by,\n                 old.last_modified,\n                 old.audit_id\n             );\n    END"
        }
      ],
      "def": "CREATE TABLE `run_controller_contract` (\n  `run_controller_contract_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `run_controller_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned NOT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `created_at` datetime DEFAULT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `last_modified` datetime DEFAULT NULL,\n  `audit_id` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  PRIMARY KEY (`run_controller_contract_id`),\n  UNIQUE KEY `run_controller_contract_contract_unique` (`contract_id`),\n  KEY `fk_run_controller_contract_run_controller` (`run_controller_id`),\n  CONSTRAINT `fk_run_controller_contract_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_run_controller_contract_run_controller` FOREIGN KEY (`run_controller_id`) REFERENCES `run_controller` (`run_controller_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "run_controller_contract_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "audit_id",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "run_controller_contract_history_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "run_controller_contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "run_controller_id",
          "type": "mediumint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (run_controller_contract_history_id) USING BTREE",
          "table": "run_controller_contract_history",
          "columns": [
            "run_controller_contract_history_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (run_controller_contract_history_id)",
          "table": "run_controller_contract_history",
          "columns": [
            "run_controller_contract_history_id"
          ]
        }
      ],
      "def": "CREATE TABLE `run_controller_contract_history` (\n  `run_controller_contract_history_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `run_controller_contract_id` mediumint unsigned NOT NULL,\n  `run_controller_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned NOT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `audit_id` varchar(255) DEFAULT NULL,\n  PRIMARY KEY (`run_controller_contract_history_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci"
    },
    {
      "name": "sales_file",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "accounting_period_id",
          "type": "smallint unsigned",
          "nullable": false
        },
        {
          "name": "amount_usd",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "file_name",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "main_url",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "row_count",
          "type": "int unsigned",
          "nullable": true
        },
        {
          "name": "sales_file_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (sales_file_id) USING BTREE",
          "table": "sales_file",
          "columns": [
            "sales_file_id"
          ]
        },
        {
          "name": "idx_acct_period_id",
          "def": "KEY idx_acct_period_id (accounting_period_id) USING BTREE",
          "table": "sales_file",
          "columns": [
            "accounting_period_id"
          ]
        },
        {
          "name": "uidx_main_url",
          "def": "UNIQUE KEY uidx_main_url (main_url) USING BTREE",
          "table": "sales_file",
          "columns": [
            "main_url"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (sales_file_id)",
          "table": "sales_file",
          "columns": [
            "sales_file_id"
          ]
        },
        {
          "name": "fk_sales_file_acct_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (accounting_period_id) REFERENCES accounting_period (accounting_period_id)",
          "table": "sales_file",
          "referenced_table": "accounting_period",
          "columns": [
            "accounting_period_id"
          ],
          "referenced_columns": [
            "accounting_period_id"
          ]
        },
        {
          "name": "uidx_main_url",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_main_url (main_url)",
          "table": "sales_file",
          "columns": [
            "main_url"
          ]
        }
      ],
      "def": "CREATE TABLE `sales_file` (\n  `sales_file_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `file_name` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `accounting_period_id` smallint unsigned NOT NULL,\n  `row_count` int unsigned DEFAULT NULL,\n  `main_url` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `amount_usd` decimal(20,2) DEFAULT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`sales_file_id`),\n  UNIQUE KEY `uidx_main_url` (`main_url`),\n  KEY `idx_acct_period_id` (`accounting_period_id`),\n  CONSTRAINT `fk_sales_file_acct_period` FOREIGN KEY (`accounting_period_id`) REFERENCES `accounting_period` (`accounting_period_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "schedule",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "conditions",
          "type": "json",
          "nullable": true
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "schedule_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "schedule_name",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "target_id",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "target_type",
          "type": "enum('contributor')",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (schedule_id) USING BTREE",
          "table": "schedule",
          "columns": [
            "schedule_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (schedule_id)",
          "table": "schedule",
          "columns": [
            "schedule_id"
          ]
        }
      ],
      "triggers": [
        {
          "name": "after_schedule_update",
          "def": "CREATE TRIGGER after_schedule_update AFTER UPDATE ON schedule\nFOR EACH ROW\nBEGIN\n    INSERT INTO `schedule_history`(\n        schedule_id,\n        schedule_name,\n        target_type,\n        target_id,\n        conditions,\n        created_by,\n        created_at,\n        last_modified_by,\n        last_modified\n    ) VALUES (\n        OLD.schedule_id,\n        OLD.schedule_name,\n        OLD.target_type,\n        OLD.target_id,\n        OLD.conditions,\n        OLD.created_by,\n        OLD.created_at,\n        OLD.last_modified_by,\n        OLD.last_modified\n    );\nEND"
        }
      ],
      "def": "CREATE TABLE `schedule` (\n  `schedule_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `schedule_name` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `target_type` enum('contributor') COLLATE utf8mb4_general_ci NOT NULL,\n  `target_id` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `conditions` json DEFAULT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`schedule_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "schedule_attachment",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "schedule_attachment_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "schedule_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "target_id",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "target_type",
          "type": "enum('contribution','contributor')",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (schedule_attachment_id) USING BTREE",
          "table": "schedule_attachment",
          "columns": [
            "schedule_attachment_id"
          ]
        },
        {
          "name": "fk_schedule_attachment_schedule",
          "def": "KEY fk_schedule_attachment_schedule (schedule_id) USING BTREE",
          "table": "schedule_attachment",
          "columns": [
            "schedule_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (schedule_attachment_id)",
          "table": "schedule_attachment",
          "columns": [
            "schedule_attachment_id"
          ]
        },
        {
          "name": "fk_schedule_attachment_schedule",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (schedule_id) REFERENCES schedule (schedule_id)",
          "table": "schedule_attachment",
          "referenced_table": "schedule",
          "columns": [
            "schedule_id"
          ],
          "referenced_columns": [
            "schedule_id"
          ]
        }
      ],
      "triggers": [
        {
          "name": "after_update_schedule_attachment",
          "def": "CREATE TRIGGER after_update_schedule_attachment AFTER UPDATE ON schedule_attachment\nFOR EACH ROW\nBEGIN\n    INSERT INTO `schedule_attachment_history`(\n        schedule_attachment_id,\n        schedule_id,\n        target_type,\n        target_id,\n        created_by,\n        created_at,\n        last_modified_by,\n        last_modified,\n        deleted_by,\n        deleted_at\n    ) VALUES (\n        OLD.schedule_attachment_id,\n        OLD.schedule_id,\n        OLD.target_type,\n        OLD.target_id,\n        OLD.created_by,\n        OLD.created_at,\n        OLD.last_modified_by,\n        OLD.last_modified,\n        OLD.deleted_by,\n        OLD.deleted_at\n    );\nEND"
        }
      ],
      "def": "CREATE TABLE `schedule_attachment` (\n  `schedule_attachment_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `schedule_id` mediumint unsigned NOT NULL,\n  `target_type` enum('contribution','contributor') COLLATE utf8mb4_general_ci NOT NULL,\n  `target_id` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `deleted_by` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  PRIMARY KEY (`schedule_attachment_id`),\n  KEY `fk_schedule_attachment_schedule` (`schedule_id`),\n  CONSTRAINT `fk_schedule_attachment_schedule` FOREIGN KEY (`schedule_id`) REFERENCES `schedule` (`schedule_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "schedule_attachment_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "schedule_attachment_history_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "schedule_attachment_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "schedule_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "target_id",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "target_type",
          "type": "varchar(180)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (schedule_attachment_history_id) USING BTREE",
          "table": "schedule_attachment_history",
          "columns": [
            "schedule_attachment_history_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (schedule_attachment_history_id)",
          "table": "schedule_attachment_history",
          "columns": [
            "schedule_attachment_history_id"
          ]
        }
      ],
      "def": "CREATE TABLE `schedule_attachment_history` (\n  `schedule_attachment_history_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `schedule_attachment_id` mediumint unsigned NOT NULL,\n  `schedule_id` mediumint unsigned NOT NULL,\n  `target_type` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `target_id` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `deleted_by` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  PRIMARY KEY (`schedule_attachment_history_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "schedule_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "conditions",
          "type": "json",
          "nullable": true
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "schedule_history_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "schedule_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "schedule_name",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "target_id",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "target_type",
          "type": "varchar(180)",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (schedule_history_id) USING BTREE",
          "table": "schedule_history",
          "columns": [
            "schedule_history_id"
          ]
        },
        {
          "name": "fk_schedule_id",
          "def": "KEY fk_schedule_id (schedule_id) USING BTREE",
          "table": "schedule_history",
          "columns": [
            "schedule_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (schedule_history_id)",
          "table": "schedule_history",
          "columns": [
            "schedule_history_id"
          ]
        },
        {
          "name": "fk_schedule_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (schedule_id) REFERENCES schedule (schedule_id)",
          "table": "schedule_history",
          "referenced_table": "schedule",
          "columns": [
            "schedule_id"
          ],
          "referenced_columns": [
            "schedule_id"
          ]
        }
      ],
      "def": "CREATE TABLE `schedule_history` (\n  `schedule_history_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `schedule_id` mediumint unsigned NOT NULL,\n  `schedule_name` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `target_type` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `target_id` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `conditions` json DEFAULT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`schedule_history_id`),\n  KEY `fk_schedule_id` (`schedule_id`),\n  CONSTRAINT `fk_schedule_id` FOREIGN KEY (`schedule_id`) REFERENCES `schedule` (`schedule_id`) ON DELETE RESTRICT ON UPDATE RESTRICT\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "statement_attachment",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint",
          "nullable": true
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "failure_reason",
          "type": "enum('missing_tax_information','missing_bank_information','system_error')",
          "nullable": true
        },
        {
          "name": "file_location",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "file_type",
          "type": "enum('csv','pdf','xls','xlsx','png','jpg','doc','docx','txt')",
          "nullable": false
        },
        {
          "name": "invoice_number",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "number_format",
          "type": "enum('us','eu')",
          "nullable": false,
          "default": "us"
        },
        {
          "name": "statement_attachment_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "statement_attachment_status",
          "type": "enum('in_progress','complete','error','retry')",
          "nullable": false
        },
        {
          "name": "statement_attachment_type",
          "type": "enum('distribution_fee_invoice','self_billing_invoice','revenue_detail','nr_performer_revenue','nr_label_revenue','statement_awal','statement_knr_performer','statement_knr_label','collection_summary_label','collection_summary_performer','publishing_detail','internal_upload','legacy_revenue_detail_full','legacy_revenue_detail_physical')",
          "nullable": false
        },
        {
          "name": "statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "statement_period_ids",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "subaccount_id",
          "type": "mediumint",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (statement_attachment_id) USING BTREE",
          "table": "statement_attachment",
          "columns": [
            "statement_attachment_id"
          ]
        },
        {
          "name": "fk_statement_attachment_account",
          "def": "KEY fk_statement_attachment_account (account_id) USING BTREE",
          "table": "statement_attachment",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_statement_attachment_contract",
          "def": "KEY fk_statement_attachment_contract (contract_id) USING BTREE",
          "table": "statement_attachment",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_statement_attachment_statement_period",
          "def": "KEY fk_statement_attachment_statement_period (statement_period_id) USING BTREE",
          "table": "statement_attachment",
          "columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "uidx_statement_attachment_invoice_number",
          "def": "UNIQUE KEY uidx_statement_attachment_invoice_number (invoice_number) USING BTREE",
          "table": "statement_attachment",
          "columns": [
            "invoice_number"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (statement_attachment_id)",
          "table": "statement_attachment",
          "columns": [
            "statement_attachment_id"
          ]
        },
        {
          "name": "fk_statement_attachment_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "statement_attachment",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_statement_attachment_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "statement_attachment",
          "referenced_table": "statement_period",
          "columns": [
            "statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "uidx_statement_attachment_invoice_number",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_statement_attachment_invoice_number (invoice_number)",
          "table": "statement_attachment",
          "columns": [
            "invoice_number"
          ]
        }
      ],
      "def": "CREATE TABLE `statement_attachment` (\n  `statement_attachment_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `account_id` mediumint unsigned NOT NULL,\n  `subaccount_id` mediumint DEFAULT NULL,\n  `contract_id` mediumint DEFAULT NULL,\n  `statement_period_id` mediumint unsigned NOT NULL,\n  `statement_period_ids` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `statement_attachment_status` enum('in_progress','complete','error','retry') COLLATE utf8mb4_general_ci NOT NULL,\n  `failure_reason` enum('missing_tax_information','missing_bank_information','system_error') COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `statement_attachment_type` enum('distribution_fee_invoice','self_billing_invoice','revenue_detail','nr_performer_revenue','nr_label_revenue','statement_awal','statement_knr_performer','statement_knr_label','collection_summary_label','collection_summary_performer','publishing_detail','internal_upload','legacy_revenue_detail_full','legacy_revenue_detail_physical') COLLATE utf8mb4_general_ci NOT NULL,\n  `invoice_number` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `file_location` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `file_type` enum('csv','pdf','xls','xlsx','png','jpg','doc','docx','txt') COLLATE utf8mb4_general_ci NOT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `number_format` enum('us','eu') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'us',\n  PRIMARY KEY (`statement_attachment_id`),\n  UNIQUE KEY `uidx_statement_attachment_invoice_number` (`invoice_number`),\n  KEY `fk_statement_attachment_account` (`account_id`),\n  KEY `fk_statement_attachment_statement_period` (`statement_period_id`),\n  KEY `fk_statement_attachment_contract` (`contract_id`),\n  CONSTRAINT `fk_statement_attachment_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,\n  CONSTRAINT `fk_statement_attachment_statement_period` FOREIGN KEY (`statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE RESTRICT ON UPDATE RESTRICT\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "statement_attachment_archive_WAR-1131",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": false,
          "default": "0000-00-00 00:00:00"
        },
        {
          "name": "failure_reason",
          "type": "enum('missing_tax_information','system_error')",
          "nullable": true
        },
        {
          "name": "file_location",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "invoice_number",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "statement_attachment_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "default": "0"
        },
        {
          "name": "statement_attachment_status",
          "type": "enum('in_progress','complete','error')",
          "nullable": false,
          "default": "in_progress"
        },
        {
          "name": "statement_attachment_type",
          "type": "enum('distribution_fee_invoice','self_billing_invoice','revenue_detail','nr_performer_revenue','nr_label_revenue','statement_awal','statement_knr_performer','statement_knr_label','collection_summary_label','collection_summary_performer')",
          "nullable": false
        },
        {
          "name": "statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        }
      ],
      "def": "CREATE TABLE `statement_attachment_archive_WAR-1131` (\n  `statement_attachment_id` mediumint unsigned NOT NULL DEFAULT '0',\n  `account_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned NOT NULL,\n  `statement_period_id` mediumint unsigned NOT NULL,\n  `statement_attachment_status` enum('in_progress','complete','error') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'in_progress',\n  `failure_reason` enum('missing_tax_information','system_error') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `statement_attachment_type` enum('distribution_fee_invoice','self_billing_invoice','revenue_detail','nr_performer_revenue','nr_label_revenue','statement_awal','statement_knr_performer','statement_knr_label','collection_summary_label','collection_summary_performer') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,\n  `invoice_number` varchar(180) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `file_location` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `created_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `deleted_at` datetime NOT NULL DEFAULT '0000-00-00 00:00:00'\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "statement_period",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "closed_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "closed_date",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "statement_month",
          "type": "tinyint",
          "nullable": true
        },
        {
          "name": "statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "statement_period_name",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "statement_period_status",
          "type": "enum('open','current','closed')",
          "nullable": false,
          "default": "open"
        },
        {
          "name": "statement_year",
          "type": "smallint",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (statement_period_id) USING BTREE",
          "table": "statement_period",
          "columns": [
            "statement_period_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (statement_period_id)",
          "table": "statement_period",
          "columns": [
            "statement_period_id"
          ]
        }
      ],
      "def": "CREATE TABLE `statement_period` (\n  `statement_period_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `statement_period_name` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `statement_period_status` enum('open','current','closed') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'open',\n  `statement_month` tinyint DEFAULT NULL,\n  `statement_year` smallint DEFAULT NULL,\n  `closed_date` datetime DEFAULT NULL,\n  `closed_by` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  PRIMARY KEY (`statement_period_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "statement_period_adjustment_file",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "error_type",
          "type": "enum('format_error','content_error','row_count_error')",
          "nullable": true
        },
        {
          "name": "file_name",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "invalid_file_location",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "invalid_row_count",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "md5sum",
          "type": "varchar(35)",
          "nullable": true
        },
        {
          "name": "statement_period_adjustment_file_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "total_file_amount_multicurrency",
          "type": "decimal(25,12)",
          "nullable": true
        },
        {
          "name": "total_rounded_amount_multicurrency",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "valid_file_location",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "valid_row_count",
          "type": "mediumint unsigned",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (statement_period_adjustment_file_id) USING BTREE",
          "table": "statement_period_adjustment_file",
          "columns": [
            "statement_period_adjustment_file_id"
          ]
        },
        {
          "name": "fk_statement_period_adjustment_file_statement_period",
          "def": "KEY fk_statement_period_adjustment_file_statement_period (statement_period_id) USING BTREE",
          "table": "statement_period_adjustment_file",
          "columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "idx_statement_period_adjustment_file_deleted",
          "def": "KEY idx_statement_period_adjustment_file_deleted (deleted_at, deleted_by) USING BTREE",
          "table": "statement_period_adjustment_file",
          "columns": [
            "deleted_at",
            "deleted_by"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (statement_period_adjustment_file_id)",
          "table": "statement_period_adjustment_file",
          "columns": [
            "statement_period_adjustment_file_id"
          ]
        },
        {
          "name": "fk_statement_period_adjustment_file_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "statement_period_adjustment_file",
          "referenced_table": "statement_period",
          "columns": [
            "statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        }
      ],
      "def": "CREATE TABLE `statement_period_adjustment_file` (\n  `statement_period_adjustment_file_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `statement_period_id` mediumint unsigned NOT NULL,\n  `file_name` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `valid_file_location` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `invalid_file_location` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `valid_row_count` mediumint unsigned DEFAULT NULL,\n  `invalid_row_count` mediumint unsigned DEFAULT NULL,\n  `total_file_amount_multicurrency` decimal(25,12) DEFAULT NULL,\n  `total_rounded_amount_multicurrency` decimal(20,2) DEFAULT NULL,\n  `md5sum` varchar(35) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `error_type` enum('format_error','content_error','row_count_error') COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `deleted_by` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  PRIMARY KEY (`statement_period_adjustment_file_id`),\n  KEY `fk_statement_period_adjustment_file_statement_period` (`statement_period_id`),\n  KEY `idx_statement_period_adjustment_file_deleted` (`deleted_at`,`deleted_by`),\n  CONSTRAINT `fk_statement_period_adjustment_file_statement_period` FOREIGN KEY (`statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "statement_period_payment_entity",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "is_visible_to_customer",
          "type": "tinyint(1)",
          "nullable": false,
          "default": "0"
        },
        {
          "name": "reference_payment_entity_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "statement_period_payment_entity_id",
          "type": "smallint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (statement_period_payment_entity_id) USING BTREE",
          "table": "statement_period_payment_entity",
          "columns": [
            "statement_period_payment_entity_id"
          ]
        },
        {
          "name": "fk_statement_period_payment_entity",
          "def": "KEY fk_statement_period_payment_entity (statement_period_id) USING BTREE",
          "table": "statement_period_payment_entity",
          "columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_statement_period_reference_payment_entity",
          "def": "KEY fk_statement_period_reference_payment_entity (reference_payment_entity_id) USING BTREE",
          "table": "statement_period_payment_entity",
          "columns": [
            "reference_payment_entity_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (statement_period_payment_entity_id)",
          "table": "statement_period_payment_entity",
          "columns": [
            "statement_period_payment_entity_id"
          ]
        },
        {
          "name": "fk_statement_period_payment_entity",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "statement_period_payment_entity",
          "referenced_table": "statement_period",
          "columns": [
            "statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_statement_period_reference_payment_entity",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (reference_payment_entity_id) REFERENCES reference_payment_entity (reference_payment_entity_id)",
          "table": "statement_period_payment_entity",
          "referenced_table": "reference_payment_entity",
          "columns": [
            "reference_payment_entity_id"
          ],
          "referenced_columns": [
            "reference_payment_entity_id"
          ]
        }
      ],
      "def": "CREATE TABLE `statement_period_payment_entity` (\n  `statement_period_payment_entity_id` smallint unsigned NOT NULL AUTO_INCREMENT,\n  `statement_period_id` mediumint unsigned NOT NULL,\n  `reference_payment_entity_id` mediumint unsigned DEFAULT NULL,\n  `is_visible_to_customer` tinyint(1) NOT NULL DEFAULT '0',\n  PRIMARY KEY (`statement_period_payment_entity_id`),\n  KEY `fk_statement_period_payment_entity` (`statement_period_id`),\n  KEY `fk_statement_period_reference_payment_entity` (`reference_payment_entity_id`),\n  CONSTRAINT `fk_statement_period_payment_entity` FOREIGN KEY (`statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_statement_period_reference_payment_entity` FOREIGN KEY (`reference_payment_entity_id`) REFERENCES `reference_payment_entity` (`reference_payment_entity_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "tax_withholding_override",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_payee_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "certificate_expiration_date",
          "type": "date",
          "nullable": true
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "message",
          "type": "text",
          "nullable": true
        },
        {
          "name": "rate_override",
          "type": "decimal(5,2)",
          "nullable": true
        },
        {
          "name": "tax_withholding_override_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (tax_withholding_override_id) USING BTREE",
          "table": "tax_withholding_override",
          "columns": [
            "tax_withholding_override_id"
          ]
        },
        {
          "name": "account_payee_id",
          "def": "UNIQUE KEY account_payee_id (account_payee_id) USING BTREE",
          "table": "tax_withholding_override",
          "columns": [
            "account_payee_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (tax_withholding_override_id)",
          "table": "tax_withholding_override",
          "columns": [
            "tax_withholding_override_id"
          ]
        },
        {
          "name": "account_payee_id",
          "type": "UNIQUE",
          "def": "UNIQUE KEY account_payee_id (account_payee_id)",
          "table": "tax_withholding_override",
          "columns": [
            "account_payee_id"
          ]
        },
        {
          "name": "fk_tax_withholding_override_account_payee_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_payee_id) REFERENCES account_payee (account_payee_id)",
          "table": "tax_withholding_override",
          "referenced_table": "account_payee",
          "columns": [
            "account_payee_id"
          ],
          "referenced_columns": [
            "account_payee_id"
          ]
        }
      ],
      "triggers": [
        {
          "name": "after_update_tax_withholding_override",
          "def": "CREATE TRIGGER after_update_tax_withholding_override AFTER UPDATE ON tax_withholding_override\nFOR EACH ROW\nBEGIN\n    INSERT INTO `tax_withholding_override_history`\n        (\n            `tax_withholding_override_id`, \n            `account_payee_id`, \n            `rate_override`, \n            `certificate_expiration_date`, \n            `message`,\n            `created_by`,\n            `created_at`,\n            `last_modified_by`,\n            `last_modified`\n        )\n    VALUES\n        (\n            OLD.tax_withholding_override_id, \n            OLD.account_payee_id, \n            OLD.rate_override, \n            OLD.certificate_expiration_date, \n            OLD.message,\n            OLD.created_by,\n            OLD.created_at,\n            OLD.last_modified_by,\n            OLD.last_modified\n        );\nEND"
        }
      ],
      "def": "CREATE TABLE `tax_withholding_override` (\n  `tax_withholding_override_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `account_payee_id` mediumint unsigned NOT NULL,\n  `rate_override` decimal(5,2) DEFAULT NULL,\n  `certificate_expiration_date` date DEFAULT NULL,\n  `message` text,\n  `created_by` varchar(255) NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`tax_withholding_override_id`),\n  UNIQUE KEY `account_payee_id` (`account_payee_id`),\n  CONSTRAINT `fk_tax_withholding_override_account_payee_id` FOREIGN KEY (`account_payee_id`) REFERENCES `account_payee` (`account_payee_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci"
    },
    {
      "name": "tax_withholding_override_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_payee_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "certificate_expiration_date",
          "type": "date",
          "nullable": true
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "message",
          "type": "text",
          "nullable": true
        },
        {
          "name": "rate_override",
          "type": "decimal(5,2)",
          "nullable": true
        },
        {
          "name": "tax_withholding_override_history_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "tax_withholding_override_id",
          "type": "mediumint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (tax_withholding_override_history_id) USING BTREE",
          "table": "tax_withholding_override_history",
          "columns": [
            "tax_withholding_override_history_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (tax_withholding_override_history_id)",
          "table": "tax_withholding_override_history",
          "columns": [
            "tax_withholding_override_history_id"
          ]
        }
      ],
      "def": "CREATE TABLE `tax_withholding_override_history` (\n  `tax_withholding_override_history_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `tax_withholding_override_id` mediumint unsigned NOT NULL,\n  `account_payee_id` mediumint unsigned NOT NULL,\n  `rate_override` decimal(5,2) DEFAULT NULL,\n  `certificate_expiration_date` date DEFAULT NULL,\n  `message` text,\n  `created_by` varchar(255) NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  PRIMARY KEY (`tax_withholding_override_history_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci"
    },
    {
      "name": "vat_summary_file",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "file_location",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "vat_summary_file_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (vat_summary_file_id) USING BTREE",
          "table": "vat_summary_file",
          "columns": [
            "vat_summary_file_id"
          ]
        },
        {
          "name": "fk_vat_summary_file_statement_period",
          "def": "KEY fk_vat_summary_file_statement_period (statement_period_id) USING BTREE",
          "table": "vat_summary_file",
          "columns": [
            "statement_period_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (vat_summary_file_id)",
          "table": "vat_summary_file",
          "columns": [
            "vat_summary_file_id"
          ]
        },
        {
          "name": "fk_vat_summary_file_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "vat_summary_file",
          "referenced_table": "statement_period",
          "columns": [
            "statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        }
      ],
      "def": "CREATE TABLE `vat_summary_file` (\n  `vat_summary_file_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `statement_period_id` mediumint unsigned NOT NULL,\n  `file_location` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  PRIMARY KEY (`vat_summary_file_id`),\n  KEY `fk_vat_summary_file_statement_period` (`statement_period_id`),\n  CONSTRAINT `fk_vat_summary_file_statement_period` FOREIGN KEY (`statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "worksheet_account_contract_closing_balance",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "abacus_event_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "amount",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "includes_tax_adjustments",
          "type": "tinyint(1)",
          "nullable": false,
          "default": "0"
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "ledger_account_contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "reference_payment_entity_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "worksheet_account_contract_closing_balance_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (worksheet_account_contract_closing_balance_id) USING BTREE",
          "table": "worksheet_account_contract_closing_balance",
          "columns": [
            "worksheet_account_contract_closing_balance_id"
          ]
        },
        {
          "name": "fk_waccb_abacus_event",
          "def": "KEY fk_waccb_abacus_event (abacus_event_id) USING BTREE",
          "table": "worksheet_account_contract_closing_balance",
          "columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_waccb_account",
          "def": "KEY fk_waccb_account (account_id) USING BTREE",
          "table": "worksheet_account_contract_closing_balance",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_waccb_ledger_account_contract",
          "def": "KEY fk_waccb_ledger_account_contract (ledger_account_contract_id) USING BTREE",
          "table": "worksheet_account_contract_closing_balance",
          "columns": [
            "ledger_account_contract_id"
          ]
        },
        {
          "name": "fk_waccb_reference_payment_entity",
          "def": "KEY fk_waccb_reference_payment_entity (reference_payment_entity_id) USING BTREE",
          "table": "worksheet_account_contract_closing_balance",
          "columns": [
            "reference_payment_entity_id"
          ]
        },
        {
          "name": "fk_waccb_statement_period",
          "def": "KEY fk_waccb_statement_period (statement_period_id) USING BTREE",
          "table": "worksheet_account_contract_closing_balance",
          "columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "unique_waccb_contract_statement_period_event",
          "def": "UNIQUE KEY unique_waccb_contract_statement_period_event (contract_id, statement_period_id, abacus_event_id) USING BTREE",
          "table": "worksheet_account_contract_closing_balance",
          "columns": [
            "contract_id",
            "statement_period_id",
            "abacus_event_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (worksheet_account_contract_closing_balance_id)",
          "table": "worksheet_account_contract_closing_balance",
          "columns": [
            "worksheet_account_contract_closing_balance_id"
          ]
        },
        {
          "name": "fk_waccb_abacus_event",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)",
          "table": "worksheet_account_contract_closing_balance",
          "referenced_table": "abacus_event",
          "columns": [
            "abacus_event_id"
          ],
          "referenced_columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_waccb_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "worksheet_account_contract_closing_balance",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_waccb_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "worksheet_account_contract_closing_balance",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_waccb_ledger_account_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (ledger_account_contract_id) REFERENCES ledger_account_contract (ledger_account_contract_id)",
          "table": "worksheet_account_contract_closing_balance",
          "referenced_table": "ledger_account_contract",
          "columns": [
            "ledger_account_contract_id"
          ],
          "referenced_columns": [
            "ledger_account_contract_id"
          ]
        },
        {
          "name": "fk_waccb_reference_payment_entity",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (reference_payment_entity_id) REFERENCES reference_payment_entity (reference_payment_entity_id)",
          "table": "worksheet_account_contract_closing_balance",
          "referenced_table": "reference_payment_entity",
          "columns": [
            "reference_payment_entity_id"
          ],
          "referenced_columns": [
            "reference_payment_entity_id"
          ]
        },
        {
          "name": "fk_waccb_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "worksheet_account_contract_closing_balance",
          "referenced_table": "statement_period",
          "columns": [
            "statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "unique_waccb_contract_statement_period_event",
          "type": "UNIQUE",
          "def": "UNIQUE KEY unique_waccb_contract_statement_period_event (contract_id, statement_period_id, abacus_event_id)",
          "table": "worksheet_account_contract_closing_balance",
          "columns": [
            "contract_id",
            "statement_period_id",
            "abacus_event_id"
          ]
        }
      ],
      "def": "CREATE TABLE `worksheet_account_contract_closing_balance` (\n  `worksheet_account_contract_closing_balance_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `account_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned NOT NULL,\n  `reference_payment_entity_id` mediumint unsigned NOT NULL,\n  `abacus_event_id` mediumint unsigned NOT NULL,\n  `currency_code` char(3) NOT NULL,\n  `statement_period_id` mediumint unsigned NOT NULL,\n  `amount` decimal(20,2) NOT NULL,\n  `includes_tax_adjustments` tinyint(1) NOT NULL DEFAULT '0',\n  `created_at` datetime NOT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(255) DEFAULT NULL,\n  `ledger_account_contract_id` mediumint unsigned NOT NULL,\n  PRIMARY KEY (`worksheet_account_contract_closing_balance_id`),\n  UNIQUE KEY `unique_waccb_contract_statement_period_event` (`contract_id`,`statement_period_id`,`abacus_event_id`),\n  KEY `fk_waccb_account` (`account_id`),\n  KEY `fk_waccb_abacus_event` (`abacus_event_id`),\n  KEY `fk_waccb_statement_period` (`statement_period_id`),\n  KEY `fk_waccb_reference_payment_entity` (`reference_payment_entity_id`),\n  KEY `fk_waccb_ledger_account_contract` (`ledger_account_contract_id`),\n  CONSTRAINT `fk_waccb_abacus_event` FOREIGN KEY (`abacus_event_id`) REFERENCES `abacus_event` (`abacus_event_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,\n  CONSTRAINT `fk_waccb_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_waccb_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_waccb_ledger_account_contract` FOREIGN KEY (`ledger_account_contract_id`) REFERENCES `ledger_account_contract` (`ledger_account_contract_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,\n  CONSTRAINT `fk_waccb_reference_payment_entity` FOREIGN KEY (`reference_payment_entity_id`) REFERENCES `reference_payment_entity` (`reference_payment_entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_waccb_statement_period` FOREIGN KEY (`statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "worksheet_account_contract_payable_after_tax",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "abacus_event_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "country_of_tax_policy",
          "type": "char(3)",
          "nullable": true
        },
        {
          "name": "country_of_tax_residence",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "payable_amount_post_tax",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "payable_amount_pre_tax",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "tax_withholding_amount",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "vat_amount",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "worksheet_account_contract_closing_balance_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "worksheet_account_contract_payable_after_tax_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (worksheet_account_contract_payable_after_tax_id) USING BTREE",
          "table": "worksheet_account_contract_payable_after_tax",
          "columns": [
            "worksheet_account_contract_payable_after_tax_id"
          ]
        },
        {
          "name": "fk_wacpat_abacus_event",
          "def": "KEY fk_wacpat_abacus_event (abacus_event_id) USING BTREE",
          "table": "worksheet_account_contract_payable_after_tax",
          "columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_wacpat_account",
          "def": "KEY fk_wacpat_account (account_id) USING BTREE",
          "table": "worksheet_account_contract_payable_after_tax",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_wacpat_contract",
          "def": "KEY fk_wacpat_contract (contract_id) USING BTREE",
          "table": "worksheet_account_contract_payable_after_tax",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_wacpat_statement_period",
          "def": "KEY fk_wacpat_statement_period (statement_period_id) USING BTREE",
          "table": "worksheet_account_contract_payable_after_tax",
          "columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_wacpat_waccb",
          "def": "KEY fk_wacpat_waccb (worksheet_account_contract_closing_balance_id) USING BTREE",
          "table": "worksheet_account_contract_payable_after_tax",
          "columns": [
            "worksheet_account_contract_closing_balance_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (worksheet_account_contract_payable_after_tax_id)",
          "table": "worksheet_account_contract_payable_after_tax",
          "columns": [
            "worksheet_account_contract_payable_after_tax_id"
          ]
        },
        {
          "name": "fk_wacpat_abacus_event",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)",
          "table": "worksheet_account_contract_payable_after_tax",
          "referenced_table": "abacus_event",
          "columns": [
            "abacus_event_id"
          ],
          "referenced_columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_wacpat_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "worksheet_account_contract_payable_after_tax",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_wacpat_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "worksheet_account_contract_payable_after_tax",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_wacpat_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "worksheet_account_contract_payable_after_tax",
          "referenced_table": "statement_period",
          "columns": [
            "statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_wacpat_waccb",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (worksheet_account_contract_closing_balance_id) REFERENCES worksheet_account_contract_closing_balance (worksheet_account_contract_closing_balance_id)",
          "table": "worksheet_account_contract_payable_after_tax",
          "referenced_table": "worksheet_account_contract_closing_balance",
          "columns": [
            "worksheet_account_contract_closing_balance_id"
          ],
          "referenced_columns": [
            "worksheet_account_contract_closing_balance_id"
          ]
        }
      ],
      "def": "CREATE TABLE `worksheet_account_contract_payable_after_tax` (\n  `worksheet_account_contract_payable_after_tax_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `worksheet_account_contract_closing_balance_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned NOT NULL,\n  `account_id` mediumint unsigned NOT NULL,\n  `statement_period_id` mediumint unsigned NOT NULL,\n  `abacus_event_id` mediumint unsigned NOT NULL,\n  `payable_amount_pre_tax` decimal(20,2) NOT NULL,\n  `tax_withholding_amount` decimal(20,2) DEFAULT NULL,\n  `vat_amount` decimal(20,2) DEFAULT NULL,\n  `payable_amount_post_tax` decimal(20,2) NOT NULL,\n  `currency_code` char(3) NOT NULL,\n  `country_of_tax_residence` char(3) NOT NULL,\n  `country_of_tax_policy` char(3) DEFAULT NULL,\n  `created_at` datetime NOT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(255) DEFAULT NULL,\n  PRIMARY KEY (`worksheet_account_contract_payable_after_tax_id`),\n  KEY `fk_wacpat_contract` (`contract_id`),\n  KEY `fk_wacpat_account` (`account_id`),\n  KEY `fk_wacpat_abacus_event` (`abacus_event_id`),\n  KEY `fk_wacpat_statement_period` (`statement_period_id`),\n  KEY `fk_wacpat_waccb` (`worksheet_account_contract_closing_balance_id`),\n  CONSTRAINT `fk_wacpat_abacus_event` FOREIGN KEY (`abacus_event_id`) REFERENCES `abacus_event` (`abacus_event_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,\n  CONSTRAINT `fk_wacpat_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_wacpat_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_wacpat_statement_period` FOREIGN KEY (`statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_wacpat_waccb` FOREIGN KEY (`worksheet_account_contract_closing_balance_id`) REFERENCES `worksheet_account_contract_closing_balance` (`worksheet_account_contract_closing_balance_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "worksheet_account_contract_payable_details",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "amount_payable",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "currency",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "notes",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "payable_detail_type_id",
          "type": "tinyint unsigned",
          "nullable": false
        },
        {
          "name": "reference_target_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "reference_target_table",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "target_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "target_table",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "worksheet_account_contract_payable_after_tax_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "worksheet_account_contract_payable_details_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (worksheet_account_contract_payable_details_id) USING BTREE",
          "table": "worksheet_account_contract_payable_details",
          "columns": [
            "worksheet_account_contract_payable_details_id"
          ]
        },
        {
          "name": "fk_wacpd_account",
          "def": "KEY fk_wacpd_account (account_id) USING BTREE",
          "table": "worksheet_account_contract_payable_details",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_wacpd_contract",
          "def": "KEY fk_wacpd_contract (contract_id) USING BTREE",
          "table": "worksheet_account_contract_payable_details",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_wacpd_ref_payable_detail",
          "def": "KEY fk_wacpd_ref_payable_detail (payable_detail_type_id) USING BTREE",
          "table": "worksheet_account_contract_payable_details",
          "columns": [
            "payable_detail_type_id"
          ]
        },
        {
          "name": "fk_wacpd_statement_period",
          "def": "KEY fk_wacpd_statement_period (statement_period_id) USING BTREE",
          "table": "worksheet_account_contract_payable_details",
          "columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_wacpd_wacpat",
          "def": "KEY fk_wacpd_wacpat (worksheet_account_contract_payable_after_tax_id) USING BTREE",
          "table": "worksheet_account_contract_payable_details",
          "columns": [
            "worksheet_account_contract_payable_after_tax_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (worksheet_account_contract_payable_details_id)",
          "table": "worksheet_account_contract_payable_details",
          "columns": [
            "worksheet_account_contract_payable_details_id"
          ]
        },
        {
          "name": "fk_wacpd_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "worksheet_account_contract_payable_details",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_wacpd_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "worksheet_account_contract_payable_details",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_wacpd_ref_payable_detail",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (payable_detail_type_id) REFERENCES reference_payable_detail_type (reference_payable_detail_type_id)",
          "table": "worksheet_account_contract_payable_details",
          "referenced_table": "reference_payable_detail_type",
          "columns": [
            "payable_detail_type_id"
          ],
          "referenced_columns": [
            "reference_payable_detail_type_id"
          ]
        },
        {
          "name": "fk_wacpd_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "worksheet_account_contract_payable_details",
          "referenced_table": "statement_period",
          "columns": [
            "statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_wacpd_wacpat",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (worksheet_account_contract_payable_after_tax_id) REFERENCES worksheet_account_contract_payable_after_tax (worksheet_account_contract_payable_after_tax_id)",
          "table": "worksheet_account_contract_payable_details",
          "referenced_table": "worksheet_account_contract_payable_after_tax",
          "columns": [
            "worksheet_account_contract_payable_after_tax_id"
          ],
          "referenced_columns": [
            "worksheet_account_contract_payable_after_tax_id"
          ]
        }
      ],
      "def": "CREATE TABLE `worksheet_account_contract_payable_details` (\n  `worksheet_account_contract_payable_details_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `worksheet_account_contract_payable_after_tax_id` mediumint unsigned DEFAULT NULL,\n  `contract_id` mediumint unsigned NOT NULL,\n  `account_id` mediumint unsigned NOT NULL,\n  `statement_period_id` mediumint unsigned NOT NULL,\n  `target_table` varchar(255) NOT NULL,\n  `target_id` mediumint unsigned NOT NULL,\n  `reference_target_table` varchar(255) DEFAULT NULL,\n  `reference_target_id` mediumint unsigned DEFAULT NULL,\n  `payable_detail_type_id` tinyint unsigned NOT NULL,\n  `amount_payable` decimal(20,2) NOT NULL,\n  `currency` char(3) NOT NULL,\n  `notes` varchar(255) DEFAULT NULL,\n  `created_at` datetime NOT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(255) DEFAULT NULL,\n  PRIMARY KEY (`worksheet_account_contract_payable_details_id`),\n  KEY `fk_wacpd_contract` (`contract_id`),\n  KEY `fk_wacpd_account` (`account_id`),\n  KEY `fk_wacpd_statement_period` (`statement_period_id`),\n  KEY `fk_wacpd_wacpat` (`worksheet_account_contract_payable_after_tax_id`),\n  KEY `fk_wacpd_ref_payable_detail` (`payable_detail_type_id`),\n  CONSTRAINT `fk_wacpd_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_wacpd_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_wacpd_ref_payable_detail` FOREIGN KEY (`payable_detail_type_id`) REFERENCES `reference_payable_detail_type` (`reference_payable_detail_type_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_wacpd_statement_period` FOREIGN KEY (`statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_wacpd_wacpat` FOREIGN KEY (`worksheet_account_contract_payable_after_tax_id`) REFERENCES `worksheet_account_contract_payable_after_tax` (`worksheet_account_contract_payable_after_tax_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "worksheet_account_contract_taxable_revenue",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "abacus_event_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "account_contract_taxable_revenue_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "amount",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "is_us_revenue",
          "type": "tinyint(1)",
          "nullable": false,
          "default": "0"
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "reference_payment_entity_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "revenue_transaction_type",
          "type": "enum('digital','physical','closing_balance')",
          "nullable": false
        },
        {
          "name": "statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "worksheet_account_contract_closing_balance_id",
          "type": "mediumint unsigned",
          "nullable": true
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (account_contract_taxable_revenue_id) USING BTREE",
          "table": "worksheet_account_contract_taxable_revenue",
          "columns": [
            "account_contract_taxable_revenue_id"
          ]
        },
        {
          "name": "fk_wactr_abacus_event",
          "def": "KEY fk_wactr_abacus_event (abacus_event_id) USING BTREE",
          "table": "worksheet_account_contract_taxable_revenue",
          "columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_wactr_account",
          "def": "KEY fk_wactr_account (account_id) USING BTREE",
          "table": "worksheet_account_contract_taxable_revenue",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_wactr_contract",
          "def": "KEY fk_wactr_contract (contract_id) USING BTREE",
          "table": "worksheet_account_contract_taxable_revenue",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_wactr_ref_payment_entity",
          "def": "KEY fk_wactr_ref_payment_entity (reference_payment_entity_id) USING BTREE",
          "table": "worksheet_account_contract_taxable_revenue",
          "columns": [
            "reference_payment_entity_id"
          ]
        },
        {
          "name": "fk_wactr_statement_period",
          "def": "KEY fk_wactr_statement_period (statement_period_id) USING BTREE",
          "table": "worksheet_account_contract_taxable_revenue",
          "columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_wactr_waccb",
          "def": "KEY fk_wactr_waccb (worksheet_account_contract_closing_balance_id) USING BTREE",
          "table": "worksheet_account_contract_taxable_revenue",
          "columns": [
            "worksheet_account_contract_closing_balance_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (account_contract_taxable_revenue_id)",
          "table": "worksheet_account_contract_taxable_revenue",
          "columns": [
            "account_contract_taxable_revenue_id"
          ]
        },
        {
          "name": "fk_wactr_abacus_event",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)",
          "table": "worksheet_account_contract_taxable_revenue",
          "referenced_table": "abacus_event",
          "columns": [
            "abacus_event_id"
          ],
          "referenced_columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_wactr_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "worksheet_account_contract_taxable_revenue",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_wactr_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "worksheet_account_contract_taxable_revenue",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_wactr_ref_payment_entity",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (reference_payment_entity_id) REFERENCES reference_payment_entity (reference_payment_entity_id)",
          "table": "worksheet_account_contract_taxable_revenue",
          "referenced_table": "reference_payment_entity",
          "columns": [
            "reference_payment_entity_id"
          ],
          "referenced_columns": [
            "reference_payment_entity_id"
          ]
        },
        {
          "name": "fk_wactr_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "worksheet_account_contract_taxable_revenue",
          "referenced_table": "statement_period",
          "columns": [
            "statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_wactr_waccb",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (worksheet_account_contract_closing_balance_id) REFERENCES worksheet_account_contract_closing_balance (worksheet_account_contract_closing_balance_id)",
          "table": "worksheet_account_contract_taxable_revenue",
          "referenced_table": "worksheet_account_contract_closing_balance",
          "columns": [
            "worksheet_account_contract_closing_balance_id"
          ],
          "referenced_columns": [
            "worksheet_account_contract_closing_balance_id"
          ]
        }
      ],
      "def": "CREATE TABLE `worksheet_account_contract_taxable_revenue` (\n  `account_contract_taxable_revenue_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `worksheet_account_contract_closing_balance_id` mediumint unsigned DEFAULT NULL,\n  `contract_id` mediumint unsigned NOT NULL,\n  `account_id` mediumint unsigned NOT NULL,\n  `reference_payment_entity_id` mediumint unsigned NOT NULL,\n  `statement_period_id` mediumint unsigned NOT NULL,\n  `abacus_event_id` mediumint unsigned NOT NULL,\n  `amount` decimal(20,2) NOT NULL,\n  `currency_code` char(3) NOT NULL,\n  `revenue_transaction_type` enum('digital','physical','closing_balance') NOT NULL,\n  `is_us_revenue` tinyint(1) NOT NULL DEFAULT '0',\n  `created_at` datetime NOT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(255) DEFAULT NULL,\n  PRIMARY KEY (`account_contract_taxable_revenue_id`),\n  KEY `fk_wactr_contract` (`contract_id`),\n  KEY `fk_wactr_account` (`account_id`),\n  KEY `fk_wactr_statement_period` (`statement_period_id`),\n  KEY `fk_wactr_abacus_event` (`abacus_event_id`),\n  KEY `fk_wactr_ref_payment_entity` (`reference_payment_entity_id`),\n  KEY `fk_wactr_waccb` (`worksheet_account_contract_closing_balance_id`),\n  CONSTRAINT `fk_wactr_abacus_event` FOREIGN KEY (`abacus_event_id`) REFERENCES `abacus_event` (`abacus_event_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_wactr_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_wactr_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_wactr_ref_payment_entity` FOREIGN KEY (`reference_payment_entity_id`) REFERENCES `reference_payment_entity` (`reference_payment_entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_wactr_statement_period` FOREIGN KEY (`statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_wactr_waccb` FOREIGN KEY (`worksheet_account_contract_closing_balance_id`) REFERENCES `worksheet_account_contract_closing_balance` (`worksheet_account_contract_closing_balance_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "worksheet_adjustment",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "abacus_event_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "activity_statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "adjustment_amount",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "adjustment_currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "apply_to_statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "internal_note",
          "type": "mediumtext",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "note",
          "type": "mediumtext",
          "nullable": true
        },
        {
          "name": "reference_adjustment_type_id",
          "type": "tinyint unsigned",
          "nullable": false
        },
        {
          "name": "statement_period_adjustment_file_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "worksheet_adjustment_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (worksheet_adjustment_id) USING BTREE",
          "table": "worksheet_adjustment",
          "columns": [
            "worksheet_adjustment_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_abacus_event",
          "def": "KEY fk_worksheet_adjustment_abacus_event (abacus_event_id) USING BTREE",
          "table": "worksheet_adjustment",
          "columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_account",
          "def": "KEY fk_worksheet_adjustment_account (account_id) USING BTREE",
          "table": "worksheet_adjustment",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_activity_statement_period",
          "def": "KEY fk_worksheet_adjustment_activity_statement_period (activity_statement_period_id) USING BTREE",
          "table": "worksheet_adjustment",
          "columns": [
            "activity_statement_period_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_apply_to_statement_period",
          "def": "KEY fk_worksheet_adjustment_apply_to_statement_period (apply_to_statement_period_id) USING BTREE",
          "table": "worksheet_adjustment",
          "columns": [
            "apply_to_statement_period_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_contract",
          "def": "KEY fk_worksheet_adjustment_contract (contract_id) USING BTREE",
          "table": "worksheet_adjustment",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_reference_adjustment_type",
          "def": "KEY fk_worksheet_adjustment_reference_adjustment_type (reference_adjustment_type_id) USING BTREE",
          "table": "worksheet_adjustment",
          "columns": [
            "reference_adjustment_type_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_statement_period_adjustment_file",
          "def": "KEY fk_worksheet_adjustment_statement_period_adjustment_file (statement_period_adjustment_file_id) USING BTREE",
          "table": "worksheet_adjustment",
          "columns": [
            "statement_period_adjustment_file_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (worksheet_adjustment_id)",
          "table": "worksheet_adjustment",
          "columns": [
            "worksheet_adjustment_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_abacus_event",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)",
          "table": "worksheet_adjustment",
          "referenced_table": "abacus_event",
          "columns": [
            "abacus_event_id"
          ],
          "referenced_columns": [
            "abacus_event_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "worksheet_adjustment",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_activity_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (activity_statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "worksheet_adjustment",
          "referenced_table": "statement_period",
          "columns": [
            "activity_statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_apply_to_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (apply_to_statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "worksheet_adjustment",
          "referenced_table": "statement_period",
          "columns": [
            "apply_to_statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "worksheet_adjustment",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_reference_adjustment_type",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (reference_adjustment_type_id) REFERENCES reference_adjustment_type (reference_adjustment_type_id)",
          "table": "worksheet_adjustment",
          "referenced_table": "reference_adjustment_type",
          "columns": [
            "reference_adjustment_type_id"
          ],
          "referenced_columns": [
            "reference_adjustment_type_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_statement_period_adjustment_file",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (statement_period_adjustment_file_id) REFERENCES statement_period_adjustment_file (statement_period_adjustment_file_id)",
          "table": "worksheet_adjustment",
          "referenced_table": "statement_period_adjustment_file",
          "columns": [
            "statement_period_adjustment_file_id"
          ],
          "referenced_columns": [
            "statement_period_adjustment_file_id"
          ]
        }
      ],
      "def": "CREATE TABLE `worksheet_adjustment` (\n  `worksheet_adjustment_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `statement_period_adjustment_file_id` mediumint unsigned NOT NULL,\n  `abacus_event_id` mediumint unsigned NOT NULL,\n  `account_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned DEFAULT NULL,\n  `activity_statement_period_id` mediumint unsigned NOT NULL,\n  `apply_to_statement_period_id` mediumint unsigned NOT NULL,\n  `reference_adjustment_type_id` tinyint unsigned NOT NULL,\n  `adjustment_amount` decimal(20,2) NOT NULL,\n  `adjustment_currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `note` mediumtext COLLATE utf8mb4_general_ci,\n  `internal_note` mediumtext COLLATE utf8mb4_general_ci,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `deleted_by` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  PRIMARY KEY (`worksheet_adjustment_id`),\n  KEY `fk_worksheet_adjustment_statement_period_adjustment_file` (`statement_period_adjustment_file_id`),\n  KEY `fk_worksheet_adjustment_abacus_event` (`abacus_event_id`),\n  KEY `fk_worksheet_adjustment_account` (`account_id`),\n  KEY `fk_worksheet_adjustment_contract` (`contract_id`),\n  KEY `fk_worksheet_adjustment_activity_statement_period` (`activity_statement_period_id`),\n  KEY `fk_worksheet_adjustment_apply_to_statement_period` (`apply_to_statement_period_id`),\n  KEY `fk_worksheet_adjustment_reference_adjustment_type` (`reference_adjustment_type_id`),\n  CONSTRAINT `fk_worksheet_adjustment_abacus_event` FOREIGN KEY (`abacus_event_id`) REFERENCES `abacus_event` (`abacus_event_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_worksheet_adjustment_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_worksheet_adjustment_activity_statement_period` FOREIGN KEY (`activity_statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_worksheet_adjustment_apply_to_statement_period` FOREIGN KEY (`apply_to_statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_worksheet_adjustment_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_worksheet_adjustment_reference_adjustment_type` FOREIGN KEY (`reference_adjustment_type_id`) REFERENCES `reference_adjustment_type` (`reference_adjustment_type_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_worksheet_adjustment_statement_period_adjustment_file` FOREIGN KEY (`statement_period_adjustment_file_id`) REFERENCES `statement_period_adjustment_file` (`statement_period_adjustment_file_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "worksheet_adjustment_detail",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "activity_statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "amount",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "apply_to_statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "distribution_type",
          "type": "enum('digital','physical')",
          "nullable": true
        },
        {
          "name": "internal_note",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "note",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "reference_adjustment_type_id",
          "type": "tinyint unsigned",
          "nullable": false
        },
        {
          "name": "statement_period_adjustment_file_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "upc",
          "type": "varchar(20)",
          "nullable": false
        },
        {
          "name": "worksheet_adjustment_detail_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "worksheet_adjustment_id",
          "type": "mediumint unsigned",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (worksheet_adjustment_detail_id) USING BTREE",
          "table": "worksheet_adjustment_detail",
          "columns": [
            "worksheet_adjustment_detail_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_detail_account",
          "def": "KEY fk_worksheet_adjustment_detail_account (account_id) USING BTREE",
          "table": "worksheet_adjustment_detail",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_detail_activity_statement_period",
          "def": "KEY fk_worksheet_adjustment_detail_activity_statement_period (activity_statement_period_id) USING BTREE",
          "table": "worksheet_adjustment_detail",
          "columns": [
            "activity_statement_period_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_detail_apply_to_statement_period",
          "def": "KEY fk_worksheet_adjustment_detail_apply_to_statement_period (apply_to_statement_period_id) USING BTREE",
          "table": "worksheet_adjustment_detail",
          "columns": [
            "apply_to_statement_period_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_detail_contract",
          "def": "KEY fk_worksheet_adjustment_detail_contract (contract_id) USING BTREE",
          "table": "worksheet_adjustment_detail",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_detail_reference_adjustment_type",
          "def": "KEY fk_worksheet_adjustment_detail_reference_adjustment_type (reference_adjustment_type_id) USING BTREE",
          "table": "worksheet_adjustment_detail",
          "columns": [
            "reference_adjustment_type_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_detail_statement_period_adjustment_file",
          "def": "KEY fk_worksheet_adjustment_detail_statement_period_adjustment_file (statement_period_adjustment_file_id) USING BTREE",
          "table": "worksheet_adjustment_detail",
          "columns": [
            "statement_period_adjustment_file_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_detail_worksheet_adjustment",
          "def": "KEY fk_worksheet_adjustment_detail_worksheet_adjustment (worksheet_adjustment_id) USING BTREE",
          "table": "worksheet_adjustment_detail",
          "columns": [
            "worksheet_adjustment_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (worksheet_adjustment_detail_id)",
          "table": "worksheet_adjustment_detail",
          "columns": [
            "worksheet_adjustment_detail_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_detail_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "worksheet_adjustment_detail",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_detail_activity_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (activity_statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "worksheet_adjustment_detail",
          "referenced_table": "statement_period",
          "columns": [
            "activity_statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_detail_apply_to_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (apply_to_statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "worksheet_adjustment_detail",
          "referenced_table": "statement_period",
          "columns": [
            "apply_to_statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_detail_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "worksheet_adjustment_detail",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_detail_reference_adjustment_type",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (reference_adjustment_type_id) REFERENCES reference_adjustment_type (reference_adjustment_type_id)",
          "table": "worksheet_adjustment_detail",
          "referenced_table": "reference_adjustment_type",
          "columns": [
            "reference_adjustment_type_id"
          ],
          "referenced_columns": [
            "reference_adjustment_type_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_detail_statement_period_adjustment_file",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (statement_period_adjustment_file_id) REFERENCES statement_period_adjustment_file (statement_period_adjustment_file_id)",
          "table": "worksheet_adjustment_detail",
          "referenced_table": "statement_period_adjustment_file",
          "columns": [
            "statement_period_adjustment_file_id"
          ],
          "referenced_columns": [
            "statement_period_adjustment_file_id"
          ]
        },
        {
          "name": "fk_worksheet_adjustment_detail_worksheet_adjustment",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (worksheet_adjustment_id) REFERENCES worksheet_adjustment (worksheet_adjustment_id)",
          "table": "worksheet_adjustment_detail",
          "referenced_table": "worksheet_adjustment",
          "columns": [
            "worksheet_adjustment_id"
          ],
          "referenced_columns": [
            "worksheet_adjustment_id"
          ]
        }
      ],
      "def": "CREATE TABLE `worksheet_adjustment_detail` (\n  `worksheet_adjustment_detail_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `statement_period_adjustment_file_id` mediumint unsigned NOT NULL,\n  `worksheet_adjustment_id` mediumint unsigned NOT NULL,\n  `account_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned DEFAULT NULL,\n  `activity_statement_period_id` mediumint unsigned NOT NULL,\n  `apply_to_statement_period_id` mediumint unsigned NOT NULL,\n  `reference_adjustment_type_id` tinyint unsigned NOT NULL,\n  `currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `amount` decimal(20,2) NOT NULL,\n  `upc` varchar(20) COLLATE utf8mb4_general_ci NOT NULL,\n  `distribution_type` enum('digital','physical') COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `note` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `internal_note` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `created_at` datetime NOT NULL,\n  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `deleted_by` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  PRIMARY KEY (`worksheet_adjustment_detail_id`),\n  KEY `fk_worksheet_adjustment_detail_statement_period_adjustment_file` (`statement_period_adjustment_file_id`),\n  KEY `fk_worksheet_adjustment_detail_worksheet_adjustment` (`worksheet_adjustment_id`),\n  KEY `fk_worksheet_adjustment_detail_account` (`account_id`),\n  KEY `fk_worksheet_adjustment_detail_contract` (`contract_id`),\n  KEY `fk_worksheet_adjustment_detail_activity_statement_period` (`activity_statement_period_id`),\n  KEY `fk_worksheet_adjustment_detail_apply_to_statement_period` (`apply_to_statement_period_id`),\n  KEY `fk_worksheet_adjustment_detail_reference_adjustment_type` (`reference_adjustment_type_id`),\n  CONSTRAINT `fk_worksheet_adjustment_detail_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_worksheet_adjustment_detail_activity_statement_period` FOREIGN KEY (`activity_statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_worksheet_adjustment_detail_apply_to_statement_period` FOREIGN KEY (`apply_to_statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_worksheet_adjustment_detail_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_worksheet_adjustment_detail_reference_adjustment_type` FOREIGN KEY (`reference_adjustment_type_id`) REFERENCES `reference_adjustment_type` (`reference_adjustment_type_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_worksheet_adjustment_detail_statement_period_adjustment_file` FOREIGN KEY (`statement_period_adjustment_file_id`) REFERENCES `statement_period_adjustment_file` (`statement_period_adjustment_file_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_worksheet_adjustment_detail_worksheet_adjustment` FOREIGN KEY (`worksheet_adjustment_id`) REFERENCES `worksheet_adjustment` (`worksheet_adjustment_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "worksheet_correction",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": true
        },
        {
          "name": "correction_statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "correction_type",
          "type": "enum('royalty_reversal','royalty_correction')",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "distribution_fee",
          "type": "decimal(38,18)",
          "nullable": false
        },
        {
          "name": "gross_revenue",
          "type": "decimal(38,18)",
          "nullable": false
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "mechanical_deduction_admin_fee_total",
          "type": "decimal(38,18)",
          "nullable": true
        },
        {
          "name": "mechanical_deduction_total",
          "type": "decimal(38,18)",
          "nullable": true
        },
        {
          "name": "net_revenue",
          "type": "decimal(38,18)",
          "nullable": false
        },
        {
          "name": "note",
          "type": "mediumtext",
          "nullable": true
        },
        {
          "name": "statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "worksheet_correction_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (worksheet_correction_id) USING BTREE",
          "table": "worksheet_correction",
          "columns": [
            "worksheet_correction_id"
          ]
        },
        {
          "name": "fk_account_worksheet_correction",
          "def": "KEY fk_account_worksheet_correction (account_id) USING BTREE",
          "table": "worksheet_correction",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_contract_worksheet_correction",
          "def": "KEY fk_contract_worksheet_correction (contract_id) USING BTREE",
          "table": "worksheet_correction",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_correction_statement_period_worksheet_correction",
          "def": "KEY fk_correction_statement_period_worksheet_correction (correction_statement_period_id) USING BTREE",
          "table": "worksheet_correction",
          "columns": [
            "correction_statement_period_id"
          ]
        },
        {
          "name": "fk_statement_period_worksheet_correction",
          "def": "KEY fk_statement_period_worksheet_correction (statement_period_id) USING BTREE",
          "table": "worksheet_correction",
          "columns": [
            "statement_period_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (worksheet_correction_id)",
          "table": "worksheet_correction",
          "columns": [
            "worksheet_correction_id"
          ]
        },
        {
          "name": "fk_account_worksheet_correction",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "worksheet_correction",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_contract_worksheet_correction",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "worksheet_correction",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_correction_statement_period_worksheet_correction",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (correction_statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "worksheet_correction",
          "referenced_table": "statement_period",
          "columns": [
            "correction_statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_statement_period_worksheet_correction",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "worksheet_correction",
          "referenced_table": "statement_period",
          "columns": [
            "statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        }
      ],
      "def": "CREATE TABLE `worksheet_correction` (\n  `worksheet_correction_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `account_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned DEFAULT NULL,\n  `statement_period_id` mediumint unsigned NOT NULL,\n  `correction_statement_period_id` mediumint unsigned NOT NULL,\n  `correction_type` enum('royalty_reversal','royalty_correction') COLLATE utf8mb4_general_ci NOT NULL,\n  `currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `gross_revenue` decimal(38,18) NOT NULL,\n  `distribution_fee` decimal(38,18) NOT NULL,\n  `mechanical_deduction_total` decimal(38,18) DEFAULT NULL,\n  `mechanical_deduction_admin_fee_total` decimal(38,18) DEFAULT NULL,\n  `net_revenue` decimal(38,18) NOT NULL,\n  `note` mediumtext COLLATE utf8mb4_general_ci,\n  `created_at` datetime NOT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  PRIMARY KEY (`worksheet_correction_id`),\n  KEY `fk_account_worksheet_correction` (`account_id`),\n  KEY `fk_contract_worksheet_correction` (`contract_id`),\n  KEY `fk_statement_period_worksheet_correction` (`statement_period_id`),\n  KEY `fk_correction_statement_period_worksheet_correction` (`correction_statement_period_id`),\n  CONSTRAINT `fk_account_worksheet_correction` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_contract_worksheet_correction` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_correction_statement_period_worksheet_correction` FOREIGN KEY (`correction_statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_statement_period_worksheet_correction` FOREIGN KEY (`statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "worksheet_flowthrough",
      "type": "BASE TABLE",
      "comment": "Entries for worksheet flowthrough records, tracking individual flowthrough amounts",
      "columns": [
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": true,
          "comment": "Foreign key to account table. NULL if invalid. Original account ID in source_data."
        },
        {
          "name": "activity_month",
          "type": "tinyint unsigned",
          "nullable": true,
          "comment": "Activity month (1-12). NULL if invalid. Original month in source_data."
        },
        {
          "name": "activity_statement_period_id",
          "type": "mediumint unsigned",
          "nullable": true,
          "comment": "Foreign key to statement_period table. Derived from activity_month and activity_year. NULL if statement period could not be determined."
        },
        {
          "name": "activity_year",
          "type": "smallint unsigned",
          "nullable": true,
          "comment": "Activity year (e.g., 2025). NULL if invalid. Original year in source_data."
        },
        {
          "name": "amount",
          "type": "decimal(20,2)",
          "nullable": true,
          "comment": "Amount after rounding. NULL if invalid. Original amount in source_data."
        },
        {
          "name": "amount_raw",
          "type": "decimal(30,12)",
          "nullable": true,
          "comment": "Raw amount. NULL if invalid. Original amount in source_data."
        },
        {
          "name": "batch_row_index",
          "type": "mediumint unsigned",
          "nullable": false,
          "comment": "Zero-based index of this entry within the batch."
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": true,
          "comment": "Foreign key to contract table. NULL if invalid. Original contract ID in source_data."
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false,
          "default": "CURRENT_TIMESTAMP",
          "extra_def": "DEFAULT_GENERATED"
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "errors",
          "type": "json",
          "nullable": true,
          "comment": "Array of error codes. Example: [\"ACCOUNT_ID_NOT_FOUND\"]. NULL if no errors. See table reference_worksheet_flowthrough_error for codes."
        },
        {
          "name": "internal_note",
          "type": "mediumtext",
          "nullable": true,
          "comment": "Internal note for operational purposes. NULL if invalid or not given. Original internal note in source_data."
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false,
          "default": "CURRENT_TIMESTAMP",
          "extra_def": "DEFAULT_GENERATED on update CURRENT_TIMESTAMP"
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "note",
          "type": "mediumtext",
          "nullable": true,
          "comment": "User-visible note about this entry. NULL if invalid. Original note in source_data."
        },
        {
          "name": "source_data",
          "type": "json",
          "nullable": false,
          "comment": "Original source data, before validation. Example: {\"account_id\": \"ABC123\", \"amount\": \"Not a number\", ...}."
        },
        {
          "name": "worksheet_flowthrough_batch_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "comment": "Foreign key to worksheet_flowthrough_batch table."
        },
        {
          "name": "worksheet_flowthrough_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment",
          "comment": "Primary key."
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (worksheet_flowthrough_id) USING BTREE",
          "table": "worksheet_flowthrough",
          "columns": [
            "worksheet_flowthrough_id"
          ]
        },
        {
          "name": "fk_worksheet_flowthrough_account",
          "def": "KEY fk_worksheet_flowthrough_account (account_id) USING BTREE",
          "table": "worksheet_flowthrough",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_worksheet_flowthrough_contract",
          "def": "KEY fk_worksheet_flowthrough_contract (contract_id) USING BTREE",
          "table": "worksheet_flowthrough",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_worksheet_flowthrough_statement_period",
          "def": "KEY fk_worksheet_flowthrough_statement_period (activity_statement_period_id) USING BTREE",
          "table": "worksheet_flowthrough",
          "columns": [
            "activity_statement_period_id"
          ]
        },
        {
          "name": "fk_worksheet_flowthrough_worksheet_flowthrough_batch",
          "def": "KEY fk_worksheet_flowthrough_worksheet_flowthrough_batch (worksheet_flowthrough_batch_id) USING BTREE",
          "table": "worksheet_flowthrough",
          "columns": [
            "worksheet_flowthrough_batch_id"
          ]
        },
        {
          "name": "uidx_batch_row",
          "def": "UNIQUE KEY uidx_batch_row (worksheet_flowthrough_batch_id, batch_row_index) USING BTREE",
          "table": "worksheet_flowthrough",
          "columns": [
            "worksheet_flowthrough_batch_id",
            "batch_row_index"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (worksheet_flowthrough_id)",
          "table": "worksheet_flowthrough",
          "columns": [
            "worksheet_flowthrough_id"
          ]
        },
        {
          "name": "fk_worksheet_flowthrough_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "worksheet_flowthrough",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_worksheet_flowthrough_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "worksheet_flowthrough",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_worksheet_flowthrough_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (activity_statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "worksheet_flowthrough",
          "referenced_table": "statement_period",
          "columns": [
            "activity_statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_worksheet_flowthrough_worksheet_flowthrough_batch",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (worksheet_flowthrough_batch_id) REFERENCES worksheet_flowthrough_batch (worksheet_flowthrough_batch_id)",
          "table": "worksheet_flowthrough",
          "referenced_table": "worksheet_flowthrough_batch",
          "columns": [
            "worksheet_flowthrough_batch_id"
          ],
          "referenced_columns": [
            "worksheet_flowthrough_batch_id"
          ]
        },
        {
          "name": "uidx_batch_row",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_batch_row (worksheet_flowthrough_batch_id, batch_row_index)",
          "table": "worksheet_flowthrough",
          "columns": [
            "worksheet_flowthrough_batch_id",
            "batch_row_index"
          ]
        }
      ],
      "def": "CREATE TABLE `worksheet_flowthrough` (\n  `worksheet_flowthrough_id` mediumint unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key.',\n  `worksheet_flowthrough_batch_id` mediumint unsigned NOT NULL COMMENT 'Foreign key to worksheet_flowthrough_batch table.',\n  `batch_row_index` mediumint unsigned NOT NULL COMMENT 'Zero-based index of this entry within the batch.',\n  `source_data` json NOT NULL COMMENT 'Original source data, before validation. Example: {\"account_id\": \"ABC123\", \"amount\": \"Not a number\", ...}.',\n  `account_id` mediumint unsigned DEFAULT NULL COMMENT 'Foreign key to account table. NULL if invalid. Original account ID in source_data.',\n  `contract_id` mediumint unsigned DEFAULT NULL COMMENT 'Foreign key to contract table. NULL if invalid. Original contract ID in source_data.',\n  `amount` decimal(20,2) DEFAULT NULL COMMENT 'Amount after rounding. NULL if invalid. Original amount in source_data.',\n  `amount_raw` decimal(30,12) DEFAULT NULL COMMENT 'Raw amount. NULL if invalid. Original amount in source_data.',\n  `activity_month` tinyint unsigned DEFAULT NULL COMMENT 'Activity month (1-12). NULL if invalid. Original month in source_data.',\n  `activity_year` smallint unsigned DEFAULT NULL COMMENT 'Activity year (e.g., 2025). NULL if invalid. Original year in source_data.',\n  `activity_statement_period_id` mediumint unsigned DEFAULT NULL COMMENT 'Foreign key to statement_period table. Derived from activity_month and activity_year. NULL if statement period could not be determined.',\n  `note` mediumtext COMMENT 'User-visible note about this entry. NULL if invalid. Original note in source_data.',\n  `internal_note` mediumtext COMMENT 'Internal note for operational purposes. NULL if invalid or not given. Original internal note in source_data.',\n  `errors` json DEFAULT NULL COMMENT 'Array of error codes. Example: [\"ACCOUNT_ID_NOT_FOUND\"]. NULL if no errors. See table reference_worksheet_flowthrough_error for codes.',\n  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,\n  `created_by` varchar(180) NOT NULL,\n  `last_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n  `last_modified_by` varchar(180) NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(180) DEFAULT NULL,\n  PRIMARY KEY (`worksheet_flowthrough_id`),\n  UNIQUE KEY `uidx_batch_row` (`worksheet_flowthrough_batch_id`,`batch_row_index`) COMMENT 'Ensures unique batch row indexes per batch.',\n  KEY `fk_worksheet_flowthrough_worksheet_flowthrough_batch` (`worksheet_flowthrough_batch_id`),\n  KEY `fk_worksheet_flowthrough_account` (`account_id`),\n  KEY `fk_worksheet_flowthrough_contract` (`contract_id`),\n  KEY `fk_worksheet_flowthrough_statement_period` (`activity_statement_period_id`),\n  CONSTRAINT `fk_worksheet_flowthrough_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE,\n  CONSTRAINT `fk_worksheet_flowthrough_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE,\n  CONSTRAINT `fk_worksheet_flowthrough_statement_period` FOREIGN KEY (`activity_statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE RESTRICT,\n  CONSTRAINT `fk_worksheet_flowthrough_worksheet_flowthrough_batch` FOREIGN KEY (`worksheet_flowthrough_batch_id`) REFERENCES `worksheet_flowthrough_batch` (`worksheet_flowthrough_batch_id`) ON DELETE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='Entries for worksheet flowthrough records, tracking individual flowthrough amounts'"
    },
    {
      "name": "worksheet_flowthrough_batch",
      "type": "BASE TABLE",
      "comment": "Batches of flowthrough data from file uploads, UI entry, or automatic generation. Tracks processing and approval statuses.",
      "columns": [
        {
          "name": "batch_status",
          "type": "enum('pending','scanning','validating','importing','pending_approval','approved','rejected','error')",
          "nullable": false,
          "default": "pending",
          "comment": "Processing and approval status: pending (queued), scanning (AV check), validating (rules check), importing (writing to DB), pending_approval (awaiting human review), approved (accepted), rejected (declined), error (failed processing)."
        },
        {
          "name": "batch_type",
          "type": "enum('auto','manual','upload')",
          "nullable": false,
          "comment": "Batch creation type: auto (generated), manual (UI entry), upload (file upload)."
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false,
          "default": "CURRENT_TIMESTAMP",
          "extra_def": "DEFAULT_GENERATED"
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "error_row_count",
          "type": "mediumint unsigned",
          "nullable": true,
          "comment": "Number of batch rows with errors."
        },
        {
          "name": "errors",
          "type": "json",
          "nullable": true,
          "comment": "Array of error codes. Example: [\"HEADER_MISSING\"]. NULL if no errors. See table reference_worksheet_flowthrough_batch_error for codes."
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false,
          "default": "CURRENT_TIMESTAMP",
          "extra_def": "DEFAULT_GENERATED on update CURRENT_TIMESTAMP"
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "row_level_error_count",
          "type": "mediumint unsigned",
          "nullable": true,
          "comment": "Number of errors in batch rows (a single row can have multiple errors). Does not include batch-level errors."
        },
        {
          "name": "source_file_upload_id",
          "type": "mediumint unsigned",
          "nullable": true,
          "comment": "The uploaded source file that created this batch. NULL for manual/auto batch types."
        },
        {
          "name": "statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "comment": "Foreign key to statement_period table."
        },
        {
          "name": "total_amount",
          "type": "decimal(30,2)",
          "nullable": true,
          "comment": "Sum of imported amounts after rounding (mixed currencies, not normalized)."
        },
        {
          "name": "total_amount_raw",
          "type": "decimal(40,12)",
          "nullable": true,
          "comment": "Sum of raw amounts from source (mixed currencies, not normalized). Used as checksum to verify import integrity."
        },
        {
          "name": "total_row_count",
          "type": "mediumint unsigned",
          "nullable": true,
          "comment": "Total number of batch rows. See worksheet_flowthrough for row data."
        },
        {
          "name": "worksheet_flowthrough_batch_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment",
          "comment": "Primary key."
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (worksheet_flowthrough_batch_id) USING BTREE",
          "table": "worksheet_flowthrough_batch",
          "columns": [
            "worksheet_flowthrough_batch_id"
          ]
        },
        {
          "name": "fk_worksheet_flowthrough_batch_source_file",
          "def": "KEY fk_worksheet_flowthrough_batch_source_file (source_file_upload_id) USING BTREE",
          "table": "worksheet_flowthrough_batch",
          "columns": [
            "source_file_upload_id"
          ]
        },
        {
          "name": "fk_worksheet_flowthrough_batch_statement_period",
          "def": "KEY fk_worksheet_flowthrough_batch_statement_period (statement_period_id) USING BTREE",
          "table": "worksheet_flowthrough_batch",
          "columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "idx_batch_status",
          "def": "KEY idx_batch_status (batch_status) USING BTREE",
          "table": "worksheet_flowthrough_batch",
          "columns": [
            "batch_status"
          ]
        },
        {
          "name": "idx_created_at",
          "def": "KEY idx_created_at (created_at) USING BTREE",
          "table": "worksheet_flowthrough_batch",
          "columns": [
            "created_at"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (worksheet_flowthrough_batch_id)",
          "table": "worksheet_flowthrough_batch",
          "columns": [
            "worksheet_flowthrough_batch_id"
          ]
        },
        {
          "name": "fk_worksheet_flowthrough_batch_source_file",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (source_file_upload_id) REFERENCES file_upload (file_upload_id)",
          "table": "worksheet_flowthrough_batch",
          "referenced_table": "file_upload",
          "columns": [
            "source_file_upload_id"
          ],
          "referenced_columns": [
            "file_upload_id"
          ]
        },
        {
          "name": "fk_worksheet_flowthrough_batch_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "worksheet_flowthrough_batch",
          "referenced_table": "statement_period",
          "columns": [
            "statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        }
      ],
      "def": "CREATE TABLE `worksheet_flowthrough_batch` (\n  `worksheet_flowthrough_batch_id` mediumint unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key.',\n  `statement_period_id` mediumint unsigned NOT NULL COMMENT 'Foreign key to statement_period table.',\n  `source_file_upload_id` mediumint unsigned DEFAULT NULL COMMENT 'The uploaded source file that created this batch. NULL for manual/auto batch types.',\n  `batch_type` enum('auto','manual','upload') NOT NULL COMMENT 'Batch creation type: auto (generated), manual (UI entry), upload (file upload).',\n  `batch_status` enum('pending','scanning','validating','importing','pending_approval','approved','rejected','error') NOT NULL DEFAULT 'pending' COMMENT 'Processing and approval status: pending (queued), scanning (AV check), validating (rules check), importing (writing to DB), pending_approval (awaiting human review), approved (accepted), rejected (declined), error (failed processing).',\n  `errors` json DEFAULT NULL COMMENT 'Array of error codes. Example: [\"HEADER_MISSING\"]. NULL if no errors. See table reference_worksheet_flowthrough_batch_error for codes.',\n  `error_row_count` mediumint unsigned DEFAULT NULL COMMENT 'Number of batch rows with errors.',\n  `row_level_error_count` mediumint unsigned DEFAULT NULL COMMENT 'Number of errors in batch rows (a single row can have multiple errors). Does not include batch-level errors.',\n  `total_row_count` mediumint unsigned DEFAULT NULL COMMENT 'Total number of batch rows. See worksheet_flowthrough for row data.',\n  `total_amount` decimal(30,2) DEFAULT NULL COMMENT 'Sum of imported amounts after rounding (mixed currencies, not normalized).',\n  `total_amount_raw` decimal(40,12) DEFAULT NULL COMMENT 'Sum of raw amounts from source (mixed currencies, not normalized). Used as checksum to verify import integrity.',\n  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,\n  `created_by` varchar(180) NOT NULL,\n  `last_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n  `last_modified_by` varchar(180) NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(180) DEFAULT NULL,\n  PRIMARY KEY (`worksheet_flowthrough_batch_id`),\n  KEY `fk_worksheet_flowthrough_batch_statement_period` (`statement_period_id`),\n  KEY `fk_worksheet_flowthrough_batch_source_file` (`source_file_upload_id`),\n  KEY `idx_batch_status` (`batch_status`) COMMENT 'For filtering by status.',\n  KEY `idx_created_at` (`created_at`) COMMENT 'For sorting by creation date.',\n  CONSTRAINT `fk_worksheet_flowthrough_batch_source_file` FOREIGN KEY (`source_file_upload_id`) REFERENCES `file_upload` (`file_upload_id`) ON DELETE SET NULL,\n  CONSTRAINT `fk_worksheet_flowthrough_batch_statement_period` FOREIGN KEY (`statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE RESTRICT\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='Batches of flowthrough data from file uploads, UI entry, or automatic generation. Tracks processing and approval statuses.'"
    },
    {
      "name": "worksheet_flowthrough_file",
      "type": "BASE TABLE",
      "comment": "Generated download files representing flowthrough batch data in various formats for user consumption.",
      "columns": [
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false,
          "default": "CURRENT_TIMESTAMP",
          "extra_def": "DEFAULT_GENERATED",
          "comment": "When the file was generated."
        },
        {
          "name": "created_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "file_key",
          "type": "varchar(36)",
          "nullable": false,
          "comment": "Unique identifier for the file (UUID)."
        },
        {
          "name": "file_name",
          "type": "varchar(255)",
          "nullable": false,
          "comment": "Generated filename."
        },
        {
          "name": "file_size_bytes",
          "type": "bigint unsigned",
          "nullable": false,
          "comment": "File size in bytes."
        },
        {
          "name": "file_type",
          "type": "varchar(10)",
          "nullable": true,
          "comment": "File extension without leading dot and lowercase (e.g., csv, pdf, xlsx)."
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false,
          "default": "CURRENT_TIMESTAMP",
          "extra_def": "DEFAULT_GENERATED on update CURRENT_TIMESTAMP"
        },
        {
          "name": "last_modified_by",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "s3_key",
          "type": "varchar(1024)",
          "nullable": false,
          "comment": "S3 file location."
        },
        {
          "name": "worksheet_flowthrough_batch_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "comment": "The parent worksheet_flowthrough_batch."
        },
        {
          "name": "worksheet_flowthrough_file_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment",
          "comment": "Primary key."
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (worksheet_flowthrough_file_id) USING BTREE",
          "table": "worksheet_flowthrough_file",
          "columns": [
            "worksheet_flowthrough_file_id"
          ]
        },
        {
          "name": "fk_worksheet_flowthrough_file_worksheet_flowthrough_batch",
          "def": "KEY fk_worksheet_flowthrough_file_worksheet_flowthrough_batch (worksheet_flowthrough_batch_id) USING BTREE",
          "table": "worksheet_flowthrough_file",
          "columns": [
            "worksheet_flowthrough_batch_id"
          ]
        },
        {
          "name": "idx_batch_file_type",
          "def": "KEY idx_batch_file_type (worksheet_flowthrough_batch_id, file_type) USING BTREE",
          "table": "worksheet_flowthrough_file",
          "columns": [
            "worksheet_flowthrough_batch_id",
            "file_type"
          ]
        },
        {
          "name": "uidx_file_key",
          "def": "UNIQUE KEY uidx_file_key (file_key) USING BTREE",
          "table": "worksheet_flowthrough_file",
          "columns": [
            "file_key"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (worksheet_flowthrough_file_id)",
          "table": "worksheet_flowthrough_file",
          "columns": [
            "worksheet_flowthrough_file_id"
          ]
        },
        {
          "name": "fk_worksheet_flowthrough_file_worksheet_flowthrough_batch",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (worksheet_flowthrough_batch_id) REFERENCES worksheet_flowthrough_batch (worksheet_flowthrough_batch_id)",
          "table": "worksheet_flowthrough_file",
          "referenced_table": "worksheet_flowthrough_batch",
          "columns": [
            "worksheet_flowthrough_batch_id"
          ],
          "referenced_columns": [
            "worksheet_flowthrough_batch_id"
          ]
        },
        {
          "name": "uidx_file_key",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uidx_file_key (file_key)",
          "table": "worksheet_flowthrough_file",
          "columns": [
            "file_key"
          ]
        }
      ],
      "def": "CREATE TABLE `worksheet_flowthrough_file` (\n  `worksheet_flowthrough_file_id` mediumint unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key.',\n  `worksheet_flowthrough_batch_id` mediumint unsigned NOT NULL COMMENT 'The parent worksheet_flowthrough_batch.',\n  `file_key` varchar(36) NOT NULL COMMENT 'Unique identifier for the file (UUID).',\n  `file_name` varchar(255) NOT NULL COMMENT 'Generated filename.',\n  `file_size_bytes` bigint unsigned NOT NULL COMMENT 'File size in bytes.',\n  `file_type` varchar(10) DEFAULT NULL COMMENT 'File extension without leading dot and lowercase (e.g., csv, pdf, xlsx).',\n  `s3_key` varchar(1024) NOT NULL COMMENT 'S3 file location.',\n  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'When the file was generated.',\n  `created_by` varchar(180) NOT NULL,\n  `last_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n  `last_modified_by` varchar(180) NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(180) DEFAULT NULL,\n  PRIMARY KEY (`worksheet_flowthrough_file_id`),\n  UNIQUE KEY `uidx_file_key` (`file_key`) COMMENT 'Ensures file_key is unique across all files.',\n  KEY `idx_batch_file_type` (`worksheet_flowthrough_batch_id`,`file_type`) COMMENT 'Find files by batch and type.',\n  KEY `fk_worksheet_flowthrough_file_worksheet_flowthrough_batch` (`worksheet_flowthrough_batch_id`),\n  CONSTRAINT `fk_worksheet_flowthrough_file_worksheet_flowthrough_batch` FOREIGN KEY (`worksheet_flowthrough_batch_id`) REFERENCES `worksheet_flowthrough_batch` (`worksheet_flowthrough_batch_id`) ON DELETE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='Generated download files representing flowthrough batch data in various formats for user consumption.'"
    },
    {
      "name": "worksheet_payment_contract_advance",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "amount",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "amount_after_withholding_and_vat",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "amount_after_withholding_and_vat_payee_currency",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "amount_payee_currency",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "contract_advance_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "exchange_rate",
          "type": "decimal(30,19)",
          "nullable": false
        },
        {
          "name": "exchange_rate_statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "is_internal",
          "type": "tinyint(1)",
          "nullable": false,
          "default": "0"
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "payee_currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "payment_name",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "salesforce_id",
          "type": "varchar(180)",
          "nullable": true
        },
        {
          "name": "statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "us_source_income_rate",
          "type": "decimal(9,6) unsigned",
          "nullable": true
        },
        {
          "name": "vat_amount",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "vat_amount_payee_currency",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "withholding_tax_amount",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "withholding_tax_amount_payee_currency",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "worksheet_payment_contract_advance_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (worksheet_payment_contract_advance_id) USING BTREE",
          "table": "worksheet_payment_contract_advance",
          "columns": [
            "worksheet_payment_contract_advance_id"
          ]
        },
        {
          "name": "fk_contract_advance",
          "def": "KEY fk_contract_advance (contract_advance_id) USING BTREE",
          "table": "worksheet_payment_contract_advance",
          "columns": [
            "contract_advance_id"
          ]
        },
        {
          "name": "fk_exchange_rate_statement_period_id",
          "def": "KEY fk_exchange_rate_statement_period_id (exchange_rate_statement_period_id) USING BTREE",
          "table": "worksheet_payment_contract_advance",
          "columns": [
            "exchange_rate_statement_period_id"
          ]
        },
        {
          "name": "fk_statement_period",
          "def": "KEY fk_statement_period (statement_period_id) USING BTREE",
          "table": "worksheet_payment_contract_advance",
          "columns": [
            "statement_period_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (worksheet_payment_contract_advance_id)",
          "table": "worksheet_payment_contract_advance",
          "columns": [
            "worksheet_payment_contract_advance_id"
          ]
        },
        {
          "name": "fk_contract_advance",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_advance_id) REFERENCES contract_advance (contract_advance_id)",
          "table": "worksheet_payment_contract_advance",
          "referenced_table": "contract_advance",
          "columns": [
            "contract_advance_id"
          ],
          "referenced_columns": [
            "contract_advance_id"
          ]
        },
        {
          "name": "fk_exchange_rate_statement_period_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (exchange_rate_statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "worksheet_payment_contract_advance",
          "referenced_table": "statement_period",
          "columns": [
            "exchange_rate_statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "worksheet_payment_contract_advance",
          "referenced_table": "statement_period",
          "columns": [
            "statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        }
      ],
      "def": "CREATE TABLE `worksheet_payment_contract_advance` (\n  `worksheet_payment_contract_advance_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `contract_advance_id` mediumint unsigned NOT NULL,\n  `statement_period_id` mediumint unsigned NOT NULL,\n  `exchange_rate_statement_period_id` mediumint unsigned NOT NULL,\n  `payment_name` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,\n  `amount` decimal(20,2) NOT NULL,\n  `currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `amount_payee_currency` decimal(20,2) NOT NULL,\n  `payee_currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,\n  `exchange_rate` decimal(30,19) NOT NULL,\n  `withholding_tax_amount` decimal(20,2) NOT NULL,\n  `vat_amount` decimal(20,2) NOT NULL,\n  `amount_after_withholding_and_vat` decimal(20,2) NOT NULL,\n  `withholding_tax_amount_payee_currency` decimal(20,2) NOT NULL,\n  `vat_amount_payee_currency` decimal(20,2) NOT NULL,\n  `amount_after_withholding_and_vat_payee_currency` decimal(20,2) NOT NULL,\n  `us_source_income_rate` decimal(9,6) unsigned DEFAULT NULL,\n  `salesforce_id` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  `is_internal` tinyint(1) NOT NULL DEFAULT '0',\n  `created_at` datetime NOT NULL,\n  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n  PRIMARY KEY (`worksheet_payment_contract_advance_id`),\n  KEY `fk_contract_advance` (`contract_advance_id`),\n  KEY `fk_statement_period` (`statement_period_id`),\n  KEY `fk_exchange_rate_statement_period_id` (`exchange_rate_statement_period_id`),\n  CONSTRAINT `fk_contract_advance` FOREIGN KEY (`contract_advance_id`) REFERENCES `contract_advance` (`contract_advance_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_exchange_rate_statement_period_id` FOREIGN KEY (`exchange_rate_statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_statement_period` FOREIGN KEY (`statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
    },
    {
      "name": "worksheet_payment_custom",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "activity_statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "amount",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "amount_after_withholding_and_vat",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "payment_name",
          "type": "varchar(180)",
          "nullable": false
        },
        {
          "name": "statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "vat_amount",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "withholding_tax_amount",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "worksheet_payment_custom_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (worksheet_payment_custom_id) USING BTREE",
          "table": "worksheet_payment_custom",
          "columns": [
            "worksheet_payment_custom_id"
          ]
        },
        {
          "name": "fk_worksheet_payment_custom_account",
          "def": "KEY fk_worksheet_payment_custom_account (account_id) USING BTREE",
          "table": "worksheet_payment_custom",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_worksheet_payment_custom_activity_statement_period",
          "def": "KEY fk_worksheet_payment_custom_activity_statement_period (activity_statement_period_id) USING BTREE",
          "table": "worksheet_payment_custom",
          "columns": [
            "activity_statement_period_id"
          ]
        },
        {
          "name": "fk_worksheet_payment_custom_contract",
          "def": "KEY fk_worksheet_payment_custom_contract (contract_id) USING BTREE",
          "table": "worksheet_payment_custom",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_worksheet_payment_custom_statement_period",
          "def": "KEY fk_worksheet_payment_custom_statement_period (statement_period_id) USING BTREE",
          "table": "worksheet_payment_custom",
          "columns": [
            "statement_period_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (worksheet_payment_custom_id)",
          "table": "worksheet_payment_custom",
          "columns": [
            "worksheet_payment_custom_id"
          ]
        },
        {
          "name": "fk_worksheet_payment_custom_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "worksheet_payment_custom",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_worksheet_payment_custom_activity_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (activity_statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "worksheet_payment_custom",
          "referenced_table": "statement_period",
          "columns": [
            "activity_statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        },
        {
          "name": "fk_worksheet_payment_custom_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "worksheet_payment_custom",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_worksheet_payment_custom_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "worksheet_payment_custom",
          "referenced_table": "statement_period",
          "columns": [
            "statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        }
      ],
      "def": "CREATE TABLE `worksheet_payment_custom` (\n  `worksheet_payment_custom_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `account_id` mediumint unsigned NOT NULL,\n  `contract_id` mediumint unsigned NOT NULL,\n  `currency_code` char(3) NOT NULL,\n  `amount` decimal(20,2) NOT NULL,\n  `withholding_tax_amount` decimal(20,2) DEFAULT NULL,\n  `vat_amount` decimal(20,2) DEFAULT NULL,\n  `amount_after_withholding_and_vat` decimal(20,2) NOT NULL,\n  `activity_statement_period_id` mediumint unsigned NOT NULL,\n  `statement_period_id` mediumint unsigned NOT NULL,\n  `payment_name` varchar(180) NOT NULL,\n  `created_at` datetime NOT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(255) DEFAULT NULL,\n  PRIMARY KEY (`worksheet_payment_custom_id`),\n  KEY `fk_worksheet_payment_custom_account` (`account_id`),\n  KEY `fk_worksheet_payment_custom_contract` (`contract_id`),\n  KEY `fk_worksheet_payment_custom_activity_statement_period` (`activity_statement_period_id`),\n  KEY `fk_worksheet_payment_custom_statement_period` (`statement_period_id`),\n  CONSTRAINT `fk_worksheet_payment_custom_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_worksheet_payment_custom_activity_statement_period` FOREIGN KEY (`activity_statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_worksheet_payment_custom_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_worksheet_payment_custom_statement_period` FOREIGN KEY (`statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci"
    },
    {
      "name": "worksheet_tax_correction",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "amount",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "correction_statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "note",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "payable_detail_type_id",
          "type": "tinyint unsigned",
          "nullable": false
        },
        {
          "name": "worksheet_tax_correction_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (worksheet_tax_correction_id) USING BTREE",
          "table": "worksheet_tax_correction",
          "columns": [
            "worksheet_tax_correction_id"
          ]
        },
        {
          "name": "fk_tc_account",
          "def": "KEY fk_tc_account (account_id) USING BTREE",
          "table": "worksheet_tax_correction",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_tc_contract",
          "def": "KEY fk_tc_contract (contract_id) USING BTREE",
          "table": "worksheet_tax_correction",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_tc_ref_payable_detail",
          "def": "KEY fk_tc_ref_payable_detail (payable_detail_type_id) USING BTREE",
          "table": "worksheet_tax_correction",
          "columns": [
            "payable_detail_type_id"
          ]
        },
        {
          "name": "idx_correction_statement_period_id_contract_id",
          "def": "KEY idx_correction_statement_period_id_contract_id (correction_statement_period_id, contract_id) USING BTREE",
          "table": "worksheet_tax_correction",
          "columns": [
            "correction_statement_period_id",
            "contract_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (worksheet_tax_correction_id)",
          "table": "worksheet_tax_correction",
          "columns": [
            "worksheet_tax_correction_id"
          ]
        },
        {
          "name": "fk_tc_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "worksheet_tax_correction",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_tc_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "worksheet_tax_correction",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_tc_ref_payable_detail",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (payable_detail_type_id) REFERENCES reference_payable_detail_type (reference_payable_detail_type_id)",
          "table": "worksheet_tax_correction",
          "referenced_table": "reference_payable_detail_type",
          "columns": [
            "payable_detail_type_id"
          ],
          "referenced_columns": [
            "reference_payable_detail_type_id"
          ]
        },
        {
          "name": "fk_tc_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (correction_statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "worksheet_tax_correction",
          "referenced_table": "statement_period",
          "columns": [
            "correction_statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        }
      ],
      "def": "CREATE TABLE `worksheet_tax_correction` (\n  `worksheet_tax_correction_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `contract_id` mediumint unsigned NOT NULL,\n  `account_id` mediumint unsigned NOT NULL,\n  `correction_statement_period_id` mediumint unsigned NOT NULL,\n  `payable_detail_type_id` tinyint unsigned NOT NULL,\n  `amount` decimal(20,2) NOT NULL,\n  `currency_code` char(3) NOT NULL,\n  `note` varchar(255) DEFAULT NULL,\n  `created_at` datetime NOT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(255) DEFAULT NULL,\n  PRIMARY KEY (`worksheet_tax_correction_id`),\n  KEY `fk_tc_contract` (`contract_id`),\n  KEY `fk_tc_account` (`account_id`),\n  KEY `fk_tc_ref_payable_detail` (`payable_detail_type_id`),\n  KEY `idx_correction_statement_period_id_contract_id` (`correction_statement_period_id`,`contract_id`),\n  CONSTRAINT `fk_tc_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_tc_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_tc_ref_payable_detail` FOREIGN KEY (`payable_detail_type_id`) REFERENCES `reference_payable_detail_type` (`reference_payable_detail_type_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_tc_statement_period` FOREIGN KEY (`correction_statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3"
    },
    {
      "name": "worksheet_tax_correction_vat",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "account_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "base_amount_payee_currency",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "contract_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "correction_statement_period_id",
          "type": "mediumint unsigned",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "created_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "deleted_at",
          "type": "datetime",
          "nullable": true
        },
        {
          "name": "deleted_by",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "last_modified",
          "type": "datetime",
          "nullable": false
        },
        {
          "name": "last_modified_by",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "net_amount_payee_currency",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "note",
          "type": "varchar(255)",
          "nullable": true
        },
        {
          "name": "payable_detail_type_id",
          "type": "tinyint unsigned",
          "nullable": false
        },
        {
          "name": "payee_currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "vat_amount_payee_currency",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "vat_amount_vat_currency",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "vat_category",
          "type": "enum('gross_revenue','distribution_fee','closing_balance','commission')",
          "nullable": true
        },
        {
          "name": "vat_currency_code",
          "type": "char(3)",
          "nullable": false
        },
        {
          "name": "vat_rate",
          "type": "decimal(20,2)",
          "nullable": false
        },
        {
          "name": "wht_amount_payee_currency",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "wht_amount_vat_currency",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "wht_rate",
          "type": "decimal(20,2)",
          "nullable": true
        },
        {
          "name": "worksheet_tax_correction_vat_id",
          "type": "mediumint unsigned",
          "nullable": false,
          "extra_def": "auto_increment"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (worksheet_tax_correction_vat_id) USING BTREE",
          "table": "worksheet_tax_correction_vat",
          "columns": [
            "worksheet_tax_correction_vat_id"
          ]
        },
        {
          "name": "fk_tcv_account",
          "def": "KEY fk_tcv_account (account_id) USING BTREE",
          "table": "worksheet_tax_correction_vat",
          "columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_tcv_contract",
          "def": "KEY fk_tcv_contract (contract_id) USING BTREE",
          "table": "worksheet_tax_correction_vat",
          "columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_tcv_ref_payable_detail",
          "def": "KEY fk_tcv_ref_payable_detail (payable_detail_type_id) USING BTREE",
          "table": "worksheet_tax_correction_vat",
          "columns": [
            "payable_detail_type_id"
          ]
        },
        {
          "name": "fk_tcv_statement_period",
          "def": "KEY fk_tcv_statement_period (correction_statement_period_id) USING BTREE",
          "table": "worksheet_tax_correction_vat",
          "columns": [
            "correction_statement_period_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (worksheet_tax_correction_vat_id)",
          "table": "worksheet_tax_correction_vat",
          "columns": [
            "worksheet_tax_correction_vat_id"
          ]
        },
        {
          "name": "fk_tcv_account",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)",
          "table": "worksheet_tax_correction_vat",
          "referenced_table": "account",
          "columns": [
            "account_id"
          ],
          "referenced_columns": [
            "account_id"
          ]
        },
        {
          "name": "fk_tcv_contract",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)",
          "table": "worksheet_tax_correction_vat",
          "referenced_table": "contract",
          "columns": [
            "contract_id"
          ],
          "referenced_columns": [
            "contract_id"
          ]
        },
        {
          "name": "fk_tcv_ref_payable_detail",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (payable_detail_type_id) REFERENCES reference_payable_detail_type (reference_payable_detail_type_id)",
          "table": "worksheet_tax_correction_vat",
          "referenced_table": "reference_payable_detail_type",
          "columns": [
            "payable_detail_type_id"
          ],
          "referenced_columns": [
            "reference_payable_detail_type_id"
          ]
        },
        {
          "name": "fk_tcv_statement_period",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (correction_statement_period_id) REFERENCES statement_period (statement_period_id)",
          "table": "worksheet_tax_correction_vat",
          "referenced_table": "statement_period",
          "columns": [
            "correction_statement_period_id"
          ],
          "referenced_columns": [
            "statement_period_id"
          ]
        }
      ],
      "def": "CREATE TABLE `worksheet_tax_correction_vat` (\n  `worksheet_tax_correction_vat_id` mediumint unsigned NOT NULL AUTO_INCREMENT,\n  `payable_detail_type_id` tinyint unsigned NOT NULL,\n  `contract_id` mediumint unsigned NOT NULL,\n  `account_id` mediumint unsigned NOT NULL,\n  `correction_statement_period_id` mediumint unsigned NOT NULL,\n  `vat_category` enum('gross_revenue','distribution_fee','closing_balance','commission') DEFAULT NULL,\n  `base_amount_payee_currency` decimal(20,2) NOT NULL,\n  `payee_currency_code` char(3) NOT NULL,\n  `vat_currency_code` char(3) NOT NULL,\n  `vat_rate` decimal(20,2) NOT NULL,\n  `vat_amount_payee_currency` decimal(20,2) NOT NULL,\n  `vat_amount_vat_currency` decimal(20,2) NOT NULL,\n  `net_amount_payee_currency` decimal(20,2) NOT NULL,\n  `wht_rate` decimal(20,2) DEFAULT NULL,\n  `wht_amount_payee_currency` decimal(20,2) DEFAULT NULL,\n  `wht_amount_vat_currency` decimal(20,2) DEFAULT NULL,\n  `note` varchar(255) DEFAULT NULL,\n  `created_at` datetime NOT NULL,\n  `created_by` varchar(255) NOT NULL,\n  `last_modified` datetime NOT NULL,\n  `last_modified_by` varchar(255) NOT NULL,\n  `deleted_at` datetime DEFAULT NULL,\n  `deleted_by` varchar(255) DEFAULT NULL,\n  PRIMARY KEY (`worksheet_tax_correction_vat_id`),\n  KEY `fk_tcv_contract` (`contract_id`),\n  KEY `fk_tcv_account` (`account_id`),\n  KEY `fk_tcv_statement_period` (`correction_statement_period_id`),\n  KEY `fk_tcv_ref_payable_detail` (`payable_detail_type_id`),\n  CONSTRAINT `fk_tcv_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_tcv_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_tcv_ref_payable_detail` FOREIGN KEY (`payable_detail_type_id`) REFERENCES `reference_payable_detail_type` (`reference_payable_detail_type_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n  CONSTRAINT `fk_tcv_statement_period` FOREIGN KEY (`correction_statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3"
    }
  ],
  "relations": [
    {
      "table": "abacus_event",
      "columns": [
        "statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "abacus_state_history",
      "columns": [
        "abacus_state_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "abacus_state",
      "parent_columns": [
        "abacus_state_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (abacus_state_id) REFERENCES abacus_state (abacus_state_id)"
    },
    {
      "table": "account_contract",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "account_contract",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_one",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "account_contract_vat_detail",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "account_contract_vat_detail",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "account_payee",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_one",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "account_payee",
      "columns": [
        "payoneer_program_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_payoneer_program",
      "parent_columns": [
        "payoneer_program_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (payoneer_program_id) REFERENCES reference_payoneer_program (payoneer_program_id)"
    },
    {
      "table": "account_payee",
      "columns": [
        "reference_payment_type_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_payment_type",
      "parent_columns": [
        "reference_payment_type_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (reference_payment_type_id) REFERENCES reference_payment_type (reference_payment_type_id)"
    },
    {
      "table": "account_payee_history",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "account_payee_history",
      "columns": [
        "account_payee_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account_payee",
      "parent_columns": [
        "account_payee_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_payee_id) REFERENCES account_payee (account_payee_id)"
    },
    {
      "table": "account_payee_kyc_notification",
      "columns": [
        "account_payee_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account_payee",
      "parent_columns": [
        "account_payee_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_payee_id) REFERENCES account_payee (account_payee_id)"
    },
    {
      "table": "account_payee_tax_form_info",
      "columns": [
        "account_payee_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account_payee",
      "parent_columns": [
        "account_payee_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_payee_id) REFERENCES account_payee (account_payee_id)"
    },
    {
      "table": "account_payment_term",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_one",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "account_payment_term",
      "columns": [
        "agreement_type_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_agreement_type",
      "parent_columns": [
        "reference_agreement_type_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (agreement_type_id) REFERENCES reference_agreement_type (reference_agreement_type_id)"
    },
    {
      "table": "account_payment_term",
      "columns": [
        "payment_entity_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_payment_entity",
      "parent_columns": [
        "reference_payment_entity_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (payment_entity_id) REFERENCES reference_payment_entity (reference_payment_entity_id)"
    },
    {
      "table": "account_payment_term_history",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "account_payment_term_history",
      "columns": [
        "payment_entity_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_payment_entity",
      "parent_columns": [
        "reference_payment_entity_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (payment_entity_id) REFERENCES reference_payment_entity (reference_payment_entity_id)"
    },
    {
      "table": "account_payment_term_history",
      "columns": [
        "account_payment_term_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account_payment_term",
      "parent_columns": [
        "account_payment_term_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_payment_term_id) REFERENCES account_payment_term (account_payment_term_id)"
    },
    {
      "table": "account_tax_info",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_one",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "account_tax_info_history",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "account_tax_info_history",
      "columns": [
        "account_tax_info_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account_tax_info",
      "parent_columns": [
        "account_tax_info_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_tax_info_id) REFERENCES account_tax_info (account_tax_info_id)"
    },
    {
      "table": "accounting_period",
      "columns": [
        "statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "accounting_period_report",
      "columns": [
        "accounting_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "accounting_period",
      "parent_columns": [
        "accounting_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (accounting_period_id) REFERENCES accounting_period (accounting_period_id)"
    },
    {
      "table": "accounting_run",
      "columns": [
        "run_controller_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "run_controller",
      "parent_columns": [
        "run_controller_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (run_controller_id) REFERENCES run_controller (run_controller_id)"
    },
    {
      "table": "accounting_run",
      "columns": [
        "accounting_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "accounting_period",
      "parent_columns": [
        "accounting_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (accounting_period_id) REFERENCES accounting_period (accounting_period_id)"
    },
    {
      "table": "contract",
      "columns": [
        "reference_signing_entity_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_signing_entity",
      "parent_columns": [
        "reference_signing_entity_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (reference_signing_entity_id) REFERENCES reference_signing_entity (reference_signing_entity_id)"
    },
    {
      "table": "contract_advance",
      "columns": [
        "reference_advance_payment_method_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_advance_payment_method",
      "parent_columns": [
        "reference_advance_payment_method_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (reference_advance_payment_method_id) REFERENCES reference_advance_payment_method (reference_advance_payment_method_id)"
    },
    {
      "table": "contract_advance",
      "columns": [
        "reference_payment_type_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_payment_type",
      "parent_columns": [
        "reference_payment_type_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (reference_payment_type_id) REFERENCES reference_payment_type (reference_payment_type_id)"
    },
    {
      "table": "contract_advance",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "contract_advance_history",
      "columns": [
        "contract_advance_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract_advance",
      "parent_columns": [
        "contract_advance_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_advance_id) REFERENCES contract_advance (contract_advance_id)"
    },
    {
      "table": "contract_advance_history",
      "columns": [
        "reference_advance_payment_method_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_advance_payment_method",
      "parent_columns": [
        "reference_advance_payment_method_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (reference_advance_payment_method_id) REFERENCES reference_advance_payment_method (reference_advance_payment_method_id)"
    },
    {
      "table": "contract_advance_history",
      "columns": [
        "reference_payment_type_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_payment_type",
      "parent_columns": [
        "reference_payment_type_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (reference_payment_type_id) REFERENCES reference_payment_type (reference_payment_type_id)"
    },
    {
      "table": "contract_advance_history",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "contract_exclusion",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_one",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "contract_flowthrough",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "contract_flowthrough",
      "columns": [
        "reference_flowthrough_calculation_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_flowthrough_calculation",
      "parent_columns": [
        "reference_flowthrough_calculation_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (reference_flowthrough_calculation_id) REFERENCES reference_flowthrough_calculation (reference_flowthrough_calculation_id)"
    },
    {
      "table": "contract_history",
      "columns": [
        "reference_signing_entity_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_signing_entity",
      "parent_columns": [
        "reference_signing_entity_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (reference_signing_entity_id) REFERENCES reference_signing_entity (reference_signing_entity_id)"
    },
    {
      "table": "contract_lifecycle",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "contract_lifecycle",
      "columns": [
        "contract_lifecycle_schedule_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract_lifecycle_schedule",
      "parent_columns": [
        "contract_lifecycle_schedule_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_lifecycle_schedule_id) REFERENCES contract_lifecycle_schedule (contract_lifecycle_schedule_id)"
    },
    {
      "table": "contract_lifecycle_schedule",
      "columns": [
        "collection_period_detail_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract_lifecycle_schedule_detail",
      "parent_columns": [
        "contract_lifecycle_schedule_detail_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (collection_period_detail_id) REFERENCES contract_lifecycle_schedule_detail (contract_lifecycle_schedule_detail_id)"
    },
    {
      "table": "contract_lifecycle_schedule",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "contract_lifecycle_schedule",
      "columns": [
        "renewal_offset_detail_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract_lifecycle_schedule_detail",
      "parent_columns": [
        "contract_lifecycle_schedule_detail_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (renewal_offset_detail_id) REFERENCES contract_lifecycle_schedule_detail (contract_lifecycle_schedule_detail_id)"
    },
    {
      "table": "contract_lifecycle_schedule",
      "columns": [
        "termination_notice_detail_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract_lifecycle_schedule_detail",
      "parent_columns": [
        "contract_lifecycle_schedule_detail_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (termination_notice_detail_id) REFERENCES contract_lifecycle_schedule_detail (contract_lifecycle_schedule_detail_id)"
    },
    {
      "table": "contract_mechanical_deduction",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "contract_party",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "contract_party_history",
      "columns": [
        "contract_party_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract_party",
      "parent_columns": [
        "contract_party_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_party_id) REFERENCES contract_party (contract_party_id)"
    },
    {
      "table": "contract_party_history",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "contract_reserve",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "contract_template",
      "columns": [
        "reference_signing_entity_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_signing_entity",
      "parent_columns": [
        "reference_signing_entity_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (reference_signing_entity_id) REFERENCES reference_signing_entity (reference_signing_entity_id)"
    },
    {
      "table": "contract_template",
      "columns": [
        "run_controller_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "run_controller",
      "parent_columns": [
        "run_controller_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (run_controller_id) REFERENCES run_controller (run_controller_id)"
    },
    {
      "table": "contract_term",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "contract_term_condition",
      "columns": [
        "contract_term_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract_term",
      "parent_columns": [
        "contract_term_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_term_id) REFERENCES contract_term (contract_term_id)"
    },
    {
      "table": "contract_term_schedule",
      "columns": [
        "contract_term_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract_term",
      "parent_columns": [
        "contract_term_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_term_id) REFERENCES contract_term (contract_term_id)"
    },
    {
      "table": "contract_term_schedule",
      "columns": [
        "schedule_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "schedule",
      "parent_columns": [
        "schedule_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (schedule_id) REFERENCES schedule (schedule_id)"
    },
    {
      "table": "contract_term_schedule_history",
      "columns": [
        "contract_term_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract_term",
      "parent_columns": [
        "contract_term_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_term_id) REFERENCES contract_term (contract_term_id)"
    },
    {
      "table": "contract_term_schedule_history",
      "columns": [
        "schedule_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "schedule",
      "parent_columns": [
        "schedule_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (schedule_id) REFERENCES schedule (schedule_id)"
    },
    {
      "table": "contract_term_schedule_history",
      "columns": [
        "contract_term_schedule_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract_term_schedule",
      "parent_columns": [
        "contract_term_schedule_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_term_schedule_id) REFERENCES contract_term_schedule (contract_term_schedule_id)"
    },
    {
      "table": "exchange_rate",
      "columns": [
        "statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "file_upload",
      "columns": [
        "file_upload_config_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "file_upload_config",
      "parent_columns": [
        "file_upload_config_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (file_upload_config_id) REFERENCES file_upload_config (file_upload_config_id)"
    },
    {
      "table": "ledger_account",
      "columns": [
        "abacus_event_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "abacus_event",
      "parent_columns": [
        "abacus_event_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)"
    },
    {
      "table": "ledger_account",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "ledger_account",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "ledger_account_contract",
      "columns": [
        "abacus_event_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "abacus_event",
      "parent_columns": [
        "abacus_event_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)"
    },
    {
      "table": "ledger_account_contract",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "ledger_account_contract",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "ledger_account_contract_current_balance",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "ledger_account_contract_current_balance",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_one",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "ledger_account_contract_current_balance",
      "columns": [
        "ledger_account_contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "ledger_account_contract",
      "parent_columns": [
        "ledger_account_contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (ledger_account_contract_id) REFERENCES ledger_account_contract (ledger_account_contract_id)"
    },
    {
      "table": "ledger_account_current_balance",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_one",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "ledger_account_current_balance",
      "columns": [
        "ledger_account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "ledger_account",
      "parent_columns": [
        "ledger_account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (ledger_account_id) REFERENCES ledger_account (ledger_account_id)"
    },
    {
      "table": "ledger_accounting_run_balance",
      "columns": [
        "abacus_event_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "abacus_event",
      "parent_columns": [
        "abacus_event_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)"
    },
    {
      "table": "ledger_accounting_run_balance",
      "columns": [
        "accounting_run_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "accounting_run",
      "parent_columns": [
        "accounting_run_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (accounting_run_id) REFERENCES accounting_run (accounting_run_id)"
    },
    {
      "table": "ledger_accounting_run_balance",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "ledger_accounting_run_vat",
      "columns": [
        "accounting_run_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "accounting_run",
      "parent_columns": [
        "accounting_run_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (accounting_run_id) REFERENCES accounting_run (accounting_run_id)"
    },
    {
      "table": "ledger_accounting_run_vat",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "ledger_accounting_run_vat",
      "columns": [
        "abacus_event_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "abacus_event",
      "parent_columns": [
        "abacus_event_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)"
    },
    {
      "table": "ledger_adjustment",
      "columns": [
        "abacus_event_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "abacus_event",
      "parent_columns": [
        "abacus_event_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)"
    },
    {
      "table": "ledger_adjustment",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "ledger_adjustment",
      "columns": [
        "activity_statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (activity_statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "ledger_adjustment",
      "columns": [
        "apply_to_statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (apply_to_statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "ledger_adjustment",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "ledger_adjustment",
      "columns": [
        "reference_adjustment_type_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_adjustment_type",
      "parent_columns": [
        "reference_adjustment_type_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (reference_adjustment_type_id) REFERENCES reference_adjustment_type (reference_adjustment_type_id)"
    },
    {
      "table": "ledger_adjustment_adjustment_detail",
      "columns": [
        "ledger_adjustment_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "ledger_adjustment",
      "parent_columns": [
        "ledger_adjustment_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (ledger_adjustment_id) REFERENCES ledger_adjustment (ledger_adjustment_id)"
    },
    {
      "table": "ledger_adjustment_adjustment_detail",
      "columns": [
        "ledger_adjustment_detail_id"
      ],
      "cardinality": "zero_or_one",
      "parent_table": "ledger_adjustment_detail",
      "parent_columns": [
        "ledger_adjustment_detail_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (ledger_adjustment_detail_id) REFERENCES ledger_adjustment_detail (ledger_adjustment_detail_id)"
    },
    {
      "table": "ledger_adjustment_adjustment_detail_applied",
      "columns": [
        "ledger_adjustment_applied_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "ledger_adjustment_applied",
      "parent_columns": [
        "ledger_adjustment_applied_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (ledger_adjustment_applied_id) REFERENCES ledger_adjustment_applied (ledger_adjustment_applied_id)"
    },
    {
      "table": "ledger_adjustment_adjustment_detail_applied",
      "columns": [
        "ledger_adjustment_detail_applied_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "ledger_adjustment_detail_applied",
      "parent_columns": [
        "ledger_adjustment_detail_applied_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (ledger_adjustment_detail_applied_id) REFERENCES ledger_adjustment_detail_applied (ledger_adjustment_detail_applied_id)"
    },
    {
      "table": "ledger_adjustment_applied",
      "columns": [
        "abacus_event_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "abacus_event",
      "parent_columns": [
        "abacus_event_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)"
    },
    {
      "table": "ledger_adjustment_applied",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "ledger_adjustment_applied",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "ledger_adjustment_applied",
      "columns": [
        "ledger_adjustment_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "ledger_adjustment",
      "parent_columns": [
        "ledger_adjustment_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (ledger_adjustment_id) REFERENCES ledger_adjustment (ledger_adjustment_id)"
    },
    {
      "table": "ledger_adjustment_applied",
      "columns": [
        "statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "ledger_adjustment_applied",
      "columns": [
        "worksheet_adjustment_id"
      ],
      "cardinality": "zero_or_one",
      "parent_table": "worksheet_adjustment",
      "parent_columns": [
        "worksheet_adjustment_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (worksheet_adjustment_id) REFERENCES worksheet_adjustment (worksheet_adjustment_id)"
    },
    {
      "table": "ledger_adjustment_detail",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "ledger_adjustment_detail",
      "columns": [
        "activity_statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (activity_statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "ledger_adjustment_detail",
      "columns": [
        "apply_to_statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (apply_to_statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "ledger_adjustment_detail",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "ledger_adjustment_detail",
      "columns": [
        "reference_adjustment_type_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_adjustment_type",
      "parent_columns": [
        "reference_adjustment_type_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (reference_adjustment_type_id) REFERENCES reference_adjustment_type (reference_adjustment_type_id)"
    },
    {
      "table": "ledger_adjustment_detail_applied",
      "columns": [
        "worksheet_adjustment_detail_id"
      ],
      "cardinality": "zero_or_one",
      "parent_table": "worksheet_adjustment_detail",
      "parent_columns": [
        "worksheet_adjustment_detail_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (worksheet_adjustment_detail_id) REFERENCES worksheet_adjustment_detail (worksheet_adjustment_detail_id)"
    },
    {
      "table": "ledger_adjustment_detail_applied",
      "columns": [
        "ledger_adjustment_detail_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "ledger_adjustment_detail",
      "parent_columns": [
        "ledger_adjustment_detail_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (ledger_adjustment_detail_id) REFERENCES ledger_adjustment_detail (ledger_adjustment_detail_id)"
    },
    {
      "table": "ledger_adjustment_detail_applied",
      "columns": [
        "worksheet_adjustment_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "worksheet_adjustment",
      "parent_columns": [
        "worksheet_adjustment_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (worksheet_adjustment_id) REFERENCES worksheet_adjustment (worksheet_adjustment_id)"
    },
    {
      "table": "ledger_contract_advance_applied",
      "columns": [
        "abacus_event_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "abacus_event",
      "parent_columns": [
        "abacus_event_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)"
    },
    {
      "table": "ledger_contract_advance_applied",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "ledger_contract_advance_applied",
      "columns": [
        "contract_advance_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract_advance",
      "parent_columns": [
        "contract_advance_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_advance_id) REFERENCES contract_advance (contract_advance_id)"
    },
    {
      "table": "ledger_contract_advance_applied",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "ledger_contract_advance_applied",
      "columns": [
        "statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "ledger_correction",
      "columns": [
        "abacus_event_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "abacus_event",
      "parent_columns": [
        "abacus_event_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)"
    },
    {
      "table": "ledger_correction",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "ledger_correction",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "ledger_correction",
      "columns": [
        "correction_statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (correction_statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "ledger_correction",
      "columns": [
        "statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "ledger_correction",
      "columns": [
        "worksheet_correction_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "worksheet_correction",
      "parent_columns": [
        "worksheet_correction_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (worksheet_correction_id) REFERENCES worksheet_correction (worksheet_correction_id)"
    },
    {
      "table": "ledger_deposit",
      "columns": [
        "abacus_event_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "abacus_event",
      "parent_columns": [
        "abacus_event_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)"
    },
    {
      "table": "ledger_deposit",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "ledger_deposit",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "ledger_reserve_release",
      "columns": [
        "abacus_event_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "abacus_event",
      "parent_columns": [
        "abacus_event_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)"
    },
    {
      "table": "ledger_reserve_release",
      "columns": [
        "ledger_reserve_release_schedule_id"
      ],
      "cardinality": "zero_or_one",
      "parent_table": "ledger_reserve_release_schedule",
      "parent_columns": [
        "ledger_reserve_release_schedule_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (ledger_reserve_release_schedule_id) REFERENCES ledger_reserve_release_schedule (ledger_reserve_release_schedule_id)"
    },
    {
      "table": "ledger_reserve_release",
      "columns": [
        "statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "ledger_reserve_release_schedule",
      "columns": [
        "abacus_event_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "abacus_event",
      "parent_columns": [
        "abacus_event_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)"
    },
    {
      "table": "ledger_reserve_release_schedule",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "ledger_reserve_release_schedule",
      "columns": [
        "ledger_reserve_taken_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "ledger_reserve_taken",
      "parent_columns": [
        "ledger_reserve_taken_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (ledger_reserve_taken_id) REFERENCES ledger_reserve_taken (ledger_reserve_taken_id)"
    },
    {
      "table": "ledger_reserve_release_schedule",
      "columns": [
        "release_statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (release_statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "ledger_reserve_release_schedule",
      "columns": [
        "taken_statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (taken_statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "ledger_reserve_taken",
      "columns": [
        "abacus_event_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "abacus_event",
      "parent_columns": [
        "abacus_event_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)"
    },
    {
      "table": "ledger_reserve_taken",
      "columns": [
        "accounting_run_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "accounting_run",
      "parent_columns": [
        "accounting_run_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (accounting_run_id) REFERENCES accounting_run (accounting_run_id)"
    },
    {
      "table": "ledger_reserve_taken",
      "columns": [
        "contract_reserve_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract_reserve",
      "parent_columns": [
        "contract_reserve_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_reserve_id) REFERENCES contract_reserve (contract_reserve_id)"
    },
    {
      "table": "ledger_reserve_taken",
      "columns": [
        "statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "ledger_vat_summary",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "ledger_vat_summary",
      "columns": [
        "activity_statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (activity_statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "ledger_vat_summary",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "ledger_vat_summary",
      "columns": [
        "abacus_event_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "abacus_event",
      "parent_columns": [
        "abacus_event_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)"
    },
    {
      "table": "ledger_vat_summary",
      "columns": [
        "statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "legacy_contract",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "payee",
      "columns": [
        "payoneer_program_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_payoneer_program",
      "parent_columns": [
        "payoneer_program_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (payoneer_program_id) REFERENCES reference_payoneer_program (payoneer_program_id)"
    },
    {
      "table": "payee",
      "columns": [
        "reference_payment_type_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_payment_type",
      "parent_columns": [
        "reference_payment_type_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (reference_payment_type_id) REFERENCES reference_payment_type (reference_payment_type_id)"
    },
    {
      "table": "payee_collaborator",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "payee_collaborator",
      "columns": [
        "payee_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "payee",
      "parent_columns": [
        "payee_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (payee_id) REFERENCES payee (payee_id)"
    },
    {
      "table": "payee_kyc_notification",
      "columns": [
        "payee_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "payee",
      "parent_columns": [
        "payee_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (payee_id) REFERENCES payee (payee_id)"
    },
    {
      "table": "payment_entity_payoneer_program",
      "columns": [
        "agreement_type_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_agreement_type",
      "parent_columns": [
        "reference_agreement_type_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (agreement_type_id) REFERENCES reference_agreement_type (reference_agreement_type_id)"
    },
    {
      "table": "payment_entity_payoneer_program",
      "columns": [
        "payoneer_program_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_payoneer_program",
      "parent_columns": [
        "payoneer_program_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (payoneer_program_id) REFERENCES reference_payoneer_program (payoneer_program_id)"
    },
    {
      "table": "payment_entity_payoneer_program",
      "columns": [
        "reference_payment_entity_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_payment_entity",
      "parent_columns": [
        "reference_payment_entity_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (reference_payment_entity_id) REFERENCES reference_payment_entity (reference_payment_entity_id)"
    },
    {
      "table": "payment_group_payment",
      "columns": [
        "payment_group_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "payment_group",
      "parent_columns": [
        "payment_group_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (payment_group_id) REFERENCES payment_group (payment_group_id)"
    },
    {
      "table": "payment_group_payment",
      "columns": [
        "statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "payment_group_payment_account",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "payment_group_payment_account",
      "columns": [
        "payment_group_payment_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "payment_group_payment",
      "parent_columns": [
        "payment_group_payment_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (payment_group_payment_id) REFERENCES payment_group_payment (payment_group_payment_id)"
    },
    {
      "table": "payment_group_payment_account",
      "columns": [
        "current_statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (current_statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "payment_group_payment_account",
      "columns": [
        "last_statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (last_statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "payment_group_payment_account",
      "columns": [
        "payoneer_program_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_payoneer_program",
      "parent_columns": [
        "payoneer_program_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (payoneer_program_id) REFERENCES reference_payoneer_program (payoneer_program_id)"
    },
    {
      "table": "payment_group_payment_account_detail",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "payment_group_payment_account_detail",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "payment_group_payment_account_detail",
      "columns": [
        "payment_group_payment_account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "payment_group_payment_account",
      "parent_columns": [
        "payment_group_payment_account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (payment_group_payment_account_id) REFERENCES payment_group_payment_account (payment_group_payment_account_id)"
    },
    {
      "table": "payment_group_payment_account_detail",
      "columns": [
        "worksheet_account_contract_payable_after_tax_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "worksheet_account_contract_payable_after_tax",
      "parent_columns": [
        "worksheet_account_contract_payable_after_tax_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (worksheet_account_contract_payable_after_tax_id) REFERENCES worksheet_account_contract_payable_after_tax (worksheet_account_contract_payable_after_tax_id)"
    },
    {
      "table": "payment_group_payment_batch",
      "columns": [
        "payment_group_payment_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "payment_group_payment",
      "parent_columns": [
        "payment_group_payment_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (payment_group_payment_id) REFERENCES payment_group_payment (payment_group_payment_id)"
    },
    {
      "table": "payment_group_payment_batch",
      "columns": [
        "payoneer_program_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_payoneer_program",
      "parent_columns": [
        "payoneer_program_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (payoneer_program_id) REFERENCES reference_payoneer_program (payoneer_program_id)"
    },
    {
      "table": "payment_group_payment_batch_account",
      "columns": [
        "payment_group_payment_batch_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "payment_group_payment_batch",
      "parent_columns": [
        "payment_group_payment_batch_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (payment_group_payment_batch_id) REFERENCES payment_group_payment_batch (payment_group_payment_batch_id)"
    },
    {
      "table": "payment_group_payment_batch_account",
      "columns": [
        "payment_group_payment_account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "payment_group_payment_account",
      "parent_columns": [
        "payment_group_payment_account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (payment_group_payment_account_id) REFERENCES payment_group_payment_account (payment_group_payment_account_id)"
    },
    {
      "table": "payment_hold",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_one",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "payment_hold_history",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "payment_hold_history",
      "columns": [
        "payment_hold_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "payment_hold",
      "parent_columns": [
        "payment_hold_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (payment_hold_id) REFERENCES payment_hold (payment_hold_id)"
    },
    {
      "table": "reference_payoneer_program",
      "columns": [
        "reference_payment_type_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_payment_type",
      "parent_columns": [
        "reference_payment_type_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (reference_payment_type_id) REFERENCES reference_payment_type (reference_payment_type_id)"
    },
    {
      "table": "reference_signing_entity",
      "columns": [
        "reference_sap_profit_center_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_sap_profit_center",
      "parent_columns": [
        "reference_sap_profit_center_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (reference_sap_profit_center_id) REFERENCES reference_sap_profit_center (reference_sap_profit_center_id)"
    },
    {
      "table": "reference_signing_entity",
      "columns": [
        "reference_payment_entity_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_payment_entity",
      "parent_columns": [
        "reference_payment_entity_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (reference_payment_entity_id) REFERENCES reference_payment_entity (reference_payment_entity_id)"
    },
    {
      "table": "reference_transaction_type_group_transaction_type",
      "columns": [
        "reference_transaction_type_group_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_transaction_type_group",
      "parent_columns": [
        "reference_transaction_type_group_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (reference_transaction_type_group_id) REFERENCES reference_transaction_type_group (reference_transaction_type_group_id)"
    },
    {
      "table": "reference_transaction_type_group_transaction_type",
      "columns": [
        "reference_transaction_type_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_transaction_type",
      "parent_columns": [
        "reference_transaction_type_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (reference_transaction_type_id) REFERENCES reference_transaction_type (reference_transaction_type_id)"
    },
    {
      "table": "report_custom",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "report_payment_group_payment",
      "columns": [
        "payment_group_payment_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "payment_group_payment",
      "parent_columns": [
        "payment_group_payment_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (payment_group_payment_id) REFERENCES payment_group_payment (payment_group_payment_id)"
    },
    {
      "table": "run_controller_contract",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_one",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "run_controller_contract",
      "columns": [
        "run_controller_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "run_controller",
      "parent_columns": [
        "run_controller_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (run_controller_id) REFERENCES run_controller (run_controller_id)"
    },
    {
      "table": "sales_file",
      "columns": [
        "accounting_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "accounting_period",
      "parent_columns": [
        "accounting_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (accounting_period_id) REFERENCES accounting_period (accounting_period_id)"
    },
    {
      "table": "schedule_attachment",
      "columns": [
        "schedule_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "schedule",
      "parent_columns": [
        "schedule_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (schedule_id) REFERENCES schedule (schedule_id)"
    },
    {
      "table": "schedule_history",
      "columns": [
        "schedule_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "schedule",
      "parent_columns": [
        "schedule_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (schedule_id) REFERENCES schedule (schedule_id)"
    },
    {
      "table": "statement_attachment",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "statement_attachment",
      "columns": [
        "statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "statement_period_adjustment_file",
      "columns": [
        "statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "statement_period_payment_entity",
      "columns": [
        "statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "statement_period_payment_entity",
      "columns": [
        "reference_payment_entity_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_payment_entity",
      "parent_columns": [
        "reference_payment_entity_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (reference_payment_entity_id) REFERENCES reference_payment_entity (reference_payment_entity_id)"
    },
    {
      "table": "tax_withholding_override",
      "columns": [
        "account_payee_id"
      ],
      "cardinality": "zero_or_one",
      "parent_table": "account_payee",
      "parent_columns": [
        "account_payee_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_payee_id) REFERENCES account_payee (account_payee_id)"
    },
    {
      "table": "vat_summary_file",
      "columns": [
        "statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "worksheet_account_contract_closing_balance",
      "columns": [
        "abacus_event_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "abacus_event",
      "parent_columns": [
        "abacus_event_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)"
    },
    {
      "table": "worksheet_account_contract_closing_balance",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "worksheet_account_contract_closing_balance",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "worksheet_account_contract_closing_balance",
      "columns": [
        "ledger_account_contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "ledger_account_contract",
      "parent_columns": [
        "ledger_account_contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (ledger_account_contract_id) REFERENCES ledger_account_contract (ledger_account_contract_id)"
    },
    {
      "table": "worksheet_account_contract_closing_balance",
      "columns": [
        "reference_payment_entity_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_payment_entity",
      "parent_columns": [
        "reference_payment_entity_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (reference_payment_entity_id) REFERENCES reference_payment_entity (reference_payment_entity_id)"
    },
    {
      "table": "worksheet_account_contract_closing_balance",
      "columns": [
        "statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "worksheet_account_contract_payable_after_tax",
      "columns": [
        "abacus_event_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "abacus_event",
      "parent_columns": [
        "abacus_event_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)"
    },
    {
      "table": "worksheet_account_contract_payable_after_tax",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "worksheet_account_contract_payable_after_tax",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "worksheet_account_contract_payable_after_tax",
      "columns": [
        "statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "worksheet_account_contract_payable_after_tax",
      "columns": [
        "worksheet_account_contract_closing_balance_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "worksheet_account_contract_closing_balance",
      "parent_columns": [
        "worksheet_account_contract_closing_balance_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (worksheet_account_contract_closing_balance_id) REFERENCES worksheet_account_contract_closing_balance (worksheet_account_contract_closing_balance_id)"
    },
    {
      "table": "worksheet_account_contract_payable_details",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "worksheet_account_contract_payable_details",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "worksheet_account_contract_payable_details",
      "columns": [
        "payable_detail_type_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_payable_detail_type",
      "parent_columns": [
        "reference_payable_detail_type_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (payable_detail_type_id) REFERENCES reference_payable_detail_type (reference_payable_detail_type_id)"
    },
    {
      "table": "worksheet_account_contract_payable_details",
      "columns": [
        "statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "worksheet_account_contract_payable_details",
      "columns": [
        "worksheet_account_contract_payable_after_tax_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "worksheet_account_contract_payable_after_tax",
      "parent_columns": [
        "worksheet_account_contract_payable_after_tax_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (worksheet_account_contract_payable_after_tax_id) REFERENCES worksheet_account_contract_payable_after_tax (worksheet_account_contract_payable_after_tax_id)"
    },
    {
      "table": "worksheet_account_contract_taxable_revenue",
      "columns": [
        "abacus_event_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "abacus_event",
      "parent_columns": [
        "abacus_event_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)"
    },
    {
      "table": "worksheet_account_contract_taxable_revenue",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "worksheet_account_contract_taxable_revenue",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "worksheet_account_contract_taxable_revenue",
      "columns": [
        "reference_payment_entity_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_payment_entity",
      "parent_columns": [
        "reference_payment_entity_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (reference_payment_entity_id) REFERENCES reference_payment_entity (reference_payment_entity_id)"
    },
    {
      "table": "worksheet_account_contract_taxable_revenue",
      "columns": [
        "statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "worksheet_account_contract_taxable_revenue",
      "columns": [
        "worksheet_account_contract_closing_balance_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "worksheet_account_contract_closing_balance",
      "parent_columns": [
        "worksheet_account_contract_closing_balance_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (worksheet_account_contract_closing_balance_id) REFERENCES worksheet_account_contract_closing_balance (worksheet_account_contract_closing_balance_id)"
    },
    {
      "table": "worksheet_adjustment",
      "columns": [
        "abacus_event_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "abacus_event",
      "parent_columns": [
        "abacus_event_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)"
    },
    {
      "table": "worksheet_adjustment",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "worksheet_adjustment",
      "columns": [
        "activity_statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (activity_statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "worksheet_adjustment",
      "columns": [
        "apply_to_statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (apply_to_statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "worksheet_adjustment",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "worksheet_adjustment",
      "columns": [
        "reference_adjustment_type_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_adjustment_type",
      "parent_columns": [
        "reference_adjustment_type_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (reference_adjustment_type_id) REFERENCES reference_adjustment_type (reference_adjustment_type_id)"
    },
    {
      "table": "worksheet_adjustment",
      "columns": [
        "statement_period_adjustment_file_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period_adjustment_file",
      "parent_columns": [
        "statement_period_adjustment_file_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (statement_period_adjustment_file_id) REFERENCES statement_period_adjustment_file (statement_period_adjustment_file_id)"
    },
    {
      "table": "worksheet_adjustment_detail",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "worksheet_adjustment_detail",
      "columns": [
        "activity_statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (activity_statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "worksheet_adjustment_detail",
      "columns": [
        "apply_to_statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (apply_to_statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "worksheet_adjustment_detail",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "worksheet_adjustment_detail",
      "columns": [
        "reference_adjustment_type_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_adjustment_type",
      "parent_columns": [
        "reference_adjustment_type_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (reference_adjustment_type_id) REFERENCES reference_adjustment_type (reference_adjustment_type_id)"
    },
    {
      "table": "worksheet_adjustment_detail",
      "columns": [
        "statement_period_adjustment_file_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period_adjustment_file",
      "parent_columns": [
        "statement_period_adjustment_file_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (statement_period_adjustment_file_id) REFERENCES statement_period_adjustment_file (statement_period_adjustment_file_id)"
    },
    {
      "table": "worksheet_adjustment_detail",
      "columns": [
        "worksheet_adjustment_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "worksheet_adjustment",
      "parent_columns": [
        "worksheet_adjustment_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (worksheet_adjustment_id) REFERENCES worksheet_adjustment (worksheet_adjustment_id)"
    },
    {
      "table": "worksheet_correction",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "worksheet_correction",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "worksheet_correction",
      "columns": [
        "correction_statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (correction_statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "worksheet_correction",
      "columns": [
        "statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "worksheet_flowthrough",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "worksheet_flowthrough",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "worksheet_flowthrough",
      "columns": [
        "activity_statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (activity_statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "worksheet_flowthrough",
      "columns": [
        "worksheet_flowthrough_batch_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "worksheet_flowthrough_batch",
      "parent_columns": [
        "worksheet_flowthrough_batch_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (worksheet_flowthrough_batch_id) REFERENCES worksheet_flowthrough_batch (worksheet_flowthrough_batch_id)"
    },
    {
      "table": "worksheet_flowthrough_batch",
      "columns": [
        "source_file_upload_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "file_upload",
      "parent_columns": [
        "file_upload_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (source_file_upload_id) REFERENCES file_upload (file_upload_id)"
    },
    {
      "table": "worksheet_flowthrough_batch",
      "columns": [
        "statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "worksheet_flowthrough_file",
      "columns": [
        "worksheet_flowthrough_batch_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "worksheet_flowthrough_batch",
      "parent_columns": [
        "worksheet_flowthrough_batch_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (worksheet_flowthrough_batch_id) REFERENCES worksheet_flowthrough_batch (worksheet_flowthrough_batch_id)"
    },
    {
      "table": "worksheet_payment_contract_advance",
      "columns": [
        "contract_advance_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract_advance",
      "parent_columns": [
        "contract_advance_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_advance_id) REFERENCES contract_advance (contract_advance_id)"
    },
    {
      "table": "worksheet_payment_contract_advance",
      "columns": [
        "exchange_rate_statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (exchange_rate_statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "worksheet_payment_contract_advance",
      "columns": [
        "statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "worksheet_payment_custom",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "worksheet_payment_custom",
      "columns": [
        "activity_statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (activity_statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "worksheet_payment_custom",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "worksheet_payment_custom",
      "columns": [
        "statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "worksheet_tax_correction",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "worksheet_tax_correction",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "worksheet_tax_correction",
      "columns": [
        "payable_detail_type_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_payable_detail_type",
      "parent_columns": [
        "reference_payable_detail_type_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (payable_detail_type_id) REFERENCES reference_payable_detail_type (reference_payable_detail_type_id)"
    },
    {
      "table": "worksheet_tax_correction",
      "columns": [
        "correction_statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (correction_statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "worksheet_tax_correction_vat",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (account_id) REFERENCES account (account_id)"
    },
    {
      "table": "worksheet_tax_correction_vat",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (contract_id) REFERENCES contract (contract_id)"
    },
    {
      "table": "worksheet_tax_correction_vat",
      "columns": [
        "payable_detail_type_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_payable_detail_type",
      "parent_columns": [
        "reference_payable_detail_type_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (payable_detail_type_id) REFERENCES reference_payable_detail_type (reference_payable_detail_type_id)"
    },
    {
      "table": "worksheet_tax_correction_vat",
      "columns": [
        "correction_statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (correction_statement_period_id) REFERENCES statement_period (statement_period_id)"
    },
    {
      "table": "ACC_8715_CONTRACT_OWNER_MAP_SNOWFLAKE",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_one",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "ACC_8738_CONTRACT_OWNER_MAP_SNOWFLAKE",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_one",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "account_payee_history",
      "columns": [
        "reference_payment_type_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_payment_type",
      "parent_columns": [
        "reference_payment_type_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "account_payee_kyc_notification_history",
      "columns": [
        "account_payee_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account_payee",
      "parent_columns": [
        "account_payee_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "account_payee_kyc_notification_history",
      "columns": [
        "account_payee_kyc_notification_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account_payee_kyc_notification",
      "parent_columns": [
        "account_payee_kyc_notification_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "account_payee_tax_form_info_history",
      "columns": [
        "account_payee_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account_payee",
      "parent_columns": [
        "account_payee_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "account_payee_tax_form_info_history",
      "columns": [
        "account_payee_tax_form_info_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account_payee_tax_form_info",
      "parent_columns": [
        "account_payee_tax_form_info_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "contract_flowthrough_history",
      "columns": [
        "contract_flowthrough_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract_flowthrough",
      "parent_columns": [
        "contract_flowthrough_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "contract_flowthrough_history",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "contract_flowthrough_history",
      "columns": [
        "reference_flowthrough_calculation_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_flowthrough_calculation",
      "parent_columns": [
        "reference_flowthrough_calculation_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "contract_history",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "contract_lifecycle_bkup_20251015",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "contract_lifecycle_bkup_20251015",
      "columns": [
        "contract_lifecycle_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract_lifecycle",
      "parent_columns": [
        "contract_lifecycle_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "contract_lifecycle_bkup_20251015",
      "columns": [
        "contract_lifecycle_schedule_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract_lifecycle_schedule",
      "parent_columns": [
        "contract_lifecycle_schedule_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "contract_lifecycle_history",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "contract_lifecycle_history",
      "columns": [
        "contract_lifecycle_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract_lifecycle",
      "parent_columns": [
        "contract_lifecycle_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "contract_lifecycle_history",
      "columns": [
        "contract_lifecycle_schedule_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract_lifecycle_schedule",
      "parent_columns": [
        "contract_lifecycle_schedule_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "contract_mechanical_deduction_history",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "contract_mechanical_deduction_history",
      "columns": [
        "contract_mechanical_deduction_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract_mechanical_deduction",
      "parent_columns": [
        "contract_mechanical_deduction_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "contract_term_condition_history",
      "columns": [
        "contract_term_condition_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract_term_condition",
      "parent_columns": [
        "contract_term_condition_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "contract_term_condition_history",
      "columns": [
        "contract_term_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract_term",
      "parent_columns": [
        "contract_term_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "contract_term_history",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "contract_term_history",
      "columns": [
        "contract_term_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract_term",
      "parent_columns": [
        "contract_term_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "deleted_contract",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "historical_contract_advance",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "json_contract_file_import_status",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "json_contract_file_import_status",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "ledger_contract_advance_applied",
      "columns": [
        "worksheet_payment_contract_advance_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "worksheet_payment_contract_advance",
      "parent_columns": [
        "worksheet_payment_contract_advance_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "payee_history",
      "columns": [
        "payee_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "payee",
      "parent_columns": [
        "payee_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "payee_history",
      "columns": [
        "reference_payment_type_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "reference_payment_type",
      "parent_columns": [
        "reference_payment_type_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "payee_kyc_notification_history",
      "columns": [
        "payee_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "payee",
      "parent_columns": [
        "payee_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "payee_kyc_notification_history",
      "columns": [
        "payee_kyc_notification_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "payee_kyc_notification",
      "parent_columns": [
        "payee_kyc_notification_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "report_custom",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "run_controller_contract_history",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "run_controller_contract_history",
      "columns": [
        "run_controller_contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "run_controller_contract",
      "parent_columns": [
        "run_controller_contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "run_controller_contract_history",
      "columns": [
        "run_controller_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "run_controller",
      "parent_columns": [
        "run_controller_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "schedule_attachment_history",
      "columns": [
        "schedule_attachment_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "schedule_attachment",
      "parent_columns": [
        "schedule_attachment_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "schedule_attachment_history",
      "columns": [
        "schedule_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "schedule",
      "parent_columns": [
        "schedule_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "statement_attachment",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "statement_attachment_archive_WAR-1131",
      "columns": [
        "account_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account",
      "parent_columns": [
        "account_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "statement_attachment_archive_WAR-1131",
      "columns": [
        "contract_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "contract",
      "parent_columns": [
        "contract_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "statement_attachment_archive_WAR-1131",
      "columns": [
        "statement_attachment_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_attachment",
      "parent_columns": [
        "statement_attachment_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "statement_attachment_archive_WAR-1131",
      "columns": [
        "statement_period_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "statement_period",
      "parent_columns": [
        "statement_period_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "tax_withholding_override_history",
      "columns": [
        "account_payee_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "account_payee",
      "parent_columns": [
        "account_payee_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    },
    {
      "table": "tax_withholding_override_history",
      "columns": [
        "tax_withholding_override_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "tax_withholding_override",
      "parent_columns": [
        "tax_withholding_override_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "Detected Relation",
      "virtual": true
    }
  ],
  "driver": {
    "name": "mysql",
    "database_version": "8.0.39",
    "meta": {
      "dict": {
        "Functions": "Stored procedures and functions"
      }
    }
  },
  "viewpoints": [
    {
      "name": "Flowthrough",
      "desc": "Tables relevant to processing flowthrough.",
      "tables": [
        "contract",
        "contract_flowthrough",
        "ledger_account_contract",
        "ledger_adjustment_applied",
        "ledger_adjustment_detail_applied",
        "reference_adjustment_type",
        "reference_flowthrough_calculation",
        "statement_period",
        "statement_period_adjustment_file",
        "worksheet_adjustment",
        "worksheet_adjustment_detail"
      ],
      "groups": [
        {
          "name": "Adjustment",
          "desc": "Adjustment tables",
          "tables": [
            "statement_period_adjustment_file"
          ]
        },
        {
          "name": "contract",
          "desc": "Contract tables",
          "tables": [
            "contract",
            "contract_flowthrough"
          ]
        },
        {
          "name": "Ledger",
          "desc": "Ledger tables",
          "tables": [
            "ledger_account_contract",
            "ledger_adjustment_applied",
            "ledger_adjustment_detail_applied"
          ]
        },
        {
          "name": "Reference",
          "desc": "Reference tables",
          "tables": [
            "reference_adjustment_type",
            "reference_flowthrough_calculation",
            "statement_period"
          ]
        },
        {
          "name": "Worksheet",
          "desc": "Worksheet tables",
          "tables": [
            "worksheet_adjustment",
            "worksheet_adjustment_detail"
          ]
        }
      ]
    }
  ]
}
