# ledger_deposit

## Description

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

```sql
CREATE TABLE `ledger_deposit` (
  `ledger_deposit_id` mediumint unsigned NOT NULL AUTO_INCREMENT,
  `account_id` mediumint unsigned NOT NULL,
  `contract_id` mediumint unsigned DEFAULT NULL,
  `abacus_event_id` mediumint unsigned NOT NULL,
  `currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,
  `rounded_amount` decimal(20,2) NOT NULL,
  `remaining_amount` decimal(38,18) 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 (`ledger_deposit_id`),
  KEY `fk_contract_ledger_deposit` (`contract_id`),
  KEY `fk_abacus_event_ledger_deposit` (`abacus_event_id`),
  KEY `fk_ledger_deposit_account` (`account_id`),
  CONSTRAINT `fk_abacus_event_ledger_deposit` FOREIGN KEY (`abacus_event_id`) REFERENCES `abacus_event` (`abacus_event_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `fk_contract_ledger_deposit` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_ledger_deposit_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_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 |
| ----------------- | ------------------ | ------- | -------- | ---------------- | -------- | ------------------------------- | ------- |
| abacus_event_id   | mediumint unsigned |         | false    |                  |          | [abacus_event](abacus_event.md) |         |
| account_id        | mediumint unsigned |         | false    |                  |          | [account](account.md)           |         |
| contract_id       | mediumint unsigned |         | true     |                  |          | [contract](contract.md)         |         |
| created_at        | datetime           |         | false    |                  |          |                                 |         |
| created_by        | varchar(255)       |         | false    |                  |          |                                 |         |
| currency_code     | char(3)            |         | false    |                  |          |                                 |         |
| last_modified     | datetime           |         | false    |                  |          |                                 |         |
| last_modified_by  | varchar(255)       |         | false    |                  |          |                                 |         |
| ledger_deposit_id | mediumint unsigned |         | false    | auto_increment   |          |                                 |         |
| remaining_amount  | decimal(38,18)     |         | false    |                  |          |                                 |         |
| rounded_amount    | decimal(20,2)      |         | false    |                  |          |                                 |         |

## Constraints

| Name                           | Type        | Definition                                                              |
| ------------------------------ | ----------- | ----------------------------------------------------------------------- |
| PRIMARY                        | PRIMARY KEY | PRIMARY KEY (ledger_deposit_id)                                         |
| fk_abacus_event_ledger_deposit | FOREIGN KEY | FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id) |
| fk_contract_ledger_deposit     | FOREIGN KEY | FOREIGN KEY (contract_id) REFERENCES contract (contract_id)             |
| fk_ledger_deposit_account      | FOREIGN KEY | FOREIGN KEY (account_id) REFERENCES account (account_id)                |

## Indexes

| Name                           | Definition                                                       |
| ------------------------------ | ---------------------------------------------------------------- |
| PRIMARY                        | PRIMARY KEY (ledger_deposit_id) USING BTREE                      |
| fk_abacus_event_ledger_deposit | KEY fk_abacus_event_ledger_deposit (abacus_event_id) USING BTREE |
| fk_contract_ledger_deposit     | KEY fk_contract_ledger_deposit (contract_id) USING BTREE         |
| fk_ledger_deposit_account      | KEY fk_ledger_deposit_account (account_id) USING BTREE           |

## Relations

![er](ledger_deposit.svg)

---

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