Index

public.roles

Description

Gives users permissions to perform actions in the system. Roles can also be related to courses and organizations so that each organization and course can have its specialized roles. If course_id is defined, the role is related to a course, if organization_id is defined and course_id is not defined, the role is related to an organization. Otherwise the role is global.

Columns

Name Type Default Nullable Children Parents Comment
course_id uuid true public.courses If not null, scopes the role to be valid only within a course.
course_instance_id uuid true public.course_instances
created_at timestamp with time zone now() false Timestamp when the record was created.
deleted_at timestamp with time zone true Timestamp when the record was deleted. If null, the record is not deleted.
exam_id uuid true public.exams The exam the role is associated with.
id uuid uuid_generate_v4() false A unique, stable identifier for the record.
is_global boolean false false
organization_id uuid true public.organizations If not null, scopes the role to be valid only inside an organization. If course_id is not null, it takes precedence and this is ignored.
role user_role false The role that this row gives membership to. See https://rage.github.io/secret-project-331/headless_lms_actix/models/roles/enum.UserRole.html.
updated_at timestamp with time zone now() false Timestamp when the record was last updated. The field is updated automatically by the set_timestamp trigger.
user_id uuid false public.users User to whom the role applies.

Constraints

Name Type Definition
roles_course_id_fkey FOREIGN KEY FOREIGN KEY (course_id) REFERENCES courses(id)
roles_course_instance_id_fkey FOREIGN KEY FOREIGN KEY (course_instance_id) REFERENCES course_instances(id)
roles_exam_id_fkey FOREIGN KEY FOREIGN KEY (exam_id) REFERENCES exams(id)
roles_organization_id_fkey FOREIGN KEY FOREIGN KEY (organization_id) REFERENCES organizations(id)
roles_pkey PRIMARY KEY PRIMARY KEY (id)
roles_user_id_fkey FOREIGN KEY FOREIGN KEY (user_id) REFERENCES users(id)
single_role_for_domain CHECK CHECK ((((num_nonnulls(organization_id, course_id, course_instance_id, exam_id) = 1) AND (is_global = false)) OR ((num_nonnulls(organization_id, course_id, course_instance_id, exam_id) = 0) AND (is_global = true))))

Indexes

Name Definition
roles_pkey CREATE UNIQUE INDEX roles_pkey ON public.roles USING btree (id)

Triggers

Name Definition
set_timestamp CREATE TRIGGER set_timestamp BEFORE UPDATE ON public.roles FOR EACH ROW EXECUTE FUNCTION trigger_set_timestamp()

Relations

er

Generated by tbls