Skip to content

Commit

Permalink
#105 feat: Dummy Data insert sql 프로시저 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
seonghoo1217 committed Jul 6, 2024
1 parent dd33abe commit cd49bcc
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/main/resources/db/locust_dummy.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
DROP PROCEDURE IF EXISTS insert_dummy_data;

CREATE PROCEDURE insert_dummy_data(IN num_members INT)
BEGIN
DECLARE i INT DEFAULT 1;
DECLARE username VARCHAR(255);
DECLARE `password` VARCHAR(255); -- 변수 이름을 백틱으로 묶음
DECLARE nickname VARCHAR(255);

WHILE i <= num_members
DO
SET username = CONCAT('user', i);
SET `password` = 'password'; -- 모든 사용자의 비밀번호를 동일하게 설정 (실제 환경에서는 변경 필요)
SET nickname = CONCAT('nickname', i);

INSERT INTO member (username, `password`, nickname) VALUES (username, `password`, nickname);

SET i = i + 1;
END WHILE;

-- GameRoom 데이터 생성 (1000개)
SET i = 1;
WHILE i <= 1000
DO
INSERT INTO game_room (creator, title, participant_count, participant_limit, room_code, game_status)
VALUES ((SELECT nickname FROM member ORDER BY RAND() LIMIT 1),
CONCAT('Game Room ', i),
FLOOR(RAND() * 2) + 1, -- participant_count (1 또는 2)
2,
UUID_TO_BIN(UUID()),
'NON_PLAYING');

SET i = i + 1;
END WHILE;

-- MemberRecord 데이터 생성 (Member 수만큼)
INSERT INTO member_record (member_id, win, lose, rate)
SELECT id, FLOOR(RAND() * 100), FLOOR(RAND() * 100), ROUND(RAND() * 100, 2)
FROM member;
END;
CALL insert_dummy_data(1000);

0 comments on commit cd49bcc

Please sign in to comment.