Book additional files support (1/3) (#868)
* feat(api/model): add new entity BookAdditionalFileEntity * feat(api/db): add book additional file repository * feat(api/db): add migration * test(api/db): add book additional file repository test * test(api/db): add book additional file repository tests for hash uniqueness * feat(api/domain): add support to additional file model * feat(api): add additional files controller * refactor(api): move addAdditionalFile to FileUploadService as uploadAdditionalFile method * feat(service): search book by additional file * feat(services): process deleted additional files with ability to promote alternative formats to book instead of deleting them * refactor(util): use common code to resolve patter for entity and domain object * feat(service): move additional files * test(service): test move additional files along with book itself
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
CREATE TABLE IF NOT EXISTS book_additional_file
|
||||
(
|
||||
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||
book_id BIGINT NOT NULL,
|
||||
file_name VARCHAR(1000) NOT NULL,
|
||||
file_sub_path VARCHAR(512) NOT NULL,
|
||||
additional_file_type ENUM('ALTERNATIVE_FORMAT', 'SUPPLEMENTARY') NOT NULL,
|
||||
file_size_kb BIGINT,
|
||||
initial_hash VARCHAR(128),
|
||||
current_hash VARCHAR(128),
|
||||
description TEXT,
|
||||
added_on TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
-- Virtual column for alternative format files
|
||||
alt_format_current_hash VARCHAR(128) AS (CASE WHEN additional_file_type = 'ALTERNATIVE_FORMAT' THEN current_hash END) STORED,
|
||||
|
||||
CONSTRAINT fk_book_additional_file_book FOREIGN KEY (book_id) REFERENCES book (id) ON DELETE CASCADE,
|
||||
UNIQUE INDEX idx_book_additional_file_current_hash_alt_format (alt_format_current_hash)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_book_additional_file_book_id ON book_additional_file(book_id);
|
||||
Reference in New Issue
Block a user