ALTER TABLE public.study_group_relation ADD COLUMN planid integer NULL;

ALTER TABLE public.study_group_relation
    ADD FOREIGN KEY (planid)
        REFERENCES study_plan(planid)
        ON DELETE RESTRICT
        ON UPDATE CASCADE
;

