imported flash card
This commit is contained in:
20
supabase/migrations/006_flashcard_list_hierarchy.sql
Normal file
20
supabase/migrations/006_flashcard_list_hierarchy.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
-- ============================================
|
||||
-- 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);
|
||||
Reference in New Issue
Block a user