def METHOD_NAME(project, from_tag, to_tag, color):
    to_tag = to_tag.lower()
    sql = """
        UPDATE userstories_userstory
           SET tags = array_distinct(array_replace(tags, %(from_tag)s, %(to_tag)s))
         WHERE project_id = %(project_id)s AND %(from_tag)s = ANY(tags);
        UPDATE tasks_task
           SET tags = array_distinct(array_replace(tags, %(from_tag)s, %(to_tag)s))
         WHERE project_id = %(project_id)s AND %(from_tag)s = ANY(tags);
        UPDATE issues_issue
           SET tags = array_distinct(array_replace(tags, %(from_tag)s, %(to_tag)s))
         WHERE project_id = %(project_id)s AND %(from_tag)s = ANY(tags);
        UPDATE epics_epic
           SET tags = array_distinct(array_replace(tags, %(from_tag)s, %(to_tag)s))
         WHERE project_id = %(project_id)s AND %(from_tag)s = ANY(tags);
    """
    cursor = connection.cursor()
    cursor.execute(sql, params={"from_tag": from_tag, "to_tag": to_tag, "project_id": project.id})
    tags_colors = dict(project.tags_colors)
    tags_colors.pop(from_tag)
    tags_colors[to_tag] = color
    project.tags_colors = list(tags_colors.items())
    project.save(update_fields=["tags_colors"])