Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions prisma/migrations/20260108154707_update_schema/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
Warnings:

- You are about to alter the column `created_at` on the `Comment` table. The data in that column could be lost. The data in that column will be cast from `DateTime(0)` to `DateTime`.
- You are about to alter the column `created_at` on the `Communication` table. The data in that column could be lost. The data in that column will be cast from `DateTime(0)` to `DateTime`.
- You are about to alter the column `updated_at` on the `Communication` table. The data in that column could be lost. The data in that column will be cast from `DateTime(0)` to `DateTime`.
- You are about to alter the column `created_at` on the `Folder` table. The data in that column could be lost. The data in that column will be cast from `DateTime(0)` to `DateTime`.
- You are about to alter the column `created_at` on the `Log` table. The data in that column could be lost. The data in that column will be cast from `DateTime(0)` to `DateTime`.
- You are about to alter the column `updated_at` on the `Log` table. The data in that column could be lost. The data in that column will be cast from `DateTime(0)` to `DateTime`.
- You are about to alter the column `created_at` on the `Member` table. The data in that column could be lost. The data in that column will be cast from `DateTime(0)` to `DateTime`.
- You are about to alter the column `created_at` on the `Reference` table. The data in that column could be lost. The data in that column will be cast from `DateTime(0)` to `DateTime`.
- You are about to alter the column `updated_at` on the `Reference` table. The data in that column could be lost. The data in that column will be cast from `DateTime(0)` to `DateTime`.
- You are about to alter the column `created_at` on the `SubTask` table. The data in that column could be lost. The data in that column will be cast from `DateTime(0)` to `DateTime`.
- You are about to alter the column `updated_at` on the `SubTask` table. The data in that column could be lost. The data in that column will be cast from `DateTime(0)` to `DateTime`.
- You are about to alter the column `created_at` on the `Task` table. The data in that column could be lost. The data in that column will be cast from `DateTime(0)` to `DateTime`.
- You are about to alter the column `updated_at` on the `Task` table. The data in that column could be lost. The data in that column will be cast from `DateTime(0)` to `DateTime`.
- You are about to alter the column `invite_expired` on the `Task` table. The data in that column could be lost. The data in that column will be cast from `DateTime(0)` to `DateTime`.
- You are about to alter the column `created_at` on the `User` table. The data in that column could be lost. The data in that column will be cast from `DateTime(0)` to `DateTime`.
- You are about to alter the column `updated_at` on the `User` table. The data in that column could be lost. The data in that column will be cast from `DateTime(0)` to `DateTime`.
- You are about to alter the column `deleted_at` on the `User` table. The data in that column could be lost. The data in that column will be cast from `DateTime(0)` to `DateTime`.
- You are about to alter the column `alarm_date` on the `UserAlarm` table. The data in that column could be lost. The data in that column will be cast from `DateTime(0)` to `DateTime`.
- You are about to alter the column `created_at` on the `UserAlarm` table. The data in that column could be lost. The data in that column will be cast from `DateTime(0)` to `DateTime`.

*/
-- AlterTable
ALTER TABLE `Comment` MODIFY `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP;

-- AlterTable
ALTER TABLE `Communication` MODIFY `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updated_at` DATETIME NULL;

-- AlterTable
ALTER TABLE `Folder` MODIFY `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP;

-- AlterTable
ALTER TABLE `Log` MODIFY `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updated_at` DATETIME NULL;

