# contract_reserve

## Description

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

```sql
CREATE TABLE `contract_reserve` (
  `contract_reserve_id` mediumint unsigned NOT NULL AUTO_INCREMENT,
  `contract_id` mediumint unsigned NOT NULL,
  `reserve_rate` decimal(5,2) NOT NULL,
  `reserve_release_offset_in_months` tinyint NOT NULL,
  `installments_in_months` tinyint NOT NULL,
  `release_schedule` json NOT NULL,
  `conditions` json DEFAULT NULL,
  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,
  `created_at` datetime NOT NULL,
  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,
  `last_modified` datetime NOT NULL,
  `deleted_by` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `deleted_at` datetime DEFAULT NULL,
  PRIMARY KEY (`contract_reserve_id`),
  UNIQUE KEY `uidx_contract_reserve_deleted` (`contract_id`,`deleted_at`),
  CONSTRAINT `fk_contract_reserve_contract_id` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_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 |
| -------------------------------- | ------------------ | ------- | -------- | ---------------- | ----------------------------------------------- | ----------------------- | ------- |
| conditions                       | json               |         | true     |                  |                                                 |                         |         |
| contract_id                      | mediumint unsigned |         | false    |                  |                                                 | [contract](contract.md) |         |
| contract_reserve_id              | mediumint unsigned |         | false    | auto_increment   | [ledger_reserve_taken](ledger_reserve_taken.md) |                         |         |
| created_at                       | datetime           |         | false    |                  |                                                 |                         |         |
| created_by                       | varchar(180)       |         | false    |                  |                                                 |                         |         |
| deleted_at                       | datetime           |         | true     |                  |                                                 |                         |         |
| deleted_by                       | varchar(180)       |         | true     |                  |                                                 |                         |         |
| installments_in_months           | tinyint            |         | false    |                  |                                                 |                         |         |
| last_modified                    | datetime           |         | false    |                  |                                                 |                         |         |
| last_modified_by                 | varchar(180)       |         | false    |                  |                                                 |                         |         |
| release_schedule                 | json               |         | false    |                  |                                                 |                         |         |
| reserve_rate                     | decimal(5,2)       |         | false    |                  |                                                 |                         |         |
| reserve_release_offset_in_months | tinyint            |         | false    |                  |                                                 |                         |         |

## Constraints

| Name                            | Type        | Definition                                                         |
| ------------------------------- | ----------- | ------------------------------------------------------------------ |
| PRIMARY                         | PRIMARY KEY | PRIMARY KEY (contract_reserve_id)                                  |
| fk_contract_reserve_contract_id | FOREIGN KEY | FOREIGN KEY (contract_id) REFERENCES contract (contract_id)        |
| uidx_contract_reserve_deleted   | UNIQUE      | UNIQUE KEY uidx_contract_reserve_deleted (contract_id, deleted_at) |

## Indexes

| Name                          | Definition                                                                     |
| ----------------------------- | ------------------------------------------------------------------------------ |
| PRIMARY                       | PRIMARY KEY (contract_reserve_id) USING BTREE                                  |
| uidx_contract_reserve_deleted | UNIQUE KEY uidx_contract_reserve_deleted (contract_id, deleted_at) USING BTREE |

## Relations

![er](contract_reserve.svg)

---

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