# contract_template

## Description

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

```sql
CREATE TABLE `contract_template` (
  `contract_template_id` mediumint unsigned NOT NULL AUTO_INCREMENT,
  `template_name` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,
  `run_controller_id` mediumint unsigned DEFAULT NULL,
  `reference_signing_entity_id` mediumint unsigned NOT NULL,
  `term_duration_year` tinyint DEFAULT NULL,
  `contract_type` enum('distribution','legacy_distribution','neighbouring_rights') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'distribution',
  `contract_terms` json NOT NULL,
  `contract_exclusions` json NOT NULL,
  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `created_at` datetime NOT NULL,
  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `last_modified` datetime NOT NULL,
  PRIMARY KEY (`contract_template_id`),
  KEY `fk_contract_template_run_controller` (`run_controller_id`),
  KEY `fk_contract_template_reference_signing_entity` (`reference_signing_entity_id`),
  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,
  CONSTRAINT `fk_contract_template_run_controller` FOREIGN KEY (`run_controller_id`) REFERENCES `run_controller` (`run_controller_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
```

</details>

## Columns

| Name                        | Type                                                             | Default      | Nullable | Extra Definition | Children | Parents                                                 | Comment |
| --------------------------- | ---------------------------------------------------------------- | ------------ | -------- | ---------------- | -------- | ------------------------------------------------------- | ------- |
| contract_exclusions         | json                                                             |              | false    |                  |          |                                                         |         |
| contract_template_id        | mediumint unsigned                                               |              | false    | auto_increment   |          |                                                         |         |
| contract_terms              | json                                                             |              | false    |                  |          |                                                         |         |
| contract_type               | enum('distribution','legacy_distribution','neighbouring_rights') | distribution | false    |                  |          |                                                         |         |
| created_at                  | datetime                                                         |              | false    |                  |          |                                                         |         |
| created_by                  | varchar(255)                                                     |              | false    |                  |          |                                                         |         |
| last_modified               | datetime                                                         |              | false    |                  |          |                                                         |         |
| last_modified_by            | varchar(255)                                                     |              | false    |                  |          |                                                         |         |
| reference_signing_entity_id | mediumint unsigned                                               |              | false    |                  |          | [reference_signing_entity](reference_signing_entity.md) |         |
| run_controller_id           | mediumint unsigned                                               |              | true     |                  |          | [run_controller](run_controller.md)                     |         |
| template_name               | varchar(180)                                                     |              | false    |                  |          |                                                         |         |
| term_duration_year          | tinyint                                                          |              | true     |                  |          |                                                         |         |

## Constraints

| Name                                          | Type        | Definition                                                                                                  |
| --------------------------------------------- | ----------- | ----------------------------------------------------------------------------------------------------------- |
| PRIMARY                                       | PRIMARY KEY | PRIMARY KEY (contract_template_id)                                                                          |
| fk_contract_template_reference_signing_entity | FOREIGN KEY | FOREIGN KEY (reference_signing_entity_id) REFERENCES reference_signing_entity (reference_signing_entity_id) |
| fk_contract_template_run_controller           | FOREIGN KEY | FOREIGN KEY (run_controller_id) REFERENCES run_controller (run_controller_id)                               |

## Indexes

| Name                                          | Definition                                                                                  |
| --------------------------------------------- | ------------------------------------------------------------------------------------------- |
| PRIMARY                                       | PRIMARY KEY (contract_template_id) USING BTREE                                              |
| fk_contract_template_reference_signing_entity | KEY fk_contract_template_reference_signing_entity (reference_signing_entity_id) USING BTREE |
| fk_contract_template_run_controller           | KEY fk_contract_template_run_controller (run_controller_id) USING BTREE                     |

## Relations

![er](contract_template.svg)

---

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