-- ============================================
-- MIGRATION: Add parent/child list support
-- ============================================

-- 'parent' = chứa child lists, 'term' = chứa terms
ALTER TABLE flashcard_list
    ADD COLUMN type VARCHAR(10) NOT NULL DEFAULT 'term';

-- Self-referencing FK: null nếu là top-level list
ALTER TABLE flashcard_list
    ADD COLUMN parent_id INT REFERENCES flashcard_list(id) ON DELETE SET NULL;

-- child_ids không cần column — query: SELECT id FROM flashcard_list WHERE parent_id = ?

-- ============================================
-- INDEXES
-- ============================================

CREATE INDEX idx_list_parent_id ON flashcard_list(parent_id);
CREATE INDEX idx_list_type      ON flashcard_list(type);
