# contract_history

## Description

<details>
<summary><strong>Table Definition</strong></summary>

```sql
CREATE TABLE `contract_history` (
  `contract_history_id` mediumint unsigned NOT NULL AUTO_INCREMENT,
  `contract_id` mediumint unsigned NOT NULL,
  `reference_signing_entity_id` mediumint unsigned NOT NULL,
  `contract_name` varchar(180) NOT NULL,
  `contract_type` enum('distribution','legacy_distribution','neighbouring_rights') NOT NULL DEFAULT 'distribution',
  `sap_created_at` datetime DEFAULT NULL,
  `initial_start_date` date DEFAULT NULL,
  `execution_date` date DEFAULT NULL,
  `is_excluded_from_accounting_run` tinyint(1) DEFAULT '0',
  `summary_note` mediumtext,
  `general_note` mediumtext,
  `term_start` date DEFAULT NULL,
  `term_end` date DEFAULT NULL,
  `created_by` varchar(255) NOT NULL,
  `created_at` datetime NOT NULL,
  `last_modified_by` varchar(255) NOT NULL,
  `last_modified` datetime NOT NULL,
  PRIMARY KEY (`contract_history_id`),
  KEY `FK_contract_history_contract` (`contract_id`),
  KEY `fk_contract_history_reference_signing_entity` (`reference_signing_entity_id`),
  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
) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3
```

</details>

## Columns

| Name                            | Type                                                             | Default      | Nullable | Extra Definition | Children | Parents                                                 | Comment |
| ------------------------------- | ---------------------------------------------------------------- | ------------ | -------- | ---------------- | -------- | ------------------------------------------------------- | ------- |
| contract_history_id             | mediumint unsigned                                               |              | false    | auto_increment   |          |                                                         |         |
| contract_id                     | mediumint unsigned                                               |              | false    |                  |          | [contract](contract.md)                                 |         |
| contract_name                   | varchar(180)                                                     |              | false    |                  |          |                                                         |         |
| contract_type                   | enum('distribution','legacy_distribution','neighbouring_rights') | distribution | false    |                  |          |                                                         |         |
| created_at                      | datetime                                                         |              | false    |                  |          |                                                         |         |
| created_by                      | varchar(255)                                                     |              | false    |                  |          |                                                         |         |
| execution_date                  | date                                                             |              | true     |                  |          |                                                         |         |
| general_note                    | mediumtext                                                       |              | true     |                  |          |                                                         |         |
| initial_start_date              | date                                                             |              | true     |                  |          |                                                         |         |
| is_excluded_from_accounting_run | tinyint(1)                                                       | 0            | true     |                  |          |                                                         |         |
| last_modified                   | datetime                                                         |              | false    |                  |          |                                                         |         |
| last_modified_by                | varchar(255)                                                     |              | false    |                  |          |                                                         |         |
| reference_signing_entity_id     | mediumint unsigned                                               |              | false    |                  |          | [reference_signing_entity](reference_signing_entity.md) |         |
| sap_created_at                  | datetime                                                         |              | true     |                  |          |                                                         |         |
| summary_note                    | mediumtext                                                       |              | true     |                  |          |                                                         |         |
| term_end                        | date                                                             |              | true     |                  |          |                                                         |         |
| term_start                      | date                                                             |              | true     |                  |          |                                                         |         |

## Constraints

| Name                                         | Type        | Definition                                                                                                  |
| -------------------------------------------- | ----------- | ----------------------------------------------------------------------------------------------------------- |
| PRIMARY                                      | PRIMARY KEY | PRIMARY KEY (contract_history_id)                                                                           |
| fk_contract_history_reference_signing_entity | FOREIGN KEY | FOREIGN KEY (reference_signing_entity_id) REFERENCES reference_signing_entity (reference_signing_entity_id) |

## Indexes

| Name                                         | Definition                                                                                 |
| -------------------------------------------- | ------------------------------------------------------------------------------------------ |
| FK_contract_history_contract                 | KEY FK_contract_history_contract (contract_id) USING BTREE                                 |
| PRIMARY                                      | PRIMARY KEY (contract_history_id) USING BTREE                                              |
| fk_contract_history_reference_signing_entity | KEY fk_contract_history_reference_signing_entity (reference_signing_entity_id) USING BTREE |

## Relations

![er](contract_history.svg)

---

> Generated by [tbls](https://github.com/k1LoW/tbls)
