CREATE TABLE track_comments (
    id BIGSERIAL PRIMARY KEY,
    track_id BIGINT NOT NULL REFERENCES tracks(id) ON DELETE CASCADE,
    user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
    parent_id BIGINT REFERENCES track_comments(id) ON DELETE CASCADE,
    content TEXT NOT NULL,
    is_edited BOOLEAN DEFAULT FALSE,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    deleted_at TIMESTAMP
);

CREATE INDEX idx_track_comments_track_id ON track_comments(track_id);
CREATE INDEX idx_track_comments_user_id ON track_comments(user_id);
CREATE INDEX idx_track_comments_parent_id ON track_comments(parent_id);
CREATE INDEX idx_track_comments_created_at ON track_comments(created_at DESC);

