ALTER TABLE symbol_index_tag ADD COLUMN scope_chain TEXT;

CREATE TABLE IF NOT EXISTS symbol_index_scope (
  parent_id INTEGER NOT NULL,
  file_path TEXT NOT NULL,
  start_line INTEGER NOT NULL,
  start_column INTEGER NOT NULL,
  parent_start_line INTEGER,
  parent_start_column INTEGER,
  PRIMARY KEY (parent_id, file_path, start_line, start_column),
  FOREIGN KEY (parent_id) REFERENCES symbol_index_parent_path(id) ON DELETE CASCADE
);

CREATE INDEX IF NOT EXISTS idx_symbol_index_scope_parent_file
  ON symbol_index_scope(parent_id, file_path);
