# worksheet_flowthrough_file

## Description

Generated download files representing flowthrough batch data in various formats for user consumption.

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

```sql
CREATE TABLE `worksheet_flowthrough_file` (
  `worksheet_flowthrough_file_id` mediumint unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key.',
  `worksheet_flowthrough_batch_id` mediumint unsigned NOT NULL COMMENT 'The parent worksheet_flowthrough_batch.',
  `file_key` varchar(36) NOT NULL COMMENT 'Unique identifier for the file (UUID).',
  `file_name` varchar(255) NOT NULL COMMENT 'Generated filename.',
  `file_size_bytes` bigint unsigned NOT NULL COMMENT 'File size in bytes.',
  `file_type` varchar(10) DEFAULT NULL COMMENT 'File extension without leading dot and lowercase (e.g., csv, pdf, xlsx).',
  `s3_key` varchar(1024) NOT NULL COMMENT 'S3 file location.',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'When the file was generated.',
  `created_by` varchar(180) NOT NULL,
  `last_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `last_modified_by` varchar(180) NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `deleted_by` varchar(180) DEFAULT NULL,
  PRIMARY KEY (`worksheet_flowthrough_file_id`),
  UNIQUE KEY `uidx_file_key` (`file_key`) COMMENT 'Ensures file_key is unique across all files.',
  KEY `idx_batch_file_type` (`worksheet_flowthrough_batch_id`,`file_type`) COMMENT 'Find files by batch and type.',
  KEY `fk_worksheet_flowthrough_file_worksheet_flowthrough_batch` (`worksheet_flowthrough_batch_id`),
  CONSTRAINT `fk_worksheet_flowthrough_file_worksheet_flowthrough_batch` FOREIGN KEY (`worksheet_flowthrough_batch_id`) REFERENCES `worksheet_flowthrough_batch` (`worksheet_flowthrough_batch_id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='Generated download files representing flowthrough batch data in various formats for user consumption.'
```

</details>

## Columns

| Name                           | Type               | Default           | Nullable | Extra Definition                              | Children | Parents                                                       | Comment                                                                  |
| ------------------------------ | ------------------ | ----------------- | -------- | --------------------------------------------- | -------- | ------------------------------------------------------------- | ------------------------------------------------------------------------ |
| created_at                     | datetime           | CURRENT_TIMESTAMP | false    | DEFAULT_GENERATED                             |          |                                                               | When the file was generated.                                             |
| created_by                     | varchar(180)       |                   | false    |                                               |          |                                                               |                                                                          |
| deleted_at                     | datetime           |                   | true     |                                               |          |                                                               |                                                                          |
| deleted_by                     | varchar(180)       |                   | true     |                                               |          |                                                               |                                                                          |
| file_key                       | varchar(36)        |                   | false    |                                               |          |                                                               | Unique identifier for the file (UUID).                                   |
| file_name                      | varchar(255)       |                   | false    |                                               |          |                                                               | Generated filename.                                                      |
| file_size_bytes                | bigint unsigned    |                   | false    |                                               |          |                                                               | File size in bytes.                                                      |
| file_type                      | varchar(10)        |                   | true     |                                               |          |                                                               | File extension without leading dot and lowercase (e.g., csv, pdf, xlsx). |
| last_modified                  | datetime           | CURRENT_TIMESTAMP | false    | DEFAULT_GENERATED on update CURRENT_TIMESTAMP |          |                                                               |                                                                          |
| last_modified_by               | varchar(180)       |                   | false    |                                               |          |                                                               |                                                                          |
| s3_key                         | varchar(1024)      |                   | false    |                                               |          |                                                               | S3 file location.                                                        |
| worksheet_flowthrough_batch_id | mediumint unsigned |                   | false    |                                               |          | [worksheet_flowthrough_batch](worksheet_flowthrough_batch.md) | The parent worksheet_flowthrough_batch.                                  |
| worksheet_flowthrough_file_id  | mediumint unsigned |                   | false    | auto_increment                                |          |                                                               | Primary key.                                                             |

## Constraints

| Name                                                      | Type        | Definition                                                                                                           |
| --------------------------------------------------------- | ----------- | -------------------------------------------------------------------------------------------------------------------- |
| PRIMARY                                                   | PRIMARY KEY | PRIMARY KEY (worksheet_flowthrough_file_id)                                                                          |
| fk_worksheet_flowthrough_file_worksheet_flowthrough_batch | FOREIGN KEY | FOREIGN KEY (worksheet_flowthrough_batch_id) REFERENCES worksheet_flowthrough_batch (worksheet_flowthrough_batch_id) |
| uidx_file_key                                             | UNIQUE      | UNIQUE KEY uidx_file_key (file_key)                                                                                  |

## Indexes

| Name                                                      | Definition                                                                                                 |
| --------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| PRIMARY                                                   | PRIMARY KEY (worksheet_flowthrough_file_id) USING BTREE                                                    |
| fk_worksheet_flowthrough_file_worksheet_flowthrough_batch | KEY fk_worksheet_flowthrough_file_worksheet_flowthrough_batch (worksheet_flowthrough_batch_id) USING BTREE |
| idx_batch_file_type                                       | KEY idx_batch_file_type (worksheet_flowthrough_batch_id, file_type) USING BTREE                            |
| uidx_file_key                                             | UNIQUE KEY uidx_file_key (file_key) USING BTREE                                                            |

## Relations

![er](worksheet_flowthrough_file.svg)

---

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