jkliuh2 / Honey_Apple

1 stars 0 forks source link

`chat`, `chat_message` DB 만들기 #20

Open jkliuh2 opened 6 months ago

jkliuh2 commented 6 months ago
CREATE TABLE `chat` (
    `id` int NOT NULL AUTO_INCREMENT primary key
    , `postId` int not null
    , `buyerId` int not null
    , `tradeStatus` varchar(16) not null
    , `createdAt` timestamp DEFAULT CURRENT_TIMESTAMP
    , `updatedAt` timestamp DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

거래제안 채팅방의 DB 생성.

jkliuh2 commented 6 months ago
CREATE TABLE `chat_message` (
    `id` int NOT NULL AUTO_INCREMENT primary key
    , `chatId` int not null
        , `sellerId` int
        , `buyerId` int
        , `content` varchar(256) not null
    , `createdAt` timestamp DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

sellerId, buyerId는 모두 user 테이블의 pk 참조값. 실제 컬럼에서는 둘 중 하나의 값만 채워지고 다른 하나는 NULL 상태가 된다. 채팅 메시지를 입력한 쪽이 데이터가 채워지는 user를 나타낸다.