-- AlterTable
ALTER TABLE `Member` MODIFY `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP;

-- AlterTable
ALTER TABLE `Reference` MODIFY `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updated_at` DATETIME NULL;

-- AlterTable
ALTER TABLE `SubTask` MODIFY `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updated_at` DATETIME NULL;

-- AlterTable
ALTER TABLE `Task` MODIFY `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updated_at` DATETIME NULL,
MODIFY `invite_expired` DATETIME NULL;

-- AlterTable
ALTER TABLE `User` MODIFY `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updated_at` DATETIME NULL,
MODIFY `deleted_at` DATETIME NULL;

-- AlterTable
ALTER TABLE `UserAlarm` MODIFY `alarm_date` DATETIME NOT NULL,
MODIFY `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP;
202 changes: 202 additions & 0 deletions prisma/migrations/20260126115741_20260126/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
-- CreateTable
CREATE TABLE `TaskPriority` (
`priority_id` INTEGER NOT NULL AUTO_INCREMENT,
`user_id` INTEGER NOT NULL,
`task_id` INTEGER NOT NULL,
`rank` INTEGER NOT NULL,
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` DATETIME NULL,

UNIQUE INDEX `TaskPriority_user_id_task_id_key`(`user_id`, `task_id`),
PRIMARY KEY (`priority_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `User` (
`user_id` INTEGER NOT NULL AUTO_INCREMENT,
`nickname` VARCHAR(10) NOT NULL,
`phone_num` VARCHAR(15) NOT NULL,
`email` VARCHAR(50) NOT NULL,
`profile_image` VARCHAR(200) NULL,
`password` VARCHAR(50) NULL,
`provider` ENUM('KAKAO') NULL,
`provider_id` VARCHAR(10) NULL,
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` DATETIME NULL,
`deleted_at` DATETIME NULL,
`deadline_alarm` INTEGER NOT NULL DEFAULT 24,
`task_alarm` INTEGER NOT NULL DEFAULT 24,

UNIQUE INDEX `User_email_key`(`email`),
INDEX `User_deleted_at_idx`(`deleted_at`),
UNIQUE INDEX `User_provider_provider_id_key`(`provider`, `provider_id`),
PRIMARY KEY (`user_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `UserAlarm` (
`alarm_id` INTEGER NOT NULL AUTO_INCREMENT,
`user_id` INTEGER NOT NULL,
`task_id` INTEGER NULL,
`sub_task_id` INTEGER NULL,
`title` VARCHAR(30) NOT NULL,
`alarm_content` VARCHAR(50) NOT NULL,
`is_read` BOOLEAN NOT NULL DEFAULT false,
`alarm_date` DATETIME NOT NULL,
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,

PRIMARY KEY (`alarm_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `Folder` (
`folder_id` INTEGER NOT NULL AUTO_INCREMENT,
`user_id` INTEGER NOT NULL,
`folder_title` VARCHAR(100) NOT NULL,
`color` VARCHAR(7) NOT NULL,
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,

PRIMARY KEY (`folder_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `Task` (
`task_id` INTEGER NOT NULL AUTO_INCREMENT,
`folder_id` INTEGER NULL,
`title` VARCHAR(30) NOT NULL,
`deadline` DATE NOT NULL,
`type` ENUM('PERSONAL', 'TEAM') NOT NULL,
`status` ENUM('PENDING', 'PROGRESS', 'COMPLETED') NOT NULL,
`is_alarm` BOOLEAN NOT NULL DEFAULT true,
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` DATETIME NULL,
`invite_code` VARCHAR(50) NULL,
`invite_expired` DATETIME NULL,

PRIMARY KEY (`task_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `Member` (
`member_id` INTEGER NOT NULL AUTO_INCREMENT,
`user_id` INTEGER NOT NULL,
`task_id` INTEGER NOT NULL,
`role` BOOLEAN NOT NULL,
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,

UNIQUE INDEX `Member_user_id_task_id_key`(`user_id`, `task_id`),
PRIMARY KEY (`member_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `SubTask` (
`sub_task_id` INTEGER NOT NULL AUTO_INCREMENT,
`assignee_id` INTEGER NULL,
`task_id` INTEGER NOT NULL,
`title` VARCHAR(30) NOT NULL,
`end_date` DATE NOT NULL,
`status` ENUM('PENDING', 'PROGRESS', 'COMPLETED') NOT NULL DEFAULT 'PENDING',
`is_alarm` BOOLEAN NOT NULL DEFAULT true,
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` DATETIME NULL,

PRIMARY KEY (`sub_task_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `Comment` (
`comment_id` INTEGER NOT NULL AUTO_INCREMENT,
`sub_task_id` INTEGER NOT NULL,
`user_id` INTEGER NOT NULL,
`content` TEXT NOT NULL,
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,

PRIMARY KEY (`comment_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `Reference` (
`data_id` INTEGER NOT NULL AUTO_INCREMENT,
`task_id` INTEGER NOT NULL,
`name` VARCHAR(16) NOT NULL,
`url` VARCHAR(255) NULL,
`file_url` VARCHAR(255) NULL,
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` DATETIME NULL,

PRIMARY KEY (`data_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `Log` (
`log_id` INTEGER NOT NULL AUTO_INCREMENT,
`task_id` INTEGER NOT NULL,
`date` DATE NOT NULL,
`agenda` TEXT NULL,
`conclusion` TEXT NULL,
`discussion` TEXT NULL,
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` DATETIME NULL,

PRIMARY KEY (`log_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `Communication` (
`comu_id` INTEGER NOT NULL AUTO_INCREMENT,
`task_id` INTEGER NOT NULL,
`name` VARCHAR(16) NOT NULL,
`url` VARCHAR(255) NOT NULL,
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` DATETIME NULL,

PRIMARY KEY (`comu_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `TaskPriority` ADD CONSTRAINT `TaskPriority_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `User`(`user_id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `TaskPriority` ADD CONSTRAINT `TaskPriority_task_id_fkey` FOREIGN KEY (`task_id`) REFERENCES `Task`(`task_id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `UserAlarm` ADD CONSTRAINT `UserAlarm_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `User`(`user_id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `UserAlarm` ADD CONSTRAINT `UserAlarm_task_id_fkey` FOREIGN KEY (`task_id`) REFERENCES `Task`(`task_id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `UserAlarm` ADD CONSTRAINT `UserAlarm_sub_task_id_fkey` FOREIGN KEY (`sub_task_id`) REFERENCES `SubTask`(`sub_task_id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Folder` ADD CONSTRAINT `Folder_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `User`(`user_id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Task` ADD CONSTRAINT `Task_folder_id_fkey` FOREIGN KEY (`folder_id`) REFERENCES `Folder`(`folder_id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Member` ADD CONSTRAINT `Member_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `User`(`user_id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Member` ADD CONSTRAINT `Member_task_id_fkey` FOREIGN KEY (`task_id`) REFERENCES `Task`(`task_id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `SubTask` ADD CONSTRAINT `SubTask_task_id_fkey` FOREIGN KEY (`task_id`) REFERENCES `Task`(`task_id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `SubTask` ADD CONSTRAINT `SubTask_assignee_id_fkey` FOREIGN KEY (`assignee_id`) REFERENCES `User`(`user_id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Comment` ADD CONSTRAINT `Comment_sub_task_id_fkey` FOREIGN KEY (`sub_task_id`) REFERENCES `SubTask`(`sub_task_id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Comment` ADD CONSTRAINT `Comment_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `User`(`user_id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Reference` ADD CONSTRAINT `Reference_task_id_fkey` FOREIGN KEY (`task_id`) REFERENCES `Task`(`task_id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Log` ADD CONSTRAINT `Log_task_id_fkey` FOREIGN KEY (`task_id`) REFERENCES `Task`(`task_id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Communication` ADD CONSTRAINT `Communication_task_id_fkey` FOREIGN KEY (`task_id`) REFERENCES `Task`(`task_id`) ON DELETE CASCADE ON UPDATE CASCADE;
6 changes: 4 additions & 2 deletions src/services/task.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,18 @@ class TaskService {
taskData.deadline = new Date(taskData.deadline);
}

const finalType = taskData.type || currentTask.type;

// 폴더 변경 시 유효성 검사 (추가된 부분)
if (folderId) {
const folder = await taskRepository.findFolderById(folderId);
if (!folder) throw new NotFoundError("변경하려는 폴더가 존재하지 않습니다.");

// [보호 로직] 수정 시에도 팀/개인 폴더 규칙 적용
if (currentTask.type === 'TEAM' && folder.folderTitle !== '팀') {
if (finalType === 'TEAM' && folder.folderTitle !== '팀') {
throw new BadRequestError("INVALID_FOLDER", "팀 과제는 '팀' 폴더로만 이동할 수 있습니다.");
}
if (currentTask.type === 'PERSONAL' && folder.folderTitle === '팀') {
if (finalType === 'PERSONAL' && folder.folderTitle === '팀') {
throw new BadRequestError("INVALID_FOLDER", "개인 과제는 '팀' 폴더로 이동할 수 없습니다.");
}
}
Expand Down