mdeslippe / easy-tracker

Easy Tracker is a web-based utility that enables users to easily monitor the current and historical status of their digital services.
1 stars 0 forks source link

Create a Table to Store Files in the Database #157

Closed mdeslippe closed 1 year ago

mdeslippe commented 1 year ago

Overview

File Information that Should be Stored in the Database

Information Type Field Data Type Max Size Primary Key Foreign Key Unique Nullable Default Value
id bigint N/A ✔️ ✔️ auto_increment
user_id bigint N/A ✔️ N/A
file_created_at timestamp N/A Current Date & Time (UTC)
mime_type varchar 1024 N/A
name varchar 1024 N/A
data longblob N/A N/A

SQL

CREATE TABLE `files` (
    `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
    `user_id` BIGINT(20) UNSIGNED NOT NULL,
    `file_created_at` TIMESTAMP NOT NULL DEFAULT current_timestamp(),
    `mime_type` VARCHAR(1024) NOT NULL COLLATE 'utf8mb4_unicode_ci',
    `name` VARCHAR(1024) NOT NULL COLLATE 'utf8mb4_unicode_ci',
    `data` LONGBLOB NOT NULL,
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `FK__users` (`user_id`) USING BTREE,
    CONSTRAINT `FK__users` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE
)
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
ROW_FORMAT=COMPRESSED
AUTO_INCREMENT=1;