# payments

## 概要

<details>
<summary><strong>テーブル定義</strong></summary>

```sql
CREATE TABLE `payments` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '入金ID',
  `invoice_id` bigint unsigned NOT NULL,
  `payment_date` date DEFAULT NULL COMMENT '入金日',
  `amount` decimal(12,2) NOT NULL COMMENT '入金額',
  `method` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '支払方法（例：振込）',
  `note` text COLLATE utf8mb4_unicode_ci COMMENT '備考',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `payments_invoice_id_foreign` (`invoice_id`),
  CONSTRAINT `payments_invoice_id_foreign` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
```

</details>

## カラム一覧

| 名前 | タイプ | デフォルト値 | NULL許可 | Extra Definition | 子テーブル | 親テーブル | コメント |
| ---- | ------ | ------------ | -------- | ---------------- | ---------- | ---------- | -------- |
| id | bigint unsigned |  | false | auto_increment |  |  | 入金ID |
| invoice_id | bigint unsigned |  | false |  |  | [invoices](invoices.md) |  |
| payment_date | date |  | true |  |  |  | 入金日 |
| amount | decimal(12,2) |  | false |  |  |  | 入金額 |
| method | varchar(255) |  | true |  |  |  | 支払方法（例：振込） |
| note | text |  | true |  |  |  | 備考 |
| created_at | timestamp |  | true |  |  |  |  |
| updated_at | timestamp |  | true |  |  |  |  |

## 制約一覧

| 名前 | タイプ | 定義 |
| ---- | ---- | ---------- |
| payments_invoice_id_foreign | FOREIGN KEY | FOREIGN KEY (invoice_id) REFERENCES invoices (id) |
| PRIMARY | PRIMARY KEY | PRIMARY KEY (id) |

## INDEX一覧

| 名前 | 定義 |
| ---- | ---------- |
| payments_invoice_id_foreign | KEY payments_invoice_id_foreign (invoice_id) USING BTREE |
| PRIMARY | PRIMARY KEY (id) USING BTREE |

## ER図

![er](payments.svg)

---

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