feat: Gnuboard5 Cloudflare R2 Storage Module
- R2StorageAdapter: S3 호환 클라이언트 래퍼
- R2FileHandler: 그누보드 통합 핸들러
- Presigned URL 지원
- 유저별 경로 분리 (users/{member_id}/...)
- 대용량 파일 멀티파트 업로드 지원
- 로컬 스토리지 폴백
- DB 마이그레이션 스크립트 포함
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
38
extend/r2-storage/migrations/001_add_r2_columns.sql
Normal file
38
extend/r2-storage/migrations/001_add_r2_columns.sql
Normal file
@@ -0,0 +1,38 @@
|
||||
-- ============================================
|
||||
-- Gnuboard5 R2 Storage Migration
|
||||
-- Version: 1.0.0
|
||||
-- ============================================
|
||||
|
||||
-- 게시판 첨부파일 테이블에 R2 관련 컬럼 추가
|
||||
ALTER TABLE `g5_board_file`
|
||||
ADD COLUMN `bf_r2_key` VARCHAR(500) DEFAULT NULL COMMENT 'R2 object key (storage path)' AFTER `bf_type`,
|
||||
ADD COLUMN `bf_storage_type` ENUM('local', 'r2') DEFAULT 'local' COMMENT 'Storage type' AFTER `bf_r2_key`;
|
||||
|
||||
-- 인덱스 추가 (R2 키 조회 최적화)
|
||||
CREATE INDEX `idx_bf_r2_key` ON `g5_board_file` (`bf_r2_key`(255));
|
||||
CREATE INDEX `idx_bf_storage_type` ON `g5_board_file` (`bf_storage_type`);
|
||||
|
||||
-- 1:1 문의 첨부파일 테이블 (있는 경우)
|
||||
-- ALTER TABLE `g5_qa_content`
|
||||
-- ADD COLUMN `qa_r2_key1` VARCHAR(500) DEFAULT NULL COMMENT 'R2 object key for file 1',
|
||||
-- ADD COLUMN `qa_r2_key2` VARCHAR(500) DEFAULT NULL COMMENT 'R2 object key for file 2',
|
||||
-- ADD COLUMN `qa_storage_type` ENUM('local', 'r2') DEFAULT 'local';
|
||||
|
||||
-- 에디터 첨부파일 추적 테이블 (신규 생성 - 선택사항)
|
||||
CREATE TABLE IF NOT EXISTS `g5_editor_files` (
|
||||
`ef_no` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`mb_id` VARCHAR(20) NOT NULL DEFAULT '' COMMENT 'Member ID',
|
||||
`ef_file` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'File name',
|
||||
`ef_source` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'Original file name',
|
||||
`ef_filesize` INT(11) NOT NULL DEFAULT 0 COMMENT 'File size in bytes',
|
||||
`ef_width` INT(11) NOT NULL DEFAULT 0 COMMENT 'Image width',
|
||||
`ef_height` INT(11) NOT NULL DEFAULT 0 COMMENT 'Image height',
|
||||
`ef_type` TINYINT(4) NOT NULL DEFAULT 0 COMMENT 'File type (0=file, 1=image)',
|
||||
`ef_r2_key` VARCHAR(500) DEFAULT NULL COMMENT 'R2 object key',
|
||||
`ef_storage_type` ENUM('local', 'r2') DEFAULT 'local' COMMENT 'Storage type',
|
||||
`ef_datetime` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Upload datetime',
|
||||
PRIMARY KEY (`ef_no`),
|
||||
KEY `idx_mb_id` (`mb_id`),
|
||||
KEY `idx_ef_r2_key` (`ef_r2_key`(255)),
|
||||
KEY `idx_ef_storage_type` (`ef_storage_type`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Editor uploaded files tracking';
|
||||
17
extend/r2-storage/migrations/002_rollback.sql
Normal file
17
extend/r2-storage/migrations/002_rollback.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
-- ============================================
|
||||
-- Gnuboard5 R2 Storage Rollback
|
||||
-- WARNING: 이 스크립트는 R2 관련 컬럼을 삭제합니다.
|
||||
-- 실행 전 반드시 백업하세요!
|
||||
-- ============================================
|
||||
|
||||
-- 인덱스 삭제
|
||||
DROP INDEX `idx_bf_r2_key` ON `g5_board_file`;
|
||||
DROP INDEX `idx_bf_storage_type` ON `g5_board_file`;
|
||||
|
||||
-- 컬럼 삭제
|
||||
ALTER TABLE `g5_board_file`
|
||||
DROP COLUMN `bf_r2_key`,
|
||||
DROP COLUMN `bf_storage_type`;
|
||||
|
||||
-- 에디터 파일 테이블 삭제 (선택사항)
|
||||
-- DROP TABLE IF EXISTS `g5_editor_files`;
|
||||
Reference in New Issue
Block a user