SET @schema_name := DATABASE(); SET @table_exists := ( SELECT COUNT(1) FROM information_schema.tables WHERE table_schema = @schema_name AND table_name = 'member_content_preference' ); SET @create_table_sql := IF( @table_exists = 0, 'CREATE TABLE member_content_preference ( id BIGINT NOT NULL AUTO_INCREMENT COMMENT ''PK'', member_id BIGINT NOT NULL COMMENT ''회원 ID (member.id 참조)'', is_adult_content_visible TINYINT(1) NOT NULL DEFAULT 0 COMMENT ''성인 콘텐츠 노출 여부 (0: 비노출, 1: 노출)'', content_type VARCHAR(20) NOT NULL DEFAULT ''ALL'' COMMENT ''콘텐츠 타입 필터 값'', adult_content_visibility_changed_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ''성인 콘텐츠 노출 설정 변경 시각'', content_type_changed_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ''콘텐츠 타입 설정 변경 시각'', created_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP COMMENT ''생성 시각'', updated_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT ''수정 시각'', PRIMARY KEY (id), UNIQUE KEY uk_member_content_preference_member_id (member_id), CONSTRAINT fk_member_content_preference_member_id FOREIGN KEY (member_id) REFERENCES member (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT=''회원 콘텐츠 조회 설정''', 'SELECT ''member_content_preference already exists'' AS message' ); PREPARE create_table_stmt FROM @create_table_sql; EXECUTE create_table_stmt; DEALLOCATE PREPARE create_table_stmt;