-- ============================================================
-- 脚本名称：school_dept_permission.sql
-- 功能说明：学校数据权限支持 - 增加部门关联字段
-- 作    者：pangu
-- 创建时间：2026-02-03
-- ============================================================

-- 1. pg_school 表增加 dept_id 字段
ALTER TABLE pg_school ADD COLUMN dept_id BIGINT COMMENT '关联部门ID';
CREATE INDEX idx_school_dept ON pg_school(dept_id);

-- 2. 查看现有学校数据
SELECT school_id, school_name, school_code FROM pg_school;

-- 3. 查看现有部门数据
SELECT dept_id, parent_id, dept_name, ancestors FROM sys_dept;
