cmvr-wms/sql/projectdev/20261020_resumable_upload.sql

27 lines
1.2 KiB
MySQL
Raw Normal View History

-- target-database: cmvr-project-dev
-- Upload transport metadata only. Never stores bytes in SQL or changes business records.
CREATE TABLE IF NOT EXISTS sys_file_upload (
id char(36) CHARACTER SET ascii COLLATE ascii_bin NOT NULL PRIMARY KEY,
owner_id bigint NOT NULL,
fingerprint char(64) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL,
target_json varchar(300) NOT NULL,
original_name varchar(180) NOT NULL,
byte_size int NOT NULL,
sha256 char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
status varchar(8) NOT NULL DEFAULT 'OPEN',
result_json longtext DEFAULT NULL,
create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
expires_at datetime NOT NULL,
UNIQUE KEY uk_file_upload_owner (owner_id,fingerprint),
KEY idx_file_upload_expiry (expires_at),
KEY idx_file_upload_quota (owner_id,status,expires_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS sys_file_upload_chunk (
upload_id char(36) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
chunk_index int NOT NULL,
byte_size int NOT NULL,
sha256 char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
PRIMARY KEY (upload_id,chunk_index),
CONSTRAINT fk_file_upload_chunk FOREIGN KEY (upload_id) REFERENCES sys_file_upload(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;