# file_upload_config

## Description

Configurations for different file upload types and their routing rules

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

```sql
CREATE TABLE `file_upload_config` (
  `file_upload_config_id` mediumint unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key.',
  `upload_type` enum('adjustments','flowthrough') NOT NULL COMMENT 'Type identifier for the upload. Defines which upload configuration to use.',
  `s3_key_template` varchar(255) NOT NULL DEFAULT '{file_key}.{ext}' COMMENT 'S3 path/key template',
  `allowed_file_types` json DEFAULT NULL COMMENT 'Array of allowed file extensions, without leading dot and lowercase (e.g., ["csv", "pdf", "xlsx"]). NULL = allow all extensions.',
  `max_file_size_bytes` bigint unsigned NOT NULL DEFAULT '10485760' COMMENT 'Maximum file size in bytes. Defaults to 10MB, S3 maximum is 5TB.',
  `multipart_threshold_bytes` bigint unsigned DEFAULT '104857600' COMMENT 'File size threshold for multipart upload. Defaults to 100MB, S3 maximum is 5GB.',
  `min_multipart_chunk_size_bytes` bigint unsigned DEFAULT '10485760' COMMENT 'Minimum chunk size for multipart uploads. Defaults to 10MB, S3 range is [5MB, 5GB]. Calculated chunk size should be >= this value and stay within the S3 part limit (10,000).',
  `description` varchar(255) DEFAULT NULL COMMENT 'Description of what this upload config is for.',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `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 (`file_upload_config_id`),
  UNIQUE KEY `uidx_upload_type_active` (`upload_type`,((case when (`deleted_at` is null) then 0 end))) COMMENT 'Ensures only one active (non-deleted) record per upload_type. Allows multiple soft-deleted records.'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='Configurations for different file upload types and their routing rules'
```

</details>

## Columns

| Name                           | Type                              | Default           | Nullable | Extra Definition                              | Children                      | Parents | Comment                                                                                                                                                                        |
| ------------------------------ | --------------------------------- | ----------------- | -------- | --------------------------------------------- | ----------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| allowed_file_types             | json                              |                   | true     |                                               |                               |         | Array of allowed file extensions, without leading dot and lowercase (e.g., ["csv", "pdf", "xlsx"]). NULL = allow all extensions.                                               |
| created_at                     | datetime                          | CURRENT_TIMESTAMP | false    | DEFAULT_GENERATED                             |                               |         |                                                                                                                                                                                |
| created_by                     | varchar(180)                      |                   | false    |                                               |                               |         |                                                                                                                                                                                |
| deleted_at                     | datetime                          |                   | true     |                                               |                               |         |                                                                                                                                                                                |
| deleted_by                     | varchar(180)                      |                   | true     |                                               |                               |         |                                                                                                                                                                                |
| description                    | varchar(255)                      |                   | true     |                                               |                               |         | Description of what this upload config is for.                                                                                                                                 |
| file_upload_config_id          | mediumint unsigned                |                   | false    | auto_increment                                | [file_upload](file_upload.md) |         | Primary key.                                                                                                                                                                   |
| last_modified                  | datetime                          | CURRENT_TIMESTAMP | false    | DEFAULT_GENERATED on update CURRENT_TIMESTAMP |                               |         |                                                                                                                                                                                |
| last_modified_by               | varchar(180)                      |                   | false    |                                               |                               |         |                                                                                                                                                                                |
| max_file_size_bytes            | bigint unsigned                   | 10485760          | false    |                                               |                               |         | Maximum file size in bytes. Defaults to 10MB, S3 maximum is 5TB.                                                                                                               |
| min_multipart_chunk_size_bytes | bigint unsigned                   | 10485760          | true     |                                               |                               |         | Minimum chunk size for multipart uploads. Defaults to 10MB, S3 range is [5MB, 5GB]. Calculated chunk size should be \>= this value and stay within the S3 part limit (10,000). |
| multipart_threshold_bytes      | bigint unsigned                   | 104857600         | true     |                                               |                               |         | File size threshold for multipart upload. Defaults to 100MB, S3 maximum is 5GB.                                                                                                |
| s3_key_template                | varchar(255)                      | {file_key}.{ext}  | false    |                                               |                               |         | S3 path/key template                                                                                                                                                           |
| upload_type                    | enum('adjustments','flowthrough') |                   | false    |                                               |                               |         | Type identifier for the upload. Defines which upload configuration to use.                                                                                                     |

## Constraints

| Name                    | Type        | Definition                                       |
| ----------------------- | ----------- | ------------------------------------------------ |
| PRIMARY                 | PRIMARY KEY | PRIMARY KEY (file_upload_config_id)              |
| uidx_upload_type_active | UNIQUE      | UNIQUE KEY uidx_upload_type_active (upload_type) |

## Indexes

| Name                    | Definition                                                   |
| ----------------------- | ------------------------------------------------------------ |
| PRIMARY                 | PRIMARY KEY (file_upload_config_id) USING BTREE              |
| uidx_upload_type_active | UNIQUE KEY uidx_upload_type_active (upload_type) USING BTREE |

## Relations

![er](file_upload_config.svg)

---

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