переработал бд

This commit is contained in:
Zuev committed 2026-10-21 02:14:01 +03:00
1 parent 6720970fa0
commit ac228ae0c3
31 files changed
+1679 -281

No files matched your search

@@ -21,6 +21,15 @@ final class DatabaseConstraintViolationMapper {
); );
private static final Map<String, ViolationResponse> KNOWN_CONSTRAINTS = Map.ofEntries( private static final Map<String, ViolationResponse> KNOWN_CONSTRAINTS = Map.ofEntries(
badRequest("fk_student_groups_profile_specialty", "Профиль группы не относится к выбранному направлению"),
badRequest("fk_academic_calendars_profile_specialty", "Профиль календаря не относится к выбранному направлению"),
badRequest("fk_schedule_rules_version", "Версия расписания относится к другому семестру"),
badRequest("chk_users_role", "Недопустимая роль пользователя"),
badRequest("chk_lesson_types_code", "Недопустимый технический код вида занятия"),
badRequest("chk_lesson_type_code_immutable", "Нельзя изменять стабильный код вида занятия"),
badRequest("chk_schedule_rule_loads_hours_non_negative", "Количество академических часов не может быть отрицательным"),
badRequest("chk_schedule_rule_loads_hours_even", "Количество академических часов должно быть чётным"),
badRequest("chk_schedule_rule_loads_start_week", "Неделя начала занятия должна быть положительной"),
badRequest("chk_teacher_creation_request_status", "Недопустимый статус заявки на преподавателя"), badRequest("chk_teacher_creation_request_status", "Недопустимый статус заявки на преподавателя"),
badRequest("chk_teacher_department_dates", "Дата окончания назначения кафедры раньше даты начала"), badRequest("chk_teacher_department_dates", "Дата окончания назначения кафедры раньше даты начала"),
badRequest("chk_time_slot_scopes_mode", "Недопустимый режим сетки времени"), badRequest("chk_time_slot_scopes_mode", "Недопустимый режим сетки времени"),
@@ -92,6 +101,15 @@ final class DatabaseConstraintViolationMapper {
if (known != null) { if (known != null) {
return known.withDetails(constraintName, sqlState); return known.withDetails(constraintName, sqlState);
} }
if (constraintName.startsWith("chk_") && constraintName.endsWith("_lifecycle_status")) {
return new ViolationResponse(HttpStatus.BAD_REQUEST, "Допустимые статусы записи: ACTIVE и ARCHIVED", constraintName, sqlState);
}
if (constraintName.startsWith("chk_") && constraintName.endsWith("_lifecycle_period")) {
return new ViolationResponse(HttpStatus.BAD_REQUEST, "Дата окончания действия раньше даты начала", constraintName, sqlState);
}
if (constraintName.startsWith("chk_") && constraintName.endsWith("_lifecycle_archive")) {
return new ViolationResponse(HttpStatus.BAD_REQUEST, "Статус записи не согласован с данными архивирования", constraintName, sqlState);
}
if (constraintName.endsWith("_fkey")) { if (constraintName.endsWith("_fkey")) {
return new ViolationResponse( return new ViolationResponse(
HttpStatus.CONFLICT, HttpStatus.CONFLICT,
@@ -27,7 +27,7 @@ public class LessonTypeController {
public List<LessonTypeResponse> getAllLessonTypes() { public List<LessonTypeResponse> getAllLessonTypes() {
return lessonTypesRepository.findAll().stream() return lessonTypesRepository.findAll().stream()
.sorted(Comparator.comparing(LessonType::getLessonType)) .sorted(Comparator.comparing(LessonType::getLessonType))
.map(lessonType -> new LessonTypeResponse(lessonType.getId(), lessonType.getLessonType())) .map(lessonType -> new LessonTypeResponse(lessonType.getId(), lessonType.getLessonType(), lessonType.getCode()))
.toList(); .toList();
} }
} }
@@ -2,6 +2,7 @@ package com.magistr.app.dto;
public record LessonTypeResponse( public record LessonTypeResponse(
Long id, Long id,
String name String name,
String code
) { ) {
} }
@@ -13,6 +13,17 @@ public class LessonType {
@Column(name="name", nullable = false) @Column(name="name", nullable = false)
private String lessonType; private String lessonType;
@Column(name = "code", nullable = false, unique = true, updatable = false, length = 30)
private String code;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Long getId() { public Long getId() {
return id; return id;
} }
@@ -26,6 +26,9 @@ public abstract class LifecycleEntity {
@Column(name = "archived_at") @Column(name = "archived_at")
private Instant archivedAt; private Instant archivedAt;
@Column(name = "archived_by")
private Long archivedBy;
@Column(name = "archive_reason") @Column(name = "archive_reason")
private String archiveReason; private String archiveReason;
@@ -61,6 +64,14 @@ public abstract class LifecycleEntity {
this.archivedAt = archivedAt; this.archivedAt = archivedAt;
} }
public Long getArchivedBy() {
return archivedBy;
}
public void setArchivedBy(Long archivedBy) {
this.archivedBy = archivedBy;
}
public String getArchiveReason() { public String getArchiveReason() {
return archiveReason; return archiveReason;
} }
@@ -106,6 +117,7 @@ public abstract class LifecycleEntity {
public void restore() { public void restore() {
status = STATUS_ACTIVE; status = STATUS_ACTIVE;
archivedAt = null; archivedAt = null;
archivedBy = null;
archiveReason = null; archiveReason = null;
activeTo = null; activeTo = null;
} }
@@ -1,7 +1,5 @@
package com.magistr.app.model; package com.magistr.app.model;
import java.util.Locale;
public enum ScheduleLessonCategory { public enum ScheduleLessonCategory {
LECTURE("Лекции"), LECTURE("Лекции"),
LABORATORY("Лабораторные"), LABORATORY("Лабораторные"),
@@ -18,38 +16,13 @@ public enum ScheduleLessonCategory {
} }
public static ScheduleLessonCategory fromLessonType(LessonType lessonType) { public static ScheduleLessonCategory fromLessonType(LessonType lessonType) {
if (lessonType == null || lessonType.getLessonType() == null) { if (lessonType == null || lessonType.getCode() == null) {
throw new IllegalArgumentException("Тип занятия должен быть лекцией, практикой или лабораторной работой"); throw new IllegalArgumentException("У вида занятия должен быть задан стабильный код");
} }
String name = lessonType.getLessonType() try {
.trim() return valueOf(lessonType.getCode());
.toLowerCase(Locale.forLanguageTag("ru-RU")) } catch (IllegalArgumentException exception) {
.replace('ё', 'е'); throw new IllegalArgumentException("Неподдерживаемый код вида занятия: " + lessonType.getCode());
boolean lecture = name.equals("лекция") || name.equals("лекции") || name.startsWith("лекц");
boolean laboratory = name.equals("лабораторная работа")
|| name.equals("лабораторные работы")
|| name.startsWith("лаб")
|| name.contains("лаборатор");
boolean practice = name.equals("практика")
|| name.equals("практики")
|| name.startsWith("практ")
|| name.contains("практичес")
|| name.contains("семинар");
int matches = (lecture ? 1 : 0) + (laboratory ? 1 : 0) + (practice ? 1 : 0);
if (matches > 1) {
throw new IllegalArgumentException("Тип занятия \"" + lessonType.getLessonType()
+ "\" неоднозначен. Используйте отдельный тип: лекция, практика или лабораторная работа");
} }
if (lecture) {
return LECTURE;
}
if (laboratory) {
return LABORATORY;
}
if (practice) {
return PRACTICE;
}
throw new IllegalArgumentException("Тип занятия \"" + lessonType.getLessonType()
+ "\" должен быть лекцией, практикой или лабораторной работой");
} }
} }
@@ -6,6 +6,8 @@ import jakarta.persistence.*;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.Instant; import java.time.Instant;
import java.util.HashSet; import java.util.HashSet;
import java.util.EnumMap;
import java.util.Map;
import java.util.Set; import java.util.Set;
@Entity @Entity
@@ -50,23 +52,11 @@ public class ScheduleRule {
@Column(name = "valid_to") @Column(name = "valid_to")
private LocalDate validTo; private LocalDate validTo;
@Column(name = "lecture_academic_hours", nullable = false) @ElementCollection
private Integer lectureAcademicHours = 0; @CollectionTable(name = "schedule_rule_loads", joinColumns = @JoinColumn(name = "schedule_rule_id"))
@MapKeyEnumerated(EnumType.STRING)
@Column(name = "laboratory_academic_hours", nullable = false) @MapKeyColumn(name = "lesson_type_code", length = 30)
private Integer laboratoryAcademicHours = 0; private Map<ScheduleLessonCategory, ScheduleRuleLoad> loads = new EnumMap<>(ScheduleLessonCategory.class);
@Column(name = "practice_academic_hours", nullable = false)
private Integer practiceAcademicHours = 0;
@Column(name = "lecture_start_week", nullable = false)
private Integer lectureStartWeek = 1;
@Column(name = "laboratory_start_week", nullable = false)
private Integer laboratoryStartWeek = 1;
@Column(name = "practice_start_week", nullable = false)
private Integer practiceStartWeek = 1;
@ManyToMany @ManyToMany
@JoinTable( @JoinTable(
@@ -164,67 +154,65 @@ public class ScheduleRule {
} }
public Integer getLectureAcademicHours() { public Integer getLectureAcademicHours() {
return lectureAcademicHours; return academicHoursFor(ScheduleLessonCategory.LECTURE);
} }
public void setLectureAcademicHours(Integer lectureAcademicHours) { public void setLectureAcademicHours(Integer lectureAcademicHours) {
this.lectureAcademicHours = lectureAcademicHours; loadFor(ScheduleLessonCategory.LECTURE).setAcademicHours(lectureAcademicHours);
} }
public Integer getLaboratoryAcademicHours() { public Integer getLaboratoryAcademicHours() {
return laboratoryAcademicHours; return academicHoursFor(ScheduleLessonCategory.LABORATORY);
} }
public void setLaboratoryAcademicHours(Integer laboratoryAcademicHours) { public void setLaboratoryAcademicHours(Integer laboratoryAcademicHours) {
this.laboratoryAcademicHours = laboratoryAcademicHours; loadFor(ScheduleLessonCategory.LABORATORY).setAcademicHours(laboratoryAcademicHours);
} }
public Integer getPracticeAcademicHours() { public Integer getPracticeAcademicHours() {
return practiceAcademicHours; return academicHoursFor(ScheduleLessonCategory.PRACTICE);
} }
public void setPracticeAcademicHours(Integer practiceAcademicHours) { public void setPracticeAcademicHours(Integer practiceAcademicHours) {
this.practiceAcademicHours = practiceAcademicHours; loadFor(ScheduleLessonCategory.PRACTICE).setAcademicHours(practiceAcademicHours);
} }
public Integer getLectureStartWeek() { public Integer getLectureStartWeek() {
return lectureStartWeek; return startWeekFor(ScheduleLessonCategory.LECTURE);
} }
public void setLectureStartWeek(Integer lectureStartWeek) { public void setLectureStartWeek(Integer lectureStartWeek) {
this.lectureStartWeek = lectureStartWeek; loadFor(ScheduleLessonCategory.LECTURE).setStartWeek(lectureStartWeek);
} }
public Integer getLaboratoryStartWeek() { public Integer getLaboratoryStartWeek() {
return laboratoryStartWeek; return startWeekFor(ScheduleLessonCategory.LABORATORY);
} }
public void setLaboratoryStartWeek(Integer laboratoryStartWeek) { public void setLaboratoryStartWeek(Integer laboratoryStartWeek) {
this.laboratoryStartWeek = laboratoryStartWeek; loadFor(ScheduleLessonCategory.LABORATORY).setStartWeek(laboratoryStartWeek);
} }
public Integer getPracticeStartWeek() { public Integer getPracticeStartWeek() {
return practiceStartWeek; return startWeekFor(ScheduleLessonCategory.PRACTICE);
} }
public void setPracticeStartWeek(Integer practiceStartWeek) { public void setPracticeStartWeek(Integer practiceStartWeek) {
this.practiceStartWeek = practiceStartWeek; loadFor(ScheduleLessonCategory.PRACTICE).setStartWeek(practiceStartWeek);
} }
public int academicHoursFor(ScheduleLessonCategory category) { public int academicHoursFor(ScheduleLessonCategory category) {
return switch (category) { ScheduleRuleLoad load = loads.get(category);
case LECTURE -> valueOrZero(lectureAcademicHours); return load == null ? 0 : valueOrZero(load.getAcademicHours());
case LABORATORY -> valueOrZero(laboratoryAcademicHours);
case PRACTICE -> valueOrZero(practiceAcademicHours);
};
} }
public int startWeekFor(ScheduleLessonCategory category) { public int startWeekFor(ScheduleLessonCategory category) {
return switch (category) { ScheduleRuleLoad load = loads.get(category);
case LECTURE -> valueOrDefault(lectureStartWeek, 1); return load == null ? 1 : valueOrDefault(load.getStartWeek(), 1);
case LABORATORY -> valueOrDefault(laboratoryStartWeek, 1); }
case PRACTICE -> valueOrDefault(practiceStartWeek, 1);
}; private ScheduleRuleLoad loadFor(ScheduleLessonCategory category) {
return loads.computeIfAbsent(category, ignored -> new ScheduleRuleLoad());
} }
@JsonIgnore @JsonIgnore
@@ -0,0 +1,31 @@
package com.magistr.app.model;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
/** Нагрузка одного вида занятий внутри правила расписания. */
@Embeddable
public class ScheduleRuleLoad {
@Column(name = "academic_hours", nullable = false)
private Integer academicHours = 0;
@Column(name = "start_week", nullable = false)
private Integer startWeek = 1;
public Integer getAcademicHours() {
return academicHours;
}
public void setAcademicHours(Integer academicHours) {
this.academicHours = academicHours;
}
public Integer getStartWeek() {
return startWeek;
}
public void setStartWeek(Integer startWeek) {
this.startWeek = startWeek;
}
}
@@ -32,6 +32,7 @@ public class TeacherPreference {
private String preferenceType; private String preferenceType;
@Column(name = "day_of_week") @Column(name = "day_of_week")
@org.hibernate.annotations.JdbcTypeCode(java.sql.Types.SMALLINT)
private Integer dayOfWeek; private Integer dayOfWeek;
@ManyToOne @ManyToOne
@@ -37,6 +37,7 @@ public interface ScheduleRuleRepository extends JpaRepository<ScheduleRule, Long
from ScheduleRule r from ScheduleRule r
join r.groups g join r.groups g
join r.scheduleVersion version join r.scheduleVersion version
left join fetch r.loads
left join fetch r.subject left join fetch r.subject
left join fetch r.semester sem left join fetch r.semester sem
left join fetch sem.academicYear left join fetch sem.academicYear
@@ -64,6 +65,7 @@ public interface ScheduleRuleRepository extends JpaRepository<ScheduleRule, Long
from ScheduleRule r from ScheduleRule r
join r.slots teacherSlot join r.slots teacherSlot
join r.scheduleVersion version join r.scheduleVersion version
left join fetch r.loads
left join fetch r.subject left join fetch r.subject
left join fetch r.semester sem left join fetch r.semester sem
left join fetch sem.academicYear left join fetch sem.academicYear
@@ -90,6 +92,7 @@ public interface ScheduleRuleRepository extends JpaRepository<ScheduleRule, Long
from ScheduleRule r from ScheduleRule r
join r.groups matchingGroup join r.groups matchingGroup
join r.scheduleVersion version join r.scheduleVersion version
left join fetch r.loads
left join fetch r.subject left join fetch r.subject
left join fetch r.semester sem left join fetch r.semester sem
left join fetch sem.academicYear left join fetch sem.academicYear
@@ -116,6 +119,7 @@ public interface ScheduleRuleRepository extends JpaRepository<ScheduleRule, Long
from ScheduleRule r from ScheduleRule r
join r.slots teacherSlot join r.slots teacherSlot
join r.scheduleVersion version join r.scheduleVersion version
left join fetch r.loads
left join fetch r.subject left join fetch r.subject
left join fetch r.semester sem left join fetch r.semester sem
left join fetch sem.academicYear left join fetch sem.academicYear
@@ -141,6 +145,7 @@ public interface ScheduleRuleRepository extends JpaRepository<ScheduleRule, Long
select distinct r select distinct r
from ScheduleRule r from ScheduleRule r
join r.scheduleVersion version join r.scheduleVersion version
left join fetch r.loads
left join fetch r.subject left join fetch r.subject
left join fetch r.semester sem left join fetch r.semester sem
left join fetch sem.academicYear left join fetch sem.academicYear
@@ -165,6 +170,7 @@ public interface ScheduleRuleRepository extends JpaRepository<ScheduleRule, Long
@Query(""" @Query("""
select distinct rule select distinct rule
from ScheduleRule rule from ScheduleRule rule
left join fetch rule.loads
left join fetch rule.subject left join fetch rule.subject
left join fetch rule.semester semester left join fetch rule.semester semester
left join fetch semester.academicYear left join fetch semester.academicYear
@@ -189,6 +195,7 @@ public interface ScheduleRuleRepository extends JpaRepository<ScheduleRule, Long
@Query(""" @Query("""
select distinct rule select distinct rule
from ScheduleRule rule from ScheduleRule rule
left join fetch rule.loads
left join fetch rule.subject left join fetch rule.subject
left join fetch rule.semester semester left join fetch rule.semester semester
left join fetch semester.academicYear left join fetch semester.academicYear
@@ -214,6 +221,7 @@ public interface ScheduleRuleRepository extends JpaRepository<ScheduleRule, Long
@Query(""" @Query("""
select distinct r select distinct r
from ScheduleRule r from ScheduleRule r
left join fetch r.loads
left join fetch r.subject left join fetch r.subject
left join fetch r.semester sem left join fetch r.semester sem
left join fetch sem.academicYear left join fetch sem.academicYear
@@ -233,6 +241,7 @@ public interface ScheduleRuleRepository extends JpaRepository<ScheduleRule, Long
@Query(""" @Query("""
select distinct r select distinct r
from ScheduleRule r from ScheduleRule r
left join fetch r.loads
left join fetch r.subject left join fetch r.subject
left join fetch r.semester sem left join fetch r.semester sem
left join fetch sem.academicYear left join fetch sem.academicYear
@@ -43,7 +43,8 @@ CREATE TABLE IF NOT EXISTS specialty_profiles (
archived_at TIMESTAMPTZ, archived_at TIMESTAMPTZ,
archived_by BIGINT, archived_by BIGINT,
archive_reason TEXT, archive_reason TEXT,
CONSTRAINT uq_specialty_profiles_name UNIQUE (specialty_id, name) CONSTRAINT uq_specialty_profiles_name UNIQUE (specialty_id, name),
CONSTRAINT uq_specialty_profiles_id_specialty UNIQUE (id, specialty_id)
); );
-- ========================================== -- ==========================================
@@ -219,7 +220,9 @@ CREATE TABLE IF NOT EXISTS student_groups (
education_form_id BIGINT NOT NULL REFERENCES education_forms(id), education_form_id BIGINT NOT NULL REFERENCES education_forms(id),
department_id BIGINT NOT NULL REFERENCES departments(id), department_id BIGINT NOT NULL REFERENCES departments(id),
specialty_id BIGINT NOT NULL REFERENCES specialties(id), specialty_id BIGINT NOT NULL REFERENCES specialties(id),
specialty_profile_id BIGINT NOT NULL REFERENCES specialty_profiles(id), specialty_profile_id BIGINT NOT NULL,
CONSTRAINT fk_student_groups_profile_specialty FOREIGN KEY (specialty_profile_id, specialty_id)
REFERENCES specialty_profiles(id, specialty_id),
year_start_study BIGINT NOT NULL year_start_study BIGINT NOT NULL
CONSTRAINT chk_student_groups_year_start_positive CHECK (year_start_study > 0), CONSTRAINT chk_student_groups_year_start_positive CHECK (year_start_study > 0),
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP, created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
@@ -359,6 +362,7 @@ CREATE INDEX IF NOT EXISTS idx_subject_comments_subject
CREATE TABLE IF NOT EXISTS lesson_types ( CREATE TABLE IF NOT EXISTS lesson_types (
id BIGSERIAL PRIMARY KEY, id BIGSERIAL PRIMARY KEY,
name VARCHAR(50) UNIQUE NOT NULL, name VARCHAR(50) UNIQUE NOT NULL,
code VARCHAR(30) NOT NULL UNIQUE CONSTRAINT chk_lesson_types_code CHECK (code ~ '^[A-Z][A-Z0-9_]*$'),
color_code VARCHAR(7) DEFAULT '#3788d8', color_code VARCHAR(7) DEFAULT '#3788d8',
duration_minutes INT DEFAULT 90 duration_minutes INT DEFAULT 90
); );
@@ -399,7 +403,7 @@ CREATE TABLE IF NOT EXISTS classrooms (
CREATE TABLE IF NOT EXISTS classroom_equipments ( CREATE TABLE IF NOT EXISTS classroom_equipments (
classroom_id BIGINT NOT NULL REFERENCES classrooms(id) ON DELETE CASCADE, classroom_id BIGINT NOT NULL REFERENCES classrooms(id) ON DELETE CASCADE,
equipment_id BIGINT NOT NULL REFERENCES equipments(id) ON DELETE CASCADE, equipment_id BIGINT NOT NULL REFERENCES equipments(id) ON DELETE CASCADE,
quantity INT DEFAULT 1 CHECK (quantity > 0), quantity INT NOT NULL DEFAULT 1 CHECK (quantity > 0),
notes TEXT, notes TEXT,
PRIMARY KEY (classroom_id, equipment_id) PRIMARY KEY (classroom_id, equipment_id)
); );
@@ -475,7 +479,6 @@ CREATE TABLE IF NOT EXISTS time_slots (
CREATE UNIQUE INDEX IF NOT EXISTS uq_time_slots_scope_order CREATE UNIQUE INDEX IF NOT EXISTS uq_time_slots_scope_order
ON time_slots(time_slot_scope_id, order_number); ON time_slots(time_slot_scope_id, order_number);
CREATE INDEX IF NOT EXISTS idx_time_slots_scope ON time_slots(time_slot_scope_id, order_number);
CREATE TABLE IF NOT EXISTS time_slot_date_assignments ( CREATE TABLE IF NOT EXISTS time_slot_date_assignments (
id BIGSERIAL PRIMARY KEY, id BIGSERIAL PRIMARY KEY,
@@ -528,11 +531,13 @@ CREATE TABLE IF NOT EXISTS academic_calendars (
title VARCHAR(255) NOT NULL, title VARCHAR(255) NOT NULL,
academic_year_id BIGINT NOT NULL REFERENCES academic_years(id) ON DELETE CASCADE, academic_year_id BIGINT NOT NULL REFERENCES academic_years(id) ON DELETE CASCADE,
specialty_id BIGINT NOT NULL REFERENCES specialties(id), specialty_id BIGINT NOT NULL REFERENCES specialties(id),
specialty_profile_id BIGINT NOT NULL REFERENCES specialty_profiles(id), specialty_profile_id BIGINT NOT NULL,
study_form_id BIGINT NOT NULL REFERENCES education_forms(id), study_form_id BIGINT NOT NULL REFERENCES education_forms(id),
course_count INT NOT NULL DEFAULT 4, course_count INT NOT NULL DEFAULT 4,
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP, created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT fk_academic_calendars_profile_specialty FOREIGN KEY (specialty_profile_id, specialty_id)
REFERENCES specialty_profiles(id, specialty_id),
CONSTRAINT chk_academic_calendars_course_count CHECK (course_count BETWEEN 1 AND 8), CONSTRAINT chk_academic_calendars_course_count CHECK (course_count BETWEEN 1 AND 8),
CONSTRAINT uq_academic_calendar_title UNIQUE (academic_year_id, specialty_profile_id, study_form_id, title) CONSTRAINT uq_academic_calendar_title UNIQUE (academic_year_id, specialty_profile_id, study_form_id, title)
); );
@@ -609,14 +614,9 @@ CREATE INDEX IF NOT EXISTS idx_group_calendar_assignments_lookup
CREATE TABLE IF NOT EXISTS schedule_rules ( CREATE TABLE IF NOT EXISTS schedule_rules (
id BIGSERIAL PRIMARY KEY, id BIGSERIAL PRIMARY KEY,
load_revision BIGINT NOT NULL DEFAULT 0,
subject_id BIGINT NOT NULL REFERENCES subjects(id), subject_id BIGINT NOT NULL REFERENCES subjects(id),
semester_id BIGINT NOT NULL REFERENCES semesters(id) ON DELETE CASCADE, semester_id BIGINT NOT NULL REFERENCES semesters(id) ON DELETE CASCADE,
lecture_academic_hours INT NOT NULL,
laboratory_academic_hours INT NOT NULL,
practice_academic_hours INT NOT NULL,
lecture_start_week INT NOT NULL,
laboratory_start_week INT NOT NULL,
practice_start_week INT NOT NULL,
status VARCHAR(20) NOT NULL DEFAULT 'ACTIVE', status VARCHAR(20) NOT NULL DEFAULT 'ACTIVE',
valid_from DATE, valid_from DATE,
valid_to DATE, valid_to DATE,
@@ -624,19 +624,6 @@ CREATE TABLE IF NOT EXISTS schedule_rules (
change_reason TEXT, change_reason TEXT,
created_by BIGINT REFERENCES users(id), created_by BIGINT REFERENCES users(id),
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT chk_schedule_rules_type_hours_non_negative CHECK (
lecture_academic_hours >= 0
AND laboratory_academic_hours >= 0
AND practice_academic_hours >= 0
),
CONSTRAINT chk_schedule_rules_has_type_hours CHECK (
lecture_academic_hours + laboratory_academic_hours + practice_academic_hours > 0
),
CONSTRAINT chk_schedule_rules_start_weeks_positive CHECK (
lecture_start_week > 0
AND laboratory_start_week > 0
AND practice_start_week > 0
),
CONSTRAINT chk_schedule_rules_dates CHECK (valid_to IS NULL OR valid_from IS NULL OR valid_to >= valid_from) CONSTRAINT chk_schedule_rules_dates CHECK (valid_to IS NULL OR valid_from IS NULL OR valid_to >= valid_from)
); );
@@ -645,6 +632,80 @@ CREATE INDEX IF NOT EXISTS idx_schedule_rules_subject ON schedule_rules(subject_
CREATE INDEX IF NOT EXISTS idx_schedule_rules_status_dates CREATE INDEX IF NOT EXISTS idx_schedule_rules_status_dates
ON schedule_rules(status, valid_from, valid_to); ON schedule_rules(status, valid_from, valid_to);
-- Нагрузка хранится строками по виду занятия, без повторяющихся столбцов.
CREATE TABLE schedule_rule_loads (
schedule_rule_id BIGINT NOT NULL REFERENCES schedule_rules(id) ON DELETE CASCADE,
lesson_type_code VARCHAR(30) NOT NULL REFERENCES lesson_types(code),
academic_hours INT NOT NULL,
start_week INT NOT NULL DEFAULT 1,
PRIMARY KEY (schedule_rule_id, lesson_type_code),
CONSTRAINT chk_schedule_rule_loads_hours_non_negative CHECK (academic_hours >= 0),
CONSTRAINT chk_schedule_rule_loads_hours_even CHECK (mod(academic_hours, 2) = 0),
CONSTRAINT chk_schedule_rule_loads_start_week CHECK (start_week > 0)
);
-- Запись ревизии родителя сериализует изменения разных видов нагрузки.
-- Настоящая запись, а не только FOR UPDATE, защищает также REPEATABLE READ.
CREATE FUNCTION lock_schedule_rule_load_parent() RETURNS TRIGGER LANGUAGE plpgsql AS $$
DECLARE
parent_id BIGINT;
BEGIN
IF TG_OP = 'INSERT' THEN
UPDATE schedule_rules SET load_revision = load_revision + 1 WHERE id = NEW.schedule_rule_id;
RETURN NEW;
ELSIF TG_OP = 'DELETE' THEN
UPDATE schedule_rules SET load_revision = load_revision + 1 WHERE id = OLD.schedule_rule_id;
RETURN OLD;
END IF;
FOR parent_id IN SELECT id FROM schedule_rules
WHERE id IN (OLD.schedule_rule_id, NEW.schedule_rule_id) ORDER BY id LOOP
UPDATE schedule_rules SET load_revision = load_revision + 1 WHERE id = parent_id;
END LOOP;
RETURN NEW;
END $$;
CREATE TRIGGER trg_schedule_rule_loads_lock_parent
BEFORE INSERT OR UPDATE OR DELETE ON schedule_rule_loads
FOR EACH ROW EXECUTE FUNCTION lock_schedule_rule_load_parent();
-- Отложенная проверка позволяет одной транзакции создать правило и его нагрузку,
-- а также заменить единственный положительный вид нагрузки другим.
CREATE FUNCTION enforce_schedule_rule_has_load() RETURNS TRIGGER LANGUAGE plpgsql AS $$
DECLARE
rule_ids BIGINT[];
rule_id BIGINT;
BEGIN
IF TG_TABLE_NAME = 'schedule_rules' THEN
rule_ids := ARRAY[NEW.id];
ELSIF TG_OP = 'INSERT' THEN
rule_ids := ARRAY[NEW.schedule_rule_id];
ELSIF TG_OP = 'DELETE' THEN
rule_ids := ARRAY[OLD.schedule_rule_id];
ELSE
rule_ids := ARRAY[OLD.schedule_rule_id, NEW.schedule_rule_id];
END IF;
FOREACH rule_id IN ARRAY rule_ids LOOP
IF EXISTS (SELECT 1 FROM schedule_rules WHERE id = rule_id)
AND NOT EXISTS (SELECT 1 FROM schedule_rule_loads
WHERE schedule_rule_id = rule_id AND academic_hours > 0) THEN
RAISE EXCEPTION 'В правиле должен быть хотя бы один вид занятия с положительными часами'
USING ERRCODE = '23514', CONSTRAINT = 'chk_schedule_rules_has_type_hours';
END IF;
END LOOP;
RETURN NULL;
END $$;
CREATE CONSTRAINT TRIGGER trg_schedule_rules_has_load
AFTER INSERT OR UPDATE ON schedule_rules DEFERRABLE INITIALLY DEFERRED
FOR EACH ROW EXECUTE FUNCTION enforce_schedule_rule_has_load();
CREATE CONSTRAINT TRIGGER trg_schedule_rule_loads_has_load
AFTER INSERT OR UPDATE OR DELETE ON schedule_rule_loads DEFERRABLE INITIALLY DEFERRED
FOR EACH ROW EXECUTE FUNCTION enforce_schedule_rule_has_load();
COMMENT ON TABLE schedule_rule_loads IS 'Лимит академических часов и начальная неделя по стабильному коду вида занятия';
COMMENT ON COLUMN schedule_rules.load_revision IS 'Техническая ревизия для сериализации конкурентных изменений строк нагрузки';
CREATE TABLE IF NOT EXISTS schedule_rule_groups ( CREATE TABLE IF NOT EXISTS schedule_rule_groups (
schedule_rule_id BIGINT NOT NULL REFERENCES schedule_rules(id) ON DELETE CASCADE, schedule_rule_id BIGINT NOT NULL REFERENCES schedule_rules(id) ON DELETE CASCADE,
group_id BIGINT NOT NULL REFERENCES student_groups(id) ON DELETE CASCADE, group_id BIGINT NOT NULL REFERENCES student_groups(id) ON DELETE CASCADE,
@@ -717,17 +778,17 @@ CREATE INDEX IF NOT EXISTS idx_schedule_overrides_new_teacher
CREATE OR REPLACE FUNCTION validate_schedule_rule_slot_subgroups() CREATE OR REPLACE FUNCTION validate_schedule_rule_slot_subgroups()
RETURNS TRIGGER AS $$ RETURNS TRIGGER AS $$
DECLARE DECLARE
lesson_type_name VARCHAR(50); lesson_type_code VARCHAR(30);
rule_id BIGINT; rule_id BIGINT;
subgroup_group_id BIGINT; subgroup_group_id BIGINT;
has_group_duplicate BOOLEAN; has_group_duplicate BOOLEAN;
BEGIN BEGIN
SELECT slot.schedule_rule_id, type.name INTO rule_id, lesson_type_name SELECT slot.schedule_rule_id, type.code INTO rule_id, lesson_type_code
FROM schedule_rule_slots slot FROM schedule_rule_slots slot
JOIN lesson_types type ON type.id = slot.lesson_type_id JOIN lesson_types type ON type.id = slot.lesson_type_id
WHERE slot.id = NEW.schedule_rule_slot_id; WHERE slot.id = NEW.schedule_rule_slot_id;
IF lesson_type_name IS NULL OR LOWER(lesson_type_name) NOT LIKE '%лаб%' THEN IF lesson_type_code IS DISTINCT FROM 'LABORATORY' THEN
RAISE EXCEPTION 'Подгруппы можно выбирать только для лабораторных занятий'; RAISE EXCEPTION 'Подгруппы можно выбирать только для лабораторных занятий';
END IF; END IF;
@@ -831,12 +892,6 @@ COMMENT ON TABLE subject_comments IS 'Комментарии кафедр и а
COMMENT ON TABLE schedule_overrides IS 'Точечные изменения конкретных сгенерированных пар'; COMMENT ON TABLE schedule_overrides IS 'Точечные изменения конкретных сгенерированных пар';
COMMENT ON COLUMN schedule_overrides.lesson_date IS 'Исходная дата занятия, сформированного базовым правилом'; COMMENT ON COLUMN schedule_overrides.lesson_date IS 'Исходная дата занятия, сформированного базовым правилом';
COMMENT ON COLUMN schedule_overrides.target_lesson_date IS 'Новая дата единственного занятия при действии MOVE'; COMMENT ON COLUMN schedule_overrides.target_lesson_date IS 'Новая дата единственного занятия при действии MOVE';
COMMENT ON COLUMN schedule_rules.lecture_academic_hours IS 'Лимит академических часов лекций';
COMMENT ON COLUMN schedule_rules.laboratory_academic_hours IS 'Лимит академических часов лабораторных работ';
COMMENT ON COLUMN schedule_rules.practice_academic_hours IS 'Лимит академических часов практик';
COMMENT ON COLUMN schedule_rules.lecture_start_week IS 'Неделя начала лекций в семестре';
COMMENT ON COLUMN schedule_rules.laboratory_start_week IS 'Неделя начала лабораторных работ в семестре';
COMMENT ON COLUMN schedule_rules.practice_start_week IS 'Неделя начала практик в семестре';
COMMENT ON COLUMN schedule_rules.valid_from IS 'Дата начала действия версии правила расписания'; COMMENT ON COLUMN schedule_rules.valid_from IS 'Дата начала действия версии правила расписания';
COMMENT ON COLUMN schedule_rules.valid_to IS 'Дата окончания действия версии правила расписания'; COMMENT ON COLUMN schedule_rules.valid_to IS 'Дата окончания действия версии правила расписания';
@@ -1118,41 +1173,6 @@ ALTER TABLE schedule_overrides
-- ========================================== -- ==========================================
-- Инварианты правил расписания -- Инварианты правил расписания
-- ========================================== -- ==========================================
DO $$
DECLARE
lecture_violations BIGINT;
laboratory_violations BIGINT;
practice_violations BIGINT;
BEGIN
SELECT count(*)
INTO lecture_violations
FROM schedule_rules
WHERE mod(lecture_academic_hours, 2) <> 0;
SELECT count(*)
INTO laboratory_violations
FROM schedule_rules
WHERE mod(laboratory_academic_hours, 2) <> 0;
SELECT count(*)
INTO practice_violations
FROM schedule_rules
WHERE mod(practice_academic_hours, 2) <> 0;
IF lecture_violations > 0
OR laboratory_violations > 0
OR practice_violations > 0 THEN
RAISE EXCEPTION USING
ERRCODE = '23514',
MESSAGE = format(
'Невозможно создать baseline: нечётные академические часы правил расписания — лекции=%s, лабораторные=%s, практики=%s. Исправьте исходные данные и повторите создание схемы.',
lecture_violations,
laboratory_violations,
practice_violations
);
END IF;
END $$;
DO $$ DO $$
DECLARE DECLARE
duplicate_slot_groups BIGINT; duplicate_slot_groups BIGINT;
@@ -1192,17 +1212,6 @@ BEGIN
END IF; END IF;
END $$; END $$;
ALTER TABLE schedule_rules
ADD CONSTRAINT chk_schedule_rules_academic_hours_even
CHECK (
mod(lecture_academic_hours, 2) = 0
AND mod(laboratory_academic_hours, 2) = 0
AND mod(practice_academic_hours, 2) = 0
) NOT VALID;
ALTER TABLE schedule_rules
VALIDATE CONSTRAINT chk_schedule_rules_academic_hours_even;
ALTER TABLE schedule_rule_slots ALTER TABLE schedule_rule_slots
ADD CONSTRAINT uq_schedule_rule_slots_exact_payload ADD CONSTRAINT uq_schedule_rule_slots_exact_payload
UNIQUE ( UNIQUE (
@@ -2089,6 +2098,7 @@ CREATE TABLE schedule_versions (
published_by BIGINT REFERENCES users(id), published_by BIGINT REFERENCES users(id),
published_at TIMESTAMPTZ, published_at TIMESTAMPTZ,
archived_at TIMESTAMPTZ, archived_at TIMESTAMPTZ,
CONSTRAINT uq_schedule_versions_id_semester UNIQUE (id, semester_id),
CONSTRAINT uq_schedule_versions_number UNIQUE (semester_id, version_number), CONSTRAINT uq_schedule_versions_number UNIQUE (semester_id, version_number),
CONSTRAINT chk_schedule_versions_number CHECK (version_number > 0), CONSTRAINT chk_schedule_versions_number CHECK (version_number > 0),
CONSTRAINT chk_schedule_versions_name CHECK (length(trim(name)) BETWEEN 1 AND 160), CONSTRAINT chk_schedule_versions_name CHECK (length(trim(name)) BETWEEN 1 AND 160),
@@ -2111,7 +2121,7 @@ ALTER TABLE schedule_rules
ALTER TABLE schedule_rules ALTER TABLE schedule_rules
ALTER COLUMN schedule_version_id SET NOT NULL, ALTER COLUMN schedule_version_id SET NOT NULL,
ADD CONSTRAINT fk_schedule_rules_version ADD CONSTRAINT fk_schedule_rules_version
FOREIGN KEY (schedule_version_id) REFERENCES schedule_versions(id) ON DELETE CASCADE; FOREIGN KEY (schedule_version_id, semester_id) REFERENCES schedule_versions(id, semester_id) ON DELETE CASCADE;
CREATE INDEX idx_schedule_rules_version CREATE INDEX idx_schedule_rules_version
ON schedule_rules(schedule_version_id, status); ON schedule_rules(schedule_version_id, status);
@@ -2251,3 +2261,136 @@ BEGIN
END $$; END $$;
CREATE TRIGGER zz_year_with_plan_context BEFORE UPDATE ON academic_years CREATE TRIGGER zz_year_with_plan_context BEFORE UPDATE ON academic_years
FOR EACH ROW EXECUTE FUNCTION protect_year_with_study_plan(); FOR EACH ROW EXECUTE FUNCTION protect_year_with_study_plan();
-- Стабильный код вида занятия не меняется при переименовании справочника.
CREATE FUNCTION prevent_lesson_type_code_change() RETURNS TRIGGER LANGUAGE plpgsql AS $$
BEGIN
IF NEW.code IS DISTINCT FROM OLD.code THEN
RAISE EXCEPTION 'Нельзя изменять стабильный код вида занятия'
USING ERRCODE = '23514', CONSTRAINT = 'chk_lesson_type_code_immutable';
END IF;
RETURN NEW;
END $$;
CREATE TRIGGER trg_lesson_type_code_immutable BEFORE UPDATE OF code ON lesson_types
FOR EACH ROW EXECUTE FUNCTION prevent_lesson_type_code_change();
COMMENT ON COLUMN lesson_types.code IS 'Стабильный технический код, независимый от отображаемого названия';
-- Индексы для обратного поиска по часто используемым внешним ключам.
CREATE INDEX idx_classroom_equipments_equipment ON classroom_equipments(equipment_id);
CREATE INDEX idx_teacher_subjects_subject ON teacher_subjects(subject_id);
CREATE INDEX idx_student_groups_profile_specialty ON student_groups(specialty_profile_id, specialty_id);
ALTER TABLE departments
ADD CONSTRAINT chk_departments_lifecycle_status CHECK (status IN ('ACTIVE', 'ARCHIVED')),
ADD CONSTRAINT chk_departments_lifecycle_period CHECK (
status = 'ARCHIVED' OR active_from IS NULL OR active_to IS NULL OR active_from <= active_to
),
ADD CONSTRAINT chk_departments_lifecycle_archive CHECK (
(status = 'ARCHIVED' AND archived_at IS NOT NULL)
OR (status <> 'ARCHIVED' AND archived_at IS NULL AND archived_by IS NULL AND archive_reason IS NULL)
),
ADD CONSTRAINT fk_departments_archived_by FOREIGN KEY (archived_by) REFERENCES users(id) ON DELETE SET NULL;
ALTER TABLE specialties
ADD CONSTRAINT chk_specialties_lifecycle_status CHECK (status IN ('ACTIVE', 'ARCHIVED')),
ADD CONSTRAINT chk_specialties_lifecycle_period CHECK (
status = 'ARCHIVED' OR active_from IS NULL OR active_to IS NULL OR active_from <= active_to
),
ADD CONSTRAINT chk_specialties_lifecycle_archive CHECK (
(status = 'ARCHIVED' AND archived_at IS NOT NULL)
OR (status <> 'ARCHIVED' AND archived_at IS NULL AND archived_by IS NULL AND archive_reason IS NULL)
),
ADD CONSTRAINT fk_specialties_archived_by FOREIGN KEY (archived_by) REFERENCES users(id) ON DELETE SET NULL;
ALTER TABLE specialty_profiles
ADD CONSTRAINT chk_specialty_profiles_lifecycle_status CHECK (status IN ('ACTIVE', 'ARCHIVED')),
ADD CONSTRAINT chk_specialty_profiles_lifecycle_period CHECK (
status = 'ARCHIVED' OR active_from IS NULL OR active_to IS NULL OR active_from <= active_to
),
ADD CONSTRAINT chk_specialty_profiles_lifecycle_archive CHECK (
(status = 'ARCHIVED' AND archived_at IS NOT NULL)
OR (status <> 'ARCHIVED' AND archived_at IS NULL AND archived_by IS NULL AND archive_reason IS NULL)
),
ADD CONSTRAINT fk_specialty_profiles_archived_by FOREIGN KEY (archived_by) REFERENCES users(id) ON DELETE SET NULL;
ALTER TABLE users
ADD CONSTRAINT chk_users_lifecycle_status CHECK (status IN ('ACTIVE', 'ARCHIVED')),
ADD CONSTRAINT chk_users_lifecycle_period CHECK (
status = 'ARCHIVED' OR active_from IS NULL OR active_to IS NULL OR active_from <= active_to
),
ADD CONSTRAINT chk_users_lifecycle_archive CHECK (
(status = 'ARCHIVED' AND archived_at IS NOT NULL)
OR (status <> 'ARCHIVED' AND archived_at IS NULL AND archived_by IS NULL AND archive_reason IS NULL)
),
ADD CONSTRAINT fk_users_archived_by FOREIGN KEY (archived_by) REFERENCES users(id) ON DELETE SET NULL;
ALTER TABLE education_forms
ADD CONSTRAINT chk_education_forms_lifecycle_status CHECK (status IN ('ACTIVE', 'ARCHIVED')),
ADD CONSTRAINT chk_education_forms_lifecycle_period CHECK (
status = 'ARCHIVED' OR active_from IS NULL OR active_to IS NULL OR active_from <= active_to
),
ADD CONSTRAINT chk_education_forms_lifecycle_archive CHECK (
(status = 'ARCHIVED' AND archived_at IS NOT NULL)
OR (status <> 'ARCHIVED' AND archived_at IS NULL AND archived_by IS NULL AND archive_reason IS NULL)
),
ADD CONSTRAINT fk_education_forms_archived_by FOREIGN KEY (archived_by) REFERENCES users(id) ON DELETE SET NULL;
ALTER TABLE student_groups
ADD CONSTRAINT chk_student_groups_lifecycle_status CHECK (status IN ('ACTIVE', 'ARCHIVED')),
ADD CONSTRAINT chk_student_groups_lifecycle_period CHECK (
status = 'ARCHIVED' OR active_from IS NULL OR active_to IS NULL OR active_from <= active_to
),
ADD CONSTRAINT chk_student_groups_lifecycle_archive CHECK (
(status = 'ARCHIVED' AND archived_at IS NOT NULL)
OR (status <> 'ARCHIVED' AND archived_at IS NULL AND archived_by IS NULL AND archive_reason IS NULL)
),
ADD CONSTRAINT fk_student_groups_archived_by FOREIGN KEY (archived_by) REFERENCES users(id) ON DELETE SET NULL;
ALTER TABLE subgroups
ADD CONSTRAINT chk_subgroups_lifecycle_status CHECK (status IN ('ACTIVE', 'ARCHIVED')),
ADD CONSTRAINT chk_subgroups_lifecycle_period CHECK (
status = 'ARCHIVED' OR active_from IS NULL OR active_to IS NULL OR active_from <= active_to
),
ADD CONSTRAINT chk_subgroups_lifecycle_archive CHECK (
(status = 'ARCHIVED' AND archived_at IS NOT NULL)
OR (status <> 'ARCHIVED' AND archived_at IS NULL AND archived_by IS NULL AND archive_reason IS NULL)
),
ADD CONSTRAINT fk_subgroups_archived_by FOREIGN KEY (archived_by) REFERENCES users(id) ON DELETE SET NULL;
ALTER TABLE subjects
ADD CONSTRAINT chk_subjects_lifecycle_status CHECK (status IN ('ACTIVE', 'ARCHIVED')),
ADD CONSTRAINT chk_subjects_lifecycle_period CHECK (
status = 'ARCHIVED' OR active_from IS NULL OR active_to IS NULL OR active_from <= active_to
),
ADD CONSTRAINT chk_subjects_lifecycle_archive CHECK (
(status = 'ARCHIVED' AND archived_at IS NOT NULL)
OR (status <> 'ARCHIVED' AND archived_at IS NULL AND archived_by IS NULL AND archive_reason IS NULL)
),
ADD CONSTRAINT fk_subjects_archived_by FOREIGN KEY (archived_by) REFERENCES users(id) ON DELETE SET NULL;
ALTER TABLE equipments
ADD CONSTRAINT chk_equipments_lifecycle_status CHECK (status IN ('ACTIVE', 'ARCHIVED')),
ADD CONSTRAINT chk_equipments_lifecycle_period CHECK (
status = 'ARCHIVED' OR active_from IS NULL OR active_to IS NULL OR active_from <= active_to
),
ADD CONSTRAINT chk_equipments_lifecycle_archive CHECK (
(status = 'ARCHIVED' AND archived_at IS NOT NULL)
OR (status <> 'ARCHIVED' AND archived_at IS NULL AND archived_by IS NULL AND archive_reason IS NULL)
),
ADD CONSTRAINT fk_equipments_archived_by FOREIGN KEY (archived_by) REFERENCES users(id) ON DELETE SET NULL;
ALTER TABLE classrooms
ADD CONSTRAINT chk_classrooms_lifecycle_status CHECK (status IN ('ACTIVE', 'ARCHIVED')),
ADD CONSTRAINT chk_classrooms_lifecycle_period CHECK (
status = 'ARCHIVED' OR active_from IS NULL OR active_to IS NULL OR active_from <= active_to
),
ADD CONSTRAINT chk_classrooms_lifecycle_archive CHECK (
(status = 'ARCHIVED' AND archived_at IS NOT NULL)
OR (status <> 'ARCHIVED' AND archived_at IS NULL AND archived_by IS NULL AND archive_reason IS NULL)
),
ADD CONSTRAINT fk_classrooms_archived_by FOREIGN KEY (archived_by) REFERENCES users(id) ON DELETE SET NULL;
ALTER TABLE users ADD CONSTRAINT chk_users_role
CHECK (role IN ('ADMIN', 'EDUCATION_OFFICE', 'DEPARTMENT', 'SCHEDULE_VIEWER', 'TEACHER', 'STUDENT'));
ALTER TABLE schedule_rules ADD CONSTRAINT chk_schedule_rules_status CHECK (status IN ('ACTIVE', 'ARCHIVED'));
@@ -530,10 +530,10 @@ FROM (
) generated_subject ) generated_subject
ON CONFLICT DO NOTHING; ON CONFLICT DO NOTHING;
INSERT INTO lesson_types (name, color_code) VALUES INSERT INTO lesson_types (name, code, color_code) VALUES
('Лекция', '#FF6B6B'), ('Лекция', 'LECTURE', '#FF6B6B'),
('Практика', '#4ECDC4'), ('Практика', 'PRACTICE', '#4ECDC4'),
('Лабораторная работа', '#45B7D1') ('Лабораторная работа', 'LABORATORY', '#45B7D1')
ON CONFLICT (name) DO NOTHING; ON CONFLICT (name) DO NOTHING;
-- Привязки преподавателей к дисциплинам кафедры переносятся ниже по файлу — -- Привязки преподавателей к дисциплинам кафедры переносятся ниже по файлу —
@@ -1027,32 +1027,18 @@ FROM (
AND version.status = 'PUBLISHED' AND version.status = 'PUBLISHED'
) prepared; ) prepared;
INSERT INTO schedule_rules ( INSERT INTO schedule_rules (id, subject_id, semester_id, schedule_version_id, version_group_id)
id, SELECT schedule_rule_id, subject_id, semester_id, schedule_version_id, schedule_rule_id
subject_id, FROM tmp_seed_legacy_rules;
semester_id,
schedule_version_id, INSERT INTO schedule_rule_loads (schedule_rule_id, lesson_type_code, academic_hours, start_week)
lecture_academic_hours, SELECT legacy_rule.schedule_rule_id, load.code, load.hours, load.week
laboratory_academic_hours, FROM tmp_seed_legacy_rules legacy_rule
practice_academic_hours, CROSS JOIN LATERAL (VALUES
lecture_start_week, ('LECTURE', legacy_rule.lecture_academic_hours, legacy_rule.lecture_start_week),
laboratory_start_week, ('LABORATORY', legacy_rule.laboratory_academic_hours, legacy_rule.laboratory_start_week),
practice_start_week, ('PRACTICE', legacy_rule.practice_academic_hours, legacy_rule.practice_start_week)
version_group_id ) AS load(code, hours, week);
)
SELECT
legacy_rule.schedule_rule_id,
legacy_rule.subject_id,
legacy_rule.semester_id,
legacy_rule.schedule_version_id,
legacy_rule.lecture_academic_hours,
legacy_rule.laboratory_academic_hours,
legacy_rule.practice_academic_hours,
legacy_rule.lecture_start_week,
legacy_rule.laboratory_start_week,
legacy_rule.practice_start_week,
legacy_rule.schedule_rule_id
FROM tmp_seed_legacy_rules legacy_rule;
INSERT INTO schedule_rule_groups (schedule_rule_id, group_id) INSERT INTO schedule_rule_groups (schedule_rule_id, group_id)
SELECT legacy_rule.schedule_rule_id, student_group.id SELECT legacy_rule.schedule_rule_id, student_group.id
@@ -1158,34 +1144,16 @@ WHERE student_group.name IN ('ИВТ-21-1', 'ИБ-41м')
WHERE generated_group.group_name = student_group.name WHERE generated_group.group_name = student_group.name
); );
INSERT INTO schedule_rules ( INSERT INTO schedule_rules (id, subject_id, semester_id, schedule_version_id, version_group_id, change_reason)
id, SELECT schedule_rule_id, subject_id, semester_id, schedule_version_id, schedule_rule_id,
subject_id,
semester_id,
schedule_version_id,
lecture_academic_hours,
laboratory_academic_hours,
practice_academic_hours,
lecture_start_week,
laboratory_start_week,
practice_start_week,
version_group_id,
change_reason
)
SELECT
bulk_rule.schedule_rule_id,
bulk_rule.subject_id,
bulk_rule.semester_id,
bulk_rule.schedule_version_id,
CASE WHEN bulk_rule.rule_number = 1 THEN 36 ELSE 0 END,
CASE WHEN bulk_rule.rule_number = 2 THEN 36 ELSE 0 END,
CASE WHEN bulk_rule.rule_number = 3 THEN 36 ELSE 0 END,
1,
1,
1,
bulk_rule.schedule_rule_id,
'Автоматически создано тестовым набором V2' 'Автоматически создано тестовым набором V2'
FROM tmp_seed_bulk_rules bulk_rule; FROM tmp_seed_bulk_rules;
INSERT INTO schedule_rule_loads (schedule_rule_id, lesson_type_code, academic_hours, start_week)
SELECT bulk_rule.schedule_rule_id, load.code,
CASE WHEN bulk_rule.rule_number = load.number THEN 36 ELSE 0 END, 1
FROM tmp_seed_bulk_rules bulk_rule
CROSS JOIN (VALUES ('LECTURE', 1), ('LABORATORY', 2), ('PRACTICE', 3)) AS load(code, number);
INSERT INTO schedule_rule_groups (schedule_rule_id, group_id) INSERT INTO schedule_rule_groups (schedule_rule_id, group_id)
SELECT bulk_rule.schedule_rule_id, bulk_rule.group_id SELECT bulk_rule.schedule_rule_id, bulk_rule.group_id
@@ -15,6 +15,26 @@ class GlobalExceptionHandlerDataIntegrityTest {
private final GlobalExceptionHandler handler = new GlobalExceptionHandler(); private final GlobalExceptionHandler handler = new GlobalExceptionHandler();
@Test
void compositeForeignKeyReturnsClearRussianValidationError() {
var response = handler.handleDataIntegrityViolation(
violation("violates constraint \"fk_schedule_rules_version\" Detail: secret-value", "23503"),
request("POST", "/api/admin/schedule-rules"));
assertThat(response.getStatusCode().value()).isEqualTo(400);
assertThat(response.getBody()).containsEntry("message", "Версия расписания относится к другому семестру");
assertNoTechnicalDetails(response.getBody());
}
@Test
void lifecycleConstraintReturnsClearRussianValidationError() {
var response = handler.handleDataIntegrityViolation(
violation("violates constraint \"chk_users_lifecycle_archive\" Detail: secret-value", "23514"),
request("PUT", "/api/users/1"));
assertThat(response.getStatusCode().value()).isEqualTo(400);
assertThat(response.getBody()).containsEntry("message", "Статус записи не согласован с данными архивирования");
assertNoTechnicalDetails(response.getBody());
}
@Test @Test
@DisplayName("известный CHECK возвращает русский 400 без JDBC details") @DisplayName("известный CHECK возвращает русский 400 без JDBC details")
void knownCheckConstraintReturnsSafeBadRequest() { void knownCheckConstraintReturnsSafeBadRequest() {
@@ -248,7 +248,7 @@ class TeacherSubjectControllerTest {
yearField.set(assignment, academicYear); yearField.set(assignment, academicYear);
LessonType lessonType = new LessonType(); LessonType lessonType = new LessonType();
lessonType.setId(assignment.getLessonTypeId()); lessonType.setId(assignment.getLessonTypeId());
lessonType.setLessonType("Практика"); lessonType.setLessonType("Практика"); lessonType.setCode("PRACTICE");
var lessonTypeField = TeacherSubject.class.getDeclaredField("lessonType"); var lessonTypeField = TeacherSubject.class.getDeclaredField("lessonType");
lessonTypeField.setAccessible(true); lessonTypeField.setAccessible(true);
lessonTypeField.set(assignment, lessonType); lessonTypeField.set(assignment, lessonType);
@@ -0,0 +1,237 @@
package com.magistr.app.migration;
import com.magistr.app.testing.TestContainerImages;
import org.flywaydb.core.Flyway;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.dao.DataIntegrityViolationException;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@Testcontainers
@DisplayName("Полная схема: согласованность FK, домены, нагрузка и конкурентные изменения")
class DatabaseDesignInvariantIntegrationTest {
@Container
static final PostgreSQLContainer<?> POSTGRES = new PostgreSQLContainer<>(TestContainerImages.POSTGRES);
static JdbcTemplate jdbc;
@BeforeAll
static void migrate() {
Flyway.configure().dataSource(POSTGRES.getJdbcUrl(), POSTGRES.getUsername(), POSTGRES.getPassword())
.locations("classpath:db/migration").load().migrate();
jdbc = new JdbcTemplate(new DriverManagerDataSource(POSTGRES.getJdbcUrl(), POSTGRES.getUsername(), POSTGRES.getPassword()));
}
@Test
void profileAndSpecialtyMustMatchOnInsertAndParentUpdate() {
assertThatThrownBy(() -> jdbc.update("""
INSERT INTO student_groups (name, group_size, education_form_id, department_id,
specialty_id, specialty_profile_id, year_start_study)
SELECT 'Несовместимый профиль', 20, g.education_form_id, g.department_id,
other.id, g.specialty_profile_id, g.year_start_study
FROM student_groups g JOIN specialties other ON other.id <> g.specialty_id LIMIT 1
"""))
.isInstanceOf(DataIntegrityViolationException.class).hasMessageContaining("fk_student_groups_profile_specialty");
assertThatThrownBy(() -> jdbc.update("""
INSERT INTO academic_calendars (title, academic_year_id, specialty_id, specialty_profile_id, study_form_id)
SELECT 'Несовместимый календарь', c.academic_year_id, other.id, c.specialty_profile_id, c.study_form_id
FROM academic_calendars c JOIN specialties other ON other.id <> c.specialty_id LIMIT 1
"""))
.isInstanceOf(DataIntegrityViolationException.class).hasMessageContaining("fk_academic_calendars_profile_specialty");
assertThatThrownBy(() -> jdbc.update("""
UPDATE specialty_profiles SET name='Профиль, перенесённый тестом', specialty_id = (SELECT id FROM specialties WHERE id <> specialty_profiles.specialty_id LIMIT 1)
WHERE id = (SELECT specialty_profile_id FROM student_groups LIMIT 1)
"""))
.isInstanceOf(DataIntegrityViolationException.class).hasMessageContaining("fk_");
}
@Test
void ruleSemesterMustMatchVersionAndReferencedVersionCannotChangeSemester() throws SQLException {
assertThatThrownBy(() -> jdbc.update("""
UPDATE schedule_rules SET semester_id = (SELECT id FROM semesters WHERE id <> schedule_rules.semester_id LIMIT 1)
WHERE id = (SELECT min(id) FROM schedule_rules)
"""))
.isInstanceOf(DataIntegrityViolationException.class).hasMessageContaining("fk_schedule_rules_version");
try (Connection c = POSTGRES.createConnection("")) {
c.setAutoCommit(false);
long version = scalar(c, """
INSERT INTO schedule_versions (semester_id, version_number, name, status)
SELECT semester_id, 900, 'Проверка семестра', 'DRAFT' FROM schedule_versions LIMIT 1 RETURNING id
""");
long rule = scalar(c, """
INSERT INTO schedule_rules (subject_id, semester_id, schedule_version_id)
SELECT (SELECT min(id) FROM subjects), semester_id, id FROM schedule_versions WHERE id = %d RETURNING id
""".formatted(version));
c.createStatement().executeUpdate("INSERT INTO schedule_rule_loads VALUES ("+rule+", 'LECTURE', 2, 1)");
assertThatThrownBy(() -> c.createStatement().executeUpdate("""
UPDATE schedule_versions SET semester_id=(SELECT id FROM semesters WHERE id <> schedule_versions.semester_id LIMIT 1)
WHERE id=%d
""".formatted(version)))
.isInstanceOf(SQLException.class).hasMessageContaining("fk_schedule_rules_version");
c.rollback();
}
}
@Test
void lifecycleRolesAndRequiredQuantityAreEnforcedInDatabase() {
assertThatThrownBy(() -> jdbc.update("UPDATE users SET role='TEACHRE' WHERE id=(SELECT min(id) FROM users)"))
.isInstanceOf(DataIntegrityViolationException.class).hasMessageContaining("chk_users_role");
assertThatThrownBy(() -> jdbc.update("UPDATE classrooms SET status='ACTVE' WHERE id=(SELECT min(id) FROM classrooms)"))
.isInstanceOf(DataIntegrityViolationException.class).hasMessageContaining("lifecycle_status");
assertThatThrownBy(() -> jdbc.update("UPDATE departments SET status='ARCHIVED' WHERE id=(SELECT min(id) FROM departments)"))
.isInstanceOf(DataIntegrityViolationException.class).hasMessageContaining("lifecycle_archive");
assertThatThrownBy(() -> jdbc.update("UPDATE subjects SET archived_at=CURRENT_TIMESTAMP WHERE id=(SELECT min(id) FROM subjects)"))
.isInstanceOf(DataIntegrityViolationException.class).hasMessageContaining("lifecycle_archive");
assertThatThrownBy(() -> jdbc.update("UPDATE equipments SET active_from='2026-12-01', active_to='2026-01-01' WHERE id=(SELECT min(id) FROM equipments)"))
.isInstanceOf(DataIntegrityViolationException.class).hasMessageContaining("lifecycle_period");
assertThatThrownBy(() -> jdbc.update("UPDATE classroom_equipments SET quantity=NULL"))
.isInstanceOf(DataIntegrityViolationException.class).hasMessageContaining("quantity");
}
@Test
void archiveActorIsARealUserAndDeletionPreservesArchive() throws SQLException {
try (Connection c = POSTGRES.createConnection("")) {
c.setAutoCommit(false);
long actor = scalar(c, """
INSERT INTO users (username, password, role, full_name, job_title, department_id)
VALUES ('archive_test_actor', 'хеш', 'ADMIN', 'Тестовый архиватор', 'Администратор',
(SELECT min(id) FROM departments)) RETURNING id
""");
c.createStatement().executeUpdate("UPDATE equipments SET status='ARCHIVED', archived_at=CURRENT_TIMESTAMP, archived_by="+actor+" WHERE id=(SELECT min(id) FROM equipments)");
c.createStatement().executeUpdate("DELETE FROM users WHERE id="+actor);
assertThat(scalar(c,"SELECT count(*) FROM equipments WHERE status='ARCHIVED' AND archived_at IS NOT NULL AND archived_by IS NULL")).isPositive();
c.rollback();
}
assertThatThrownBy(() -> jdbc.update("UPDATE equipments SET status='ARCHIVED', archived_at=CURRENT_TIMESTAMP, archived_by=9223372036854775807 WHERE id=(SELECT min(id) FROM equipments)"))
.isInstanceOf(DataIntegrityViolationException.class).hasMessageContaining("archived_by");
}
@Test
void renameDoesNotChangeLaboratorySemanticsAndCodeIsImmutable() throws SQLException {
try (Connection c = POSTGRES.createConnection("")) {
c.setAutoCommit(false);
c.createStatement().executeUpdate("UPDATE lesson_types SET name='Занятие с оборудованием' WHERE code='LABORATORY'");
long slot = scalar(c,"SELECT s.id FROM schedule_rule_slots s JOIN lesson_types t ON t.id=s.lesson_type_id WHERE t.code='LABORATORY' LIMIT 1");
c.createStatement().executeUpdate("DELETE FROM schedule_rule_slot_subgroups WHERE schedule_rule_slot_id="+slot);
int inserted = c.createStatement().executeUpdate("""
INSERT INTO schedule_rule_slot_subgroups (schedule_rule_slot_id, subgroup_id)
SELECT %d, sg.id FROM subgroups sg JOIN schedule_rule_groups rg ON rg.group_id=sg.group_id
JOIN schedule_rule_slots s ON s.schedule_rule_id=rg.schedule_rule_id WHERE s.id=%d LIMIT 1
""".formatted(slot,slot));
assertThat(inserted).isOne();
c.rollback();
}
assertThatThrownBy(() -> jdbc.update("UPDATE lesson_types SET code='RENAMED' WHERE code='LABORATORY'"))
.isInstanceOf(DataIntegrityViolationException.class).hasMessageContaining("Нельзя изменять стабильный код");
}
@Test
void noRepeatedHourColumnsOrDuplicateTimeSlotIndexRemain() {
assertThat(jdbc.queryForObject("""
SELECT count(*) FROM information_schema.columns WHERE table_schema='public' AND table_name='schedule_rules'
AND column_name IN ('lecture_academic_hours','laboratory_academic_hours','practice_academic_hours',
'lecture_start_week','laboratory_start_week','practice_start_week')
""",Integer.class)).isZero();
assertThat(jdbc.queryForObject("SELECT count(*) FROM pg_indexes WHERE indexname='idx_time_slots_scope'",Integer.class)).isZero();
assertThat(jdbc.queryForObject("SELECT count(*) FROM pg_indexes WHERE indexname IN ('idx_classroom_equipments_equipment','idx_teacher_subjects_subject')",Integer.class)).isEqualTo(2);
assertThat(jdbc.queryForObject("SELECT count(*) FROM schedule_rules r WHERE NOT EXISTS (SELECT 1 FROM schedule_rule_loads l WHERE l.schedule_rule_id=r.id AND l.academic_hours>0)",Integer.class)).isZero();
}
@Test
void deferredLoadConstraintChecksParentDeletionAndBothSidesOfLoadMove() throws SQLException {
try (Connection c = POSTGRES.createConnection("")) {
c.setAutoCommit(false);
long empty = insertRule(c);
assertThatThrownBy(() -> c.createStatement().execute("SET CONSTRAINTS ALL IMMEDIATE"))
.isInstanceOf(SQLException.class).hasMessageContaining("положительными часами");
c.rollback();
long first = insertRule(c), second = insertRule(c);
c.createStatement().executeUpdate("INSERT INTO schedule_rule_loads VALUES ("+first+", 'LECTURE', 2, 1), ("+second+", 'PRACTICE', 2, 1)");
c.createStatement().execute("SET CONSTRAINTS ALL IMMEDIATE");
c.createStatement().execute("SET CONSTRAINTS ALL DEFERRED");
c.createStatement().executeUpdate("UPDATE schedule_rule_loads SET schedule_rule_id="+second+" WHERE schedule_rule_id="+first);
assertThatThrownBy(() -> c.createStatement().execute("SET CONSTRAINTS ALL IMMEDIATE"))
.isInstanceOf(SQLException.class).hasMessageContaining("положительными часами");
c.rollback();
long deleted = insertRule(c);
c.createStatement().executeUpdate("INSERT INTO schedule_rule_loads VALUES ("+deleted+", 'LECTURE', 2, 1)");
c.createStatement().executeUpdate("DELETE FROM schedule_rules WHERE id="+deleted);
c.createStatement().execute("SET CONSTRAINTS ALL IMMEDIATE");
assertThat(scalar(c,"SELECT count(*) FROM schedule_rule_loads WHERE schedule_rule_id="+deleted)).isZero();
c.rollback();
}
}
@ParameterizedTest
@ValueSource(ints = {Connection.TRANSACTION_READ_COMMITTED, Connection.TRANSACTION_REPEATABLE_READ})
void concurrentChangesCannotRemoveLastPositiveLoad(int isolation) throws Exception {
long rule;
try (Connection c = POSTGRES.createConnection("")) {
c.setAutoCommit(false);
rule = insertRule(c);
c.createStatement().executeUpdate("INSERT INTO schedule_rule_loads VALUES ("+rule+", 'LECTURE', 2, 1), ("+rule+", 'PRACTICE', 2, 1)");
c.commit();
}
var executor = Executors.newFixedThreadPool(2);
var start = new CountDownLatch(1);
var ready = new CountDownLatch(2);
try {
var first = executor.submit(() -> zeroLoad(rule,"LECTURE",ready,start,isolation));
var second = executor.submit(() -> zeroLoad(rule,"PRACTICE",ready,start,isolation));
assertThat(ready.await(5, TimeUnit.SECONDS)).isTrue();
start.countDown();
assertThat(java.util.List.of(first.get(15,TimeUnit.SECONDS),second.get(15,TimeUnit.SECONDS)))
.containsExactlyInAnyOrder("OK", isolation == Connection.TRANSACTION_READ_COMMITTED ? "23514" : "40001");
assertThat(jdbc.queryForObject("SELECT sum(academic_hours) FROM schedule_rule_loads WHERE schedule_rule_id=?",Integer.class,rule)).isEqualTo(2);
} finally {
start.countDown();
executor.shutdownNow();
jdbc.update("DELETE FROM schedule_rules WHERE id=?",rule);
}
}
private String zeroLoad(long rule, String code, CountDownLatch ready, CountDownLatch start, int isolation) throws Exception {
try (Connection c = POSTGRES.createConnection("")) {
c.setAutoCommit(false);
c.setTransactionIsolation(isolation);
assertThat(scalar(c,"SELECT sum(academic_hours) FROM schedule_rule_loads WHERE schedule_rule_id="+rule)).isEqualTo(4);
ready.countDown();
start.await(5,TimeUnit.SECONDS);
try (var st=c.prepareStatement("UPDATE schedule_rule_loads SET academic_hours=0 WHERE schedule_rule_id=? AND lesson_type_code=?")) {
st.setLong(1,rule);st.setString(2,code);st.executeUpdate();c.commit();return "OK";
} catch (SQLException exception) {
c.rollback();return exception.getSQLState();
}
}
}
private long insertRule(Connection c) throws SQLException {
return scalar(c,"""
INSERT INTO schedule_rules (subject_id, semester_id, schedule_version_id)
SELECT subject_id, semester_id, schedule_version_id FROM schedule_rules ORDER BY id LIMIT 1 RETURNING id
""");
}
private long scalar(Connection c,String sql) throws SQLException {
try (var statement=c.createStatement();var result=statement.executeQuery(sql)) {
assertThat(result.next()).isTrue();return result.getLong(1);
}
}
}
@@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.catchThrowable;
@DisplayName("Инварианты правил расписания базовой схемы") @DisplayName("Инварианты правил расписания базовой схемы")
class ScheduleRuleHoursMigrationIntegrationTest { class ScheduleRuleHoursMigrationIntegrationTest {
private static final String HOURS_CONSTRAINT = "chk_schedule_rules_academic_hours_even"; private static final String HOURS_CONSTRAINT = "chk_schedule_rule_loads_hours_even";
private static final String EXACT_SLOT_CONSTRAINT = "uq_schedule_rule_slots_exact_payload"; private static final String EXACT_SLOT_CONSTRAINT = "uq_schedule_rule_slots_exact_payload";
@Container @Container
@@ -62,7 +62,7 @@ class ScheduleRuleHoursMigrationIntegrationTest {
""" """
SELECT count(*) SELECT count(*)
FROM pg_constraint FROM pg_constraint
WHERE conrelid = 'schedule_rules'::regclass WHERE conrelid = 'schedule_rule_loads'::regclass
AND conname = ? AND conname = ?
AND convalidated AND convalidated
""", """,
@@ -102,27 +102,37 @@ class ScheduleRuleHoursMigrationIntegrationTest {
int laboratoryHours, int laboratoryHours,
int practiceHours int practiceHours
) throws SQLException { ) throws SQLException {
connection.setAutoCommit(false);
try {
long ruleId;
try (PreparedStatement statement = connection.prepareStatement(""" try (PreparedStatement statement = connection.prepareStatement("""
INSERT INTO schedule_rules ( INSERT INTO schedule_rules (subject_id, semester_id, schedule_version_id)
subject_id, VALUES (?, ?, ?) RETURNING id
semester_id,
schedule_version_id,
lecture_academic_hours,
laboratory_academic_hours,
practice_academic_hours,
lecture_start_week,
laboratory_start_week,
practice_start_week
) VALUES (?, ?, ?, ?, ?, ?, 1, 1, 1)
""")) { """)) {
statement.setLong(1, seedIds.subjectId()); statement.setLong(1, seedIds.subjectId());
statement.setLong(2, seedIds.semesterId()); statement.setLong(2, seedIds.semesterId());
statement.setLong(3, seedIds.scheduleVersionId()); statement.setLong(3, seedIds.scheduleVersionId());
statement.setInt(4, lectureHours); try (ResultSet result = statement.executeQuery()) {
statement.setInt(5, laboratoryHours); result.next();
statement.setInt(6, practiceHours); ruleId = result.getLong(1);
}
}
try (PreparedStatement statement = connection.prepareStatement("""
INSERT INTO schedule_rule_loads (schedule_rule_id, lesson_type_code, academic_hours, start_week)
VALUES (?, 'LECTURE', ?, 1), (?, 'LABORATORY', ?, 1), (?, 'PRACTICE', ?, 1)
""")) {
statement.setLong(1, ruleId); statement.setInt(2, lectureHours);
statement.setLong(3, ruleId); statement.setInt(4, laboratoryHours);
statement.setLong(5, ruleId); statement.setInt(6, practiceHours);
statement.executeUpdate(); statement.executeUpdate();
} }
connection.commit();
} catch (SQLException exception) {
connection.rollback();
throw exception;
} finally {
connection.setAutoCommit(true);
}
} }
private void assertOddHoursRejected( private void assertOddHoursRejected(
@@ -0,0 +1,117 @@
package com.magistr.app.migration;
import com.magistr.app.model.ScheduleRule;
import com.magistr.app.repository.ScheduleRuleRepository;
import com.magistr.app.testing.TestContainerImages;
import jakarta.persistence.EntityManagerFactory;
import org.flywaydb.core.Flyway;
import org.hibernate.SessionFactory;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.springframework.data.jpa.repository.support.JpaRepositoryFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import java.util.List;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@Testcontainers
class ScheduleRuleLoadPersistenceIntegrationTest {
@Container
static final PostgreSQLContainer<?> POSTGRES = new PostgreSQLContainer<>(TestContainerImages.POSTGRES);
static EntityManagerFactory factory;
static JdbcTemplate jdbc;
@BeforeAll
static void initialize() {
var datasource = new DriverManagerDataSource(POSTGRES.getJdbcUrl(),POSTGRES.getUsername(),POSTGRES.getPassword());
Flyway.configure().dataSource(datasource).locations("classpath:db/migration").load().migrate();
jdbc = new JdbcTemplate(datasource);
var bean = new LocalContainerEntityManagerFactoryBean();
bean.setDataSource(datasource);
bean.setPackagesToScan("com.magistr.app.model");
bean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
bean.setJpaPropertyMap(Map.of("hibernate.hbm2ddl.auto","validate","hibernate.generate_statistics","true"));
bean.afterPropertiesSet();
factory = bean.getObject();
}
@AfterAll
static void close() {
if (factory != null) factory.close();
}
@Test
void hibernatePersistsNormalizedLoadsAndRepositoryFetchesThemWithoutExtraQueries() {
long sourceId = jdbc.queryForObject("SELECT min(id) FROM schedule_rules",Long.class);
Long copyId;
try (var em = factory.createEntityManager()) {
em.getTransaction().begin();
var source = em.find(ScheduleRule.class,sourceId);
var copy = new ScheduleRule();
copy.setSubject(source.getSubject());
copy.setSemester(source.getSemester());
copy.setScheduleVersion(source.getScheduleVersion());
copy.setLectureAcademicHours(36);
copy.setLaboratoryAcademicHours(18);
copy.setPracticeAcademicHours(0);
copy.setLectureStartWeek(2);
copy.setLaboratoryStartWeek(3);
em.persist(copy);
em.getTransaction().commit();
copyId = copy.getId();
}
try (var em = factory.createEntityManager()) {
em.getTransaction().begin();
var repository = new JpaRepositoryFactory(em).getRepository(ScheduleRuleRepository.class);
var rules = repository.findPageWithDetails(List.of(sourceId,copyId));
assertThat(rules).hasSize(2);
var statistics = factory.unwrap(SessionFactory.class).getStatistics();
long reads = statistics.getPrepareStatementCount();
for (var rule:rules) {
assertThat(factory.getPersistenceUnitUtil().isLoaded(rule,"loads")).isTrue();
rule.getLectureAcademicHours();
rule.getLaboratoryAcademicHours();
rule.getPracticeAcademicHours();
rule.getLectureStartWeek();
rule.getLaboratoryStartWeek();
}
assertThat(statistics.getPrepareStatementCount()).isEqualTo(reads);
var copy = rules.stream().filter(r->r.getId().equals(copyId)).findFirst().orElseThrow();
assertThat(copy.getLectureAcademicHours()).isEqualTo(36);
assertThat(copy.getLaboratoryAcademicHours()).isEqualTo(18);
assertThat(copy.getPracticeAcademicHours()).isZero();
assertThat(copy.getLectureStartWeek()).isEqualTo(2);
assertThat(copy.getLaboratoryStartWeek()).isEqualTo(3);
em.getTransaction().commit();
}
assertThat(jdbc.queryForObject("SELECT sum(academic_hours) FROM schedule_rule_loads WHERE schedule_rule_id=?",Integer.class,copyId)).isEqualTo(54);
assertThat(jdbc.queryForObject("SELECT start_week FROM schedule_rule_loads WHERE schedule_rule_id=? AND lesson_type_code='LABORATORY'",Integer.class,copyId)).isEqualTo(3);
jdbc.update("DELETE FROM schedule_rules WHERE id=?",copyId);
assertThat(jdbc.queryForObject("SELECT count(*) FROM schedule_rule_loads WHERE schedule_rule_id=?",Integer.class,copyId)).isZero();
}
@Test
void zeroingAllHoursThroughHibernateRollsBackAtCommit() {
long id = jdbc.queryForObject("SELECT min(id) FROM schedule_rules",Long.class);
int before = jdbc.queryForObject("SELECT sum(academic_hours) FROM schedule_rule_loads WHERE schedule_rule_id=?",Integer.class,id);
try (var em = factory.createEntityManager()) {
em.getTransaction().begin();
var rule = em.find(ScheduleRule.class,id);
rule.setLectureAcademicHours(0);
rule.setLaboratoryAcademicHours(0);
rule.setPracticeAcademicHours(0);
assertThatThrownBy(()->em.getTransaction().commit()).hasStackTraceContaining("положительными часами");
}
assertThat(jdbc.queryForObject("SELECT sum(academic_hours) FROM schedule_rule_loads WHERE schedule_rule_id=?",Integer.class,id)).isEqualTo(before);
}
}
@@ -51,4 +51,16 @@ class LifecycleEntityTest {
assertThat(subject.getArchivedAt()).isEqualTo(archiveMoment); assertThat(subject.getArchivedAt()).isEqualTo(archiveMoment);
assertThat(subject.getArchiveReason()).isEqualTo("Тестовая архивация"); assertThat(subject.getArchiveReason()).isEqualTo("Тестовая архивация");
} }
@Test
void restoreClearsArchiveActorAndOtherArchiveMetadata() {
Subject subject = new Subject();
subject.archive("Архивирование");
subject.setArchivedBy(42L);
subject.restore();
assertThat(subject.getArchivedBy()).isNull();
assertThat(subject.getArchivedAt()).isNull();
assertThat(subject.getArchiveReason()).isNull();
assertThat(subject.getStatus()).isEqualTo(LifecycleEntity.STATUS_ACTIVE);
}
} }
@@ -1,39 +1,36 @@
package com.magistr.app.model; package com.magistr.app.model;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.assertThatThrownBy;
class ScheduleLessonCategoryTest { class ScheduleLessonCategoryTest {
@Test @Test
void mapsCanonicalLessonTypes() { void categoryUsesCodeEvenAfterArbitraryRename() {
assertThat(ScheduleLessonCategory.fromLessonType(lessonType("Лекция"))) for (ScheduleLessonCategory category : ScheduleLessonCategory.values()) {
.isEqualTo(ScheduleLessonCategory.LECTURE); LessonType type = new LessonType();
assertThat(ScheduleLessonCategory.fromLessonType(lessonType("Практика"))) type.setCode(category.name());
.isEqualTo(ScheduleLessonCategory.PRACTICE); type.setLessonType("Произвольное название без указания вида нагрузки");
assertThat(ScheduleLessonCategory.fromLessonType(lessonType("Лабораторная работа"))) assertThat(ScheduleLessonCategory.fromLessonType(type)).isEqualTo(category);
.isEqualTo(ScheduleLessonCategory.LABORATORY); }
} }
@Test @Test
void rejectsAmbiguousLessonType() { void displayNameCannotOverrideCode() {
assertThatThrownBy(() -> ScheduleLessonCategory.fromLessonType(lessonType("Лабораторно-практическое занятие"))) LessonType type = new LessonType();
.isInstanceOf(IllegalArgumentException.class) type.setCode("PRACTICE");
.hasMessageContaining("неоднозначен"); type.setLessonType("Лабораторная работа");
assertThat(ScheduleLessonCategory.fromLessonType(type)).isEqualTo(ScheduleLessonCategory.PRACTICE);
} }
@Test @Test
void rejectsUnsupportedLessonType() { void missingOrUnsupportedCodesAreRejectedWithoutNameFallback() {
assertThatThrownBy(() -> ScheduleLessonCategory.fromLessonType(lessonType("Консультация"))) LessonType type = new LessonType();
.isInstanceOf(IllegalArgumentException.class) type.setLessonType("Лекция");
.hasMessageContaining("должен быть лекцией"); assertThatThrownBy(() -> ScheduleLessonCategory.fromLessonType(type))
} .isInstanceOf(IllegalArgumentException.class).hasMessageContaining("стабильный код");
type.setCode("CONSULTATION");
private LessonType lessonType(String name) { assertThatThrownBy(() -> ScheduleLessonCategory.fromLessonType(type))
LessonType lessonType = new LessonType(); .isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Неподдерживаемый код");
lessonType.setLessonType(name);
return lessonType;
} }
} }
@@ -282,7 +282,7 @@ class ScheduleGenerationQueryCountTest {
LessonType lessonType = new LessonType(); LessonType lessonType = new LessonType();
lessonType.setId(80L); lessonType.setId(80L);
lessonType.setLessonType("Лекция"); lessonType.setLessonType("Лекция"); lessonType.setCode("LECTURE");
ScheduleRuleSlot slot = new ScheduleRuleSlot(); ScheduleRuleSlot slot = new ScheduleRuleSlot();
slot.setId(90L); slot.setId(90L);
@@ -709,6 +709,12 @@ class ScheduleRuleServiceTest {
LessonType type = new LessonType(); LessonType type = new LessonType();
type.setId(id); type.setId(id);
type.setLessonType(name); type.setLessonType(name);
type.setCode(switch (name) {
case "Лекция" -> "LECTURE";
case "Практика" -> "PRACTICE";
case "Лабораторная работа" -> "LABORATORY";
default -> "UNSUPPORTED";
});
return type; return type;
} }
@@ -77,7 +77,7 @@ class StudyPlanServiceTest {
ScheduleRule rule=new ScheduleRule(); StudentGroup group=new StudentGroup(); group.setId(10L); group.setName("Группа"); ScheduleRule rule=new ScheduleRule(); StudentGroup group=new StudentGroup(); group.setId(10L); group.setName("Группа");
Semester semester=new Semester(); semester.setId(6L); Subject subject=new Subject(); subject.setId(2L); Semester semester=new Semester(); semester.setId(6L); Subject subject=new Subject(); subject.setId(2L);
rule.setSemester(semester); rule.setSubject(subject); rule.setGroups(Set.of(group)); rule.setLectureAcademicHours(36); rule.setSemester(semester); rule.setSubject(subject); rule.setGroups(Set.of(group)); rule.setLectureAcademicHours(36);
LessonType type=new LessonType(); type.setLessonType("Лекция"); User wrong=new User(); wrong.setId(8L); LessonType type=new LessonType(); type.setLessonType("Лекция"); type.setCode("LECTURE"); User wrong=new User(); wrong.setId(8L);
ScheduleRuleSlot slot=new ScheduleRuleSlot(); slot.setLessonType(type); slot.setTeacher(wrong); ScheduleRuleSlot slot=new ScheduleRuleSlot(); slot.setLessonType(type); slot.setTeacher(wrong);
when(plans.assignedPlan(10L,6L)).thenReturn(Optional.of(1L)); when(plans.assignedPlan(10L,6L)).thenReturn(Optional.of(1L));
when(plans.loads(1L,2L)).thenReturn(List.of(new Load(LECTURE,36,false,7L,"Преподаватель профиля",36))); when(plans.loads(1L,2L)).thenReturn(List.of(new Load(LECTURE,36,false,7L,"Преподаватель профиля",36)));
+7 -4
View File
@@ -845,14 +845,17 @@ ID существующих слотов сохраняются; удалени
### `GET /api/lesson-types` ### `GET /api/lesson-types`
Справочник типов занятий для конструктора правил расписания. Справочник типов занятий для конструктора правил расписания. `code` — стабильный технический код;
переименование `name` не меняет категорию нагрузки и разрешение подгрупп. Код после создания
не изменяется. Поля `*AcademicHours` и `*StartWeek` API правил сохранены; в БД нагрузка
хранится строками `schedule_rule_loads`.
**Ответ:** **Ответ:**
```json ```json
[ [
{ "id": 1, "name": "Лекция" }, { "id": 1, "name": "Лекция", "code": "LECTURE" },
{ "id": 2, "name": "Практика" }, { "id": 2, "name": "Практика", "code": "PRACTICE" },
{ "id": 3, "name": "Лабораторная работа" } { "id": 3, "name": "Лабораторная работа", "code": "LABORATORY" }
] ]
``` ```
+4 -1
View File
@@ -155,7 +155,8 @@ Bearer-токен проверяется на backend. Frontend-скрытие
| `academic_calendar_subjects` | Дисциплины графика по номерам учебных семестров | | `academic_calendar_subjects` | Дисциплины графика по номерам учебных семестров |
| `student_group_calendar_assignments` | Назначение конкретного графика группе на учебный год | | `student_group_calendar_assignments` | Назначение конкретного графика группе на учебный год |
| `time_slots` | Настраиваемая сетка пар для тенанта | | `time_slots` | Настраиваемая сетка пар для тенанта |
| `schedule_rules` | Лимиты часов и недели начала по лекциям, лабораторным и практикам | | `schedule_rules` | Версия, дисциплина, семестр и период действия правила |
| `schedule_rule_loads` | Лимит часов и начальная неделя по стабильному коду вида занятия |
| `schedule_rule_groups` | Группы правила, включая потоковые лекции | | `schedule_rule_groups` | Группы правила, включая потоковые лекции |
| `schedule_rule_slots` | День, чётность, слот, преподаватель, аудитория, тип и формат занятия | | `schedule_rule_slots` | День, чётность, слот, преподаватель, аудитория, тип и формат занятия |
| `schedule_rule_slot_subgroups` | Подгруппы лабораторного слота | | `schedule_rule_slot_subgroups` | Подгруппы лабораторного слота |
@@ -242,6 +243,8 @@ constraint. При чтении API разворачивает периоды о
или 100 группами получает полный агрегат, а защита или 100 группами получает полный агрегат, а защита
широкого `/api/schedule/search` остаётся прежней. широкого `/api/schedule/search` остаётся прежней.
Вид нагрузки определяется по неизменяемому `lesson_types.code` (`LECTURE`, `LABORATORY`, `PRACTICE`), а не по отображаемому названию. Поэтому переименование занятия не меняет расчёт часов и допустимость подгрупп.
Лабораторные работы могут делиться на подгруппы через `schedule_rule_slot_subgroups`. Если подгруппы выбраны, занятие выводится только для родительских групп этих подгрупп, а лимит лабораторных часов списывается отдельно по каждой подгруппе. Если лабораторная проводится у нескольких групп одновременно, один слот может содержать разные подгруппы разных групп. Лекции и практики не делятся на подгруппы. Лабораторные работы могут делиться на подгруппы через `schedule_rule_slot_subgroups`. Если подгруппы выбраны, занятие выводится только для родительских групп этих подгрупп, а лимит лабораторных часов списывается отдельно по каждой подгруппе. Если лабораторная проводится у нескольких групп одновременно, один слот может содержать разные подгруппы разных групп. Лекции и практики не делятся на подгруппы.
Обычные пары генерируются только на коде `Т` (`allow_schedule = true`). Экзамены, каникулы, практики, нерабочие дни, праздники `*` и дни вне учебного года `=` считаются пропуском: занятие не переносится и не списывает академические часы. Если у группы нет назначения графика на учебный год, `GET /api/schedule` возвращает пустой список для этой группы без ошибки. Обычные пары генерируются только на коде `Т` (`allow_schedule = true`). Экзамены, каникулы, практики, нерабочие дни, праздники `*` и дни вне учебного года `=` считаются пропуском: занятие не переносится и не списывает академические часы. Если у группы нет назначения графика на учебный год, `GET /api/schedule` возвращает пустой список для этой группы без ошибки.
+104 -16
View File
@@ -14,18 +14,36 @@
## ER-диаграмма ## ER-диаграмма
Подробная [визуальная схема базы данных](diagrams/database-schema.html) содержит
46 таблиц, 387 столбцов и 105 внешних ключей из `V1__init.sql`, включая изменения
через `ALTER TABLE`. Все таблицы, все столбцы и все 105 внешних ключей показаны на одном
большом SVG-полотне, включая служебные FK и самоссылки версий. Доступны масштаб,
перетаскивание, поиск таблиц и подсветка связанных объектов. При выборе таблицы
боковая панель показывает её входящие и исходящие связи с `ON DELETE`,
ограничения и явные индексы. Оформление использует светлую палитру «Магистр».
Откройте HTML-файл в браузере. Обновление схемы после изменения baseline:
```bash
python3 docs/diagrams/generate_database_schema.py
```
Генератор читает только SQL-файл и не подключается к работающей базе данных.
```mermaid ```mermaid
erDiagram erDiagram
departments { departments {
BIGSERIAL id PK BIGSERIAL id PK
VARCHAR name VARCHAR name
BIGINT code UK BIGINT code UK
BIGINT archived_by FK
} }
specialties { specialties {
BIGSERIAL id PK BIGSERIAL id PK
VARCHAR name VARCHAR name
VARCHAR specialty_code UK VARCHAR specialty_code UK
BIGINT archived_by FK
} }
specialty_profiles { specialty_profiles {
@@ -33,6 +51,7 @@ erDiagram
BIGINT specialty_id FK BIGINT specialty_id FK
VARCHAR name VARCHAR name
TEXT description TEXT description
BIGINT archived_by FK
} }
users { users {
@@ -49,6 +68,7 @@ erDiagram
TIMESTAMPTZ archived_at TIMESTAMPTZ archived_at
TIMESTAMPTZ created_at TIMESTAMPTZ created_at
TIMESTAMPTZ updated_at TIMESTAMPTZ updated_at
BIGINT archived_by FK
} }
auth_refresh_tokens { auth_refresh_tokens {
@@ -89,6 +109,7 @@ erDiagram
VARCHAR name UK VARCHAR name UK
TEXT description TEXT description
TIMESTAMPTZ created_at TIMESTAMPTZ created_at
BIGINT archived_by FK
} }
student_groups { student_groups {
@@ -101,6 +122,7 @@ erDiagram
BIGINT specialty_profile_id FK BIGINT specialty_profile_id FK
BIGINT year_start_study BIGINT year_start_study
TIMESTAMPTZ created_at TIMESTAMPTZ created_at
BIGINT archived_by FK
} }
subgroups { subgroups {
@@ -108,6 +130,7 @@ erDiagram
BIGINT group_id FK BIGINT group_id FK
VARCHAR name VARCHAR name
INT student_capacity INT student_capacity
BIGINT archived_by FK
} }
subjects { subjects {
@@ -117,11 +140,13 @@ erDiagram
BIGINT department_id FK BIGINT department_id FK
TEXT description TEXT description
TIMESTAMPTZ created_at TIMESTAMPTZ created_at
BIGINT archived_by FK
} }
lesson_types { lesson_types {
BIGSERIAL id PK BIGSERIAL id PK
VARCHAR name UK VARCHAR name UK
VARCHAR code UK
VARCHAR color_code VARCHAR color_code
INT duration_minutes INT duration_minutes
} }
@@ -131,6 +156,7 @@ erDiagram
VARCHAR name UK VARCHAR name UK
TEXT description TEXT description
VARCHAR inventory_number VARCHAR inventory_number
BIGINT archived_by FK
} }
classrooms { classrooms {
@@ -146,6 +172,7 @@ erDiagram
TIMESTAMPTZ archived_at TIMESTAMPTZ archived_at
TEXT description TEXT description
TIMESTAMPTZ created_at TIMESTAMPTZ created_at
BIGINT archived_by FK
} }
classroom_equipments { classroom_equipments {
@@ -311,6 +338,7 @@ erDiagram
schedule_rules { schedule_rules {
BIGSERIAL id PK BIGSERIAL id PK
BIGINT load_revision
BIGINT subject_id FK BIGINT subject_id FK
BIGINT semester_id FK BIGINT semester_id FK
BIGINT schedule_version_id FK BIGINT schedule_version_id FK
@@ -318,12 +346,13 @@ erDiagram
VARCHAR status VARCHAR status
DATE valid_from DATE valid_from
DATE valid_to DATE valid_to
INT lecture_academic_hours }
INT laboratory_academic_hours
INT practice_academic_hours schedule_rule_loads {
INT lecture_start_week BIGINT schedule_rule_id PK,FK
INT laboratory_start_week VARCHAR lesson_type_code PK,FK
INT practice_start_week INT academic_hours
INT start_week
} }
schedule_rule_groups { schedule_rule_groups {
@@ -515,6 +544,8 @@ erDiagram
academic_calendars ||--o{ academic_calendar_subjects : "calendar_id" academic_calendars ||--o{ academic_calendar_subjects : "calendar_id"
academic_calendars ||--o{ student_group_calendar_assignments : "calendar_id" academic_calendars ||--o{ student_group_calendar_assignments : "calendar_id"
academic_calendar_activity_types ||--o{ academic_calendar_periods : "activity_type_id" academic_calendar_activity_types ||--o{ academic_calendar_periods : "activity_type_id"
schedule_rules ||--o{ schedule_rule_loads : "schedule_rule_id"
lesson_types ||--o{ schedule_rule_loads : "code → lesson_type_code"
schedule_rules ||--o{ schedule_rule_groups : "schedule_rule_id" schedule_rules ||--o{ schedule_rule_groups : "schedule_rule_id"
schedule_rules ||--o{ schedule_rule_slots : "schedule_rule_id" schedule_rules ||--o{ schedule_rule_slots : "schedule_rule_id"
schedule_rule_slots ||--o{ schedule_rule_slot_subgroups : "schedule_rule_slot_id" schedule_rule_slots ||--o{ schedule_rule_slot_subgroups : "schedule_rule_slot_id"
@@ -542,6 +573,16 @@ erDiagram
time_slots ||--o{ schedule_rule_slots : "time_slot_id" time_slots ||--o{ schedule_rule_slots : "time_slot_id"
subgroups ||--o{ schedule_rule_slot_subgroups : "subgroup_id" subgroups ||--o{ schedule_rule_slot_subgroups : "subgroup_id"
users ||--o{ schedule_rule_slots : "teacher_id" users ||--o{ schedule_rule_slots : "teacher_id"
users ||--o{ departments : "archived_by"
users ||--o{ specialties : "archived_by"
users ||--o{ specialty_profiles : "archived_by"
users ||--o{ users : "archived_by"
users ||--o{ education_forms : "archived_by"
users ||--o{ student_groups : "archived_by"
users ||--o{ subgroups : "archived_by"
users ||--o{ subjects : "archived_by"
users ||--o{ equipments : "archived_by"
users ||--o{ classrooms : "archived_by"
``` ```
--- ---
@@ -650,6 +691,31 @@ backend создаёт строку через `INSERT ... ON CONFLICT DO NOTHIN
пользователя. Записи старше настраиваемого срока (по умолчанию 90 дней), а также неактивные пользователя. Записи старше настраиваемого срока (по умолчанию 90 дней), а также неактивные
счётчики удаляются tenant-aware задачей ограниченными `SKIP LOCKED` пачками. счётчики удаляются tenant-aware задачей ограниченными `SKIP LOCKED` пачками.
### Гарантии согласованности справочников
У `student_groups` и `academic_calendars` пара `(specialty_profile_id, specialty_id)`
ссылается на соответствующую пару `specialty_profiles`: существование двух независимых
ID больше не позволяет связать профиль с чужим направлением. Поля направления сохранены
как контролируемое дублирование; составной FK защищает также изменения родителя.
В таблицах жизненного цикла (`departments`, `specialties`, `specialty_profiles`, `users`,
`education_forms`, `student_groups`, `subgroups`, `subjects`, `equipments`, `classrooms`):
- допускаются только `ACTIVE` и `ARCHIVED`;
- для активной записи начало действия не позже окончания, если указаны обе даты;
- `ARCHIVED` требует `archived_at`, а `ACTIVE` запрещает поля архивирования;
- `archived_by` — необязательный FK на `users.id` с `ON DELETE SET NULL`: время и причина
архива сохраняются после удаления учётной записи архиватора;
- архивирование до запланированного начала может оставить пустой период действия:
такая запись не является активной ни на одну дату; восстановление очищает `active_to`
и все сведения об архивировании, включая `archived_by`.
Роли `users.role` ограничены значениями Java `Role`. У `classroom_equipments.quantity`
есть и `NOT NULL`, и проверка положительности. Обратный поиск оборудования и закреплений
дисциплин поддержан индексами `idx_classroom_equipments_equipment` и
`idx_teacher_subjects_subject`. Для порядка звонков оставлен один уникальный индекс
`uq_time_slots_scope_order`; дублирующий `idx_time_slots_scope` удалён.
### Учебный процесс ### Учебный процесс
#### `education_forms` — Формы обучения #### `education_forms` — Формы обучения
@@ -750,7 +816,8 @@ CHECK-ограничения требуют положительные `student_
| Колонка | Тип | Описание | | Колонка | Тип | Описание |
|---------|-----|----------| |---------|-----|----------|
| `id` | BIGSERIAL PK | ID | | `id` | BIGSERIAL PK | ID |
| `name` | VARCHAR(50) UNIQUE | Название типа | | `name` | VARCHAR(50) UNIQUE | Отображаемое название типа |
| `code` | VARCHAR(30) NOT NULL UNIQUE | Неизменяемый технический код: `LECTURE`, `LABORATORY`, `PRACTICE` |
| `color_code` | VARCHAR(7) | HEX-цвет для UI (напр. `#FF6B6B`) | | `color_code` | VARCHAR(7) | HEX-цвет для UI (напр. `#FF6B6B`) |
| `duration_minutes` | INT | Длительность (по умолчанию 90) | | `duration_minutes` | INT | Длительность (по умолчанию 90) |
@@ -1011,15 +1078,10 @@ V1 создаёт GiST exclusion constraint `ex_academic_years_no_overlap` дл
| Колонка | Тип | Описание | | Колонка | Тип | Описание |
|---------|-----|----------| |---------|-----|----------|
| `id` | BIGSERIAL PK | ID | | `id` | BIGSERIAL PK | ID |
| `load_revision` | BIGINT NOT NULL DEFAULT 0 | Техническая ревизия изменений нагрузки |
| `subject_id` | BIGINT FK → subjects | Дисциплина | | `subject_id` | BIGINT FK → subjects | Дисциплина |
| `semester_id` | BIGINT FK → semesters | Семестр | | `semester_id` | BIGINT FK → semesters | Семестр |
| `schedule_version_id` | BIGINT FK → schedule_versions (CASCADE) | Версия расписания | | `schedule_version_id` | BIGINT FK → schedule_versions (CASCADE) | Версия расписания |
| `lecture_academic_hours` | INT | Лимит академических часов лекций |
| `laboratory_academic_hours` | INT | Лимит академических часов лабораторных работ |
| `practice_academic_hours` | INT | Лимит академических часов практик |
| `lecture_start_week` | INT | Неделя семестра, с которой начинаются лекции |
| `laboratory_start_week` | INT | Неделя семестра, с которой начинаются лабораторные |
| `practice_start_week` | INT | Неделя семестра, с которой начинаются практики |
| `status` | VARCHAR(20) | `ACTIVE` или `ARCHIVED` | | `status` | VARCHAR(20) | `ACTIVE` или `ARCHIVED` |
| `valid_from` | DATE | Начало действия версии правила | | `valid_from` | DATE | Начало действия версии правила |
| `valid_to` | DATE | Окончание действия версии правила | | `valid_to` | DATE | Окончание действия версии правила |
@@ -1028,9 +1090,29 @@ V1 создаёт GiST exclusion constraint `ex_academic_years_no_overlap` дл
`ScheduleRule` использует собственные поля жизненного цикла `status`, `valid_from` и `valid_to`: архивированное правило или правило вне периода действия не участвует в генерации расписания. В отличие от справочников на `LifecycleEntity`, таблица не содержит `active_from`/`active_to`, поэтому состояние правила проверяется по `valid_*`. Публичная генерация дополнительно требует статус `PUBLISHED` у связанной версии. Уникальный индекс по `schedule_version_id + version_group_id` не позволяет дважды скопировать одну логическую линию правила в одну версию. `ScheduleRule` использует собственные поля жизненного цикла `status`, `valid_from` и `valid_to`: архивированное правило или правило вне периода действия не участвует в генерации расписания. В отличие от справочников на `LifecycleEntity`, таблица не содержит `active_from`/`active_to`, поэтому состояние правила проверяется по `valid_*`. Публичная генерация дополнительно требует статус `PUBLISHED` у связанной версии. Уникальный индекс по `schedule_version_id + version_group_id` не позволяет дважды скопировать одну логическую линию правила в одну версию.
Базовая схема V1 требует, чтобы лимиты лекций, лабораторных и практик были кратны двум. Лимиты часов и начальные недели находятся в `schedule_rule_loads`, а не в повторяющихся
Неотрицательность каждого лимита и положительная сумма уже закреплены ограничениями V1; столбцах правила. API сохраняет поля `lectureAcademicHours`, `laboratoryAcademicHours`,
нули допустимы только как лимиты неиспользуемых типов занятия. `practiceAcademicHours` и соответствующие `*StartWeek`: модель получает их из строк нагрузки.
Составной FK `(schedule_version_id, semester_id)` гарантирует совпадение семестра правила
и версии, в том числе при попытке изменить родительскую версию.
#### `schedule_rule_loads` — Нагрузка правила по видам занятий
| Колонка | Тип | Описание |
|---------|-----|----------|
| `schedule_rule_id` | BIGINT PK, FK → schedule_rules (CASCADE) | Правило расписания |
| `lesson_type_code` | VARCHAR(30) PK, FK → lesson_types.code | Стабильный код вида занятия |
| `academic_hours` | INT NOT NULL CHECK (>= 0, чётное) | Лимит академических часов |
| `start_week` | INT NOT NULL CHECK (> 0) | Начальная неделя семестра, по умолчанию 1 |
Отсутствующая строка читается моделью как ноль часов и первая неделя. На конец транзакции
каждое существующее правило должно иметь хотя бы одну строку с положительными часами.
Отложенные constraint-триггеры проверяют и создание правила, и изменения, удаление или
перенос нагрузки между правилами. Перед изменением нагрузки увеличивается техническая `schedule_rules.load_revision`:
запись строки родителя сериализует изменения разных видов нагрузки. Две транзакции не
могут совместно обнулить последние положительные часы как при `READ COMMITTED`, так
и при `REPEATABLE READ` (второй режим может отклонить конкурента с SQLSTATE `40001`).
Репозитории загружают коллекцию нагрузки вместе с правилами через `join fetch`.
#### `schedule_rule_groups` — Группы правила #### `schedule_rule_groups` — Группы правила
| Колонка | Тип | Описание | | Колонка | Тип | Описание |
@@ -1224,6 +1306,12 @@ CHECK фиксирует допустимую форму каждого типа
`V1` не выполнится; поэтому текущую консолидированную V1 применяют только к полностью `V1` не выполнится; поэтому текущую консолидированную V1 применяют только к полностью
пустой tenant-схеме пустой tenant-схеме
Текущая модель нагрузки требует `schedule_rule_loads` и `lesson_types.code`;
новую сборку backend нельзя запускать поверх старой структуры с шестью столбцами
часов/недель в `schedule_rules`. Изменение контрольных сумм через `repair` не создаёт
новую структуру и не заменяет согласованное пересоздание tenant-БД. Рабочие базы
автоматически не сбрасываются.
### Текущие миграции ### Текущие миграции
| Файл | Описание | | Файл | Описание |
+7
View File
@@ -760,3 +760,10 @@ telemetryPromise = import('/vendor/otel.js');
часы и профильных преподавателей. Изменения плана не переписывают существующие часы и профильных преподавателей. Изменения плана не переписывают существующие
правила и опубликованные версии автоматически: при последующем сохранении правила правила и опубликованные версии автоматически: при последующем сохранении правила
сервер проверяет его соответствие актуальному плану. сервер проверяет его соответствие актуальному плану.
### Стабильные коды видов занятий
Конструктор расписания определяет вид нагрузки по полю `code` ответа
`GET /api/lesson-types`: `LECTURE`, `LABORATORY`, `PRACTICE`. `name` используется
для отображения; переименование не влияет на сортировку категорий, проверки лимитов
и разрешение подгрупп. Определение категории по подстроке названия не применяется.
+197
View File
@@ -0,0 +1,197 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Магистр — полная схема базы данных</title>
<style>
*{box-sizing:border-box}html,body{margin:0;height:100%;overflow:hidden}body{background:#f8fafc;color:#0f172a;font:13px/1.4 Inter,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;display:grid;grid-template-rows:auto minmax(0,1fr) 36px;grid-template-columns:minmax(0,1fr);height:100dvh}.sans{font-family:Inter,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif}.mono,code{font-family:'Cascadia Mono','SFMono-Regular',Consolas,'Noto Sans Mono',monospace}button,input,select{font:inherit}button,select,input{border:1px solid #cbd5e1;background:#fdfefe;color:#0f172a;border-radius:5px;height:34px}button{cursor:pointer;padding:0 12px;white-space:nowrap}button:hover{background:#eeedff;border-color:#4f46e5}button:focus-visible,input:focus-visible,select:focus-visible,.entity:focus-visible{outline:2px solid #4f46e5;outline-offset:2px}.toolbar{display:flex;align-items:center;gap:20px;min-height:76px;padding:12px 20px;border-bottom:1px solid #cbd5e1;background:#fdfefe}.brand{display:flex;align-items:center;gap:12px;flex-shrink:0}.logo{width:32px;height:32px;background:#4f46e5;color:#f8fafc;border-radius:5px;display:grid;place-items:center;font-size:20px;font-weight:600}.brand h1{font-size:15px;letter-spacing:-.02em;margin:0;font-weight:600}.brand p{font-size:11px;color:#475569;margin:3px 0 0}.controls{display:flex;align-items:center;gap:6px;margin-left:auto}.zoom-value{min-width:50px;text-align:center;font-variant-numeric:tabular-nums;color:#475569}.search{width:250px;padding:0 10px}.workspace{height:auto;min-height:0;min-width:0;width:100%;position:relative;display:flex}.viewport{flex:1;min-width:0;overflow:auto;cursor:grab;overscroll-behavior:contain;background-color:#e8edf3;touch-action:pan-x pan-y}.viewport.dragging{cursor:grabbing;user-select:none}.canvas{position:relative;margin:20px;line-height:0;width:max-content;min-width:0}.canvas>svg{display:block;background:#f8fafc}.table-box{fill:#f8fafc;stroke:#475569;stroke-width:1.25}.entity{cursor:pointer;outline:none}.entity.selected .table-box,.entity:focus-visible .table-box{stroke:#4f46e5;stroke-width:3}.wire-under{fill:none;stroke:#f8fafc;stroke-width:5;stroke-linejoin:round}.wire{fill:none;stroke:#64748b;stroke-width:1.65;stroke-linejoin:round;pointer-events:none}.wire-hit{fill:none;stroke:transparent;stroke-width:10;cursor:crosshair}.relation.active .wire{stroke:#4f46e5;stroke-width:3}.relation.active .wire-under{stroke-width:7}.schema-focused .relation:not(.active){opacity:.16}.schema-focused .entity:not(.related):not(.selected){opacity:.38}.relation:hover .wire{stroke:#4f46e5;stroke-width:3}.inspector{width:350px;flex-shrink:0;background:#fdfefe;border-left:1px solid #cbd5e1;overflow:auto;padding:20px;line-height:1.6}.inspector[hidden]{display:none}.inspector h2{font-size:14px;overflow-wrap:anywhere;margin:0 0 4px}.inspector h3{font-size:12px;color:#475569;text-transform:uppercase;letter-spacing:.06em;margin:24px 0 12px}.inspector p{font-size:12px;color:#475569;margin:6px 0}.inspector .close{float:right;height:28px;margin:-6px -6px 8px 8px;padding:0 8px}.link-list{list-style:none;padding:0;margin:0}.link-list li{padding:10px 0;border-top:1px solid #e2e8f0}.link-list button{height:auto;text-align:left;border:0;border-radius:0;padding:0;background:transparent;color:#4338ca;display:block;overflow-wrap:anywhere;white-space:normal;font-size:11px}.link-list small{color:#475569;display:block;font-size:10px;padding-top:3px}.constraint{font-size:10px;overflow-wrap:anywhere;white-space:normal;color:#475569;display:block;padding:8px 0;border-top:1px solid #e2e8f0}.status{height:36px;display:flex;align-items:center;gap:16px;padding:0 20px;background:#fdfefe;border-top:1px solid #cbd5e1;font-size:11px;color:#475569}.status>span:first-child{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.source{white-space:nowrap}.hint{position:absolute;bottom:20px;left:20px;pointer-events:none;padding:8px 12px;background:#fdfefe;border:1px solid #cbd5e1;border-radius:5px;color:#475569;font-size:11px;max-width:calc(100% - 40px)}.help{margin-left:6px}.fallback{padding:16px;background:#eeedff;color:#0f172a;font-size:13px}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0)}
@media(max-width:1100px){.toolbar{gap:10px;flex-wrap:wrap}.controls{flex-wrap:wrap}.brand{margin-right:auto}.search{width:210px}.workspace{height:auto}.toolbar{min-height:116px}.help{display:none}}@media(max-width:640px){.toolbar{padding:10px 12px;gap:8px}.brand{width:100%}.controls{margin-left:0;width:100%;gap:4px}.search{flex:1;min-width:130px;width:auto}.controls button{padding:0 8px}.controls .reset{display:none}.brand h1{font-size:14px}.workspace{height:auto}.inspector{position:absolute;right:0;top:0;bottom:0;width:min(350px,88vw)}.source{display:none}.status{padding:0 12px}.hint{left:12px;bottom:12px;font-size:10px}}
@media print{html,body{overflow:visible;height:auto}.toolbar,.inspector,.status,.hint{display:none}.workspace,.viewport{height:auto;overflow:visible;display:block}.canvas{margin:0;width:100%!important;height:auto!important}.canvas>svg{width:100%!important;height:auto!important}.schema-focused .relation,.schema-focused .entity{opacity:1!important}}
</style>
</head>
<body>
<header class="toolbar">
<div class="brand"><span class="logo" aria-hidden="true">М</span><div><h1>Магистр · Полная схема БД</h1><p>46 таблиц · 387 столбцов · 105 внешних ключей</p></div></div>
<div class="controls">
<label for="search" class="sr-only">Найти таблицу</label><input id="search" class="search" type="search" list="table-names" placeholder="Найти таблицу…" autocomplete="off"><datalist id="table-names"></datalist>
<button id="zoom-out" aria-label="Уменьшить масштаб">−</button><output id="zoom-value" class="zoom-value" aria-live="polite">100%</output><button id="zoom-in" aria-label="Увеличить масштаб">+</button><button id="actual">100%</button><button id="fit">Вся схема</button><button id="clear" class="reset">Сбросить выделение</button>
</div>
</header>
<div class="workspace">
<main id="viewport" class="viewport" aria-label="Полотно полной схемы базы данных"><div id="canvas" class="canvas"><svg id="schema" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4864 3884" width="4864" height="3884" role="img" aria-labelledby="database-schema-title database-schema-desc"><title id="database-schema-title">Полная схема базы данных «Магистр»</title><desc id="database-schema-desc">Все 46 таблиц, 387 столбцов и 105 внешних ключей одной tenant-БД на едином полотне.</desc><defs><marker id="fk-arrow" viewBox="0 0 8 8" refX="7" refY="4" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M 1 1 L 7 4 L 1 7" fill="none" stroke="context-stroke" stroke-width="1.4"/></marker></defs><rect width="4864" height="3884" fill="#f8fafc"/><text x="64" y="44" font-size="20" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">МАГИСТР / ПОЛНАЯ ФИЗИЧЕСКАЯ СХЕМА</text><text x="64" y="72" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">46 таблиц · 387 столбцов · 105 FK · одна tenant-БД · источник: V1__init.sql</text><text x="64" y="124" font-size="14" fill="#475569" font-weight="600" text-anchor="start" class="sans">ГРУППЫ И НАПРАВЛЕНИЯ</text><text x="768" y="124" font-size="14" fill="#475569" font-weight="600" text-anchor="start" class="sans">УЧЕБНЫЙ КАЛЕНДАРЬ</text><text x="1472" y="124" font-size="14" fill="#475569" font-weight="600" text-anchor="start" class="sans">ПЛАНЫ И ВРЕМЯ</text><text x="2176" y="124" font-size="14" fill="#475569" font-weight="600" text-anchor="start" class="sans">ПОЛЬЗОВАТЕЛИ И КАФЕДРЫ</text><text x="2880" y="124" font-size="14" fill="#475569" font-weight="600" text-anchor="start" class="sans">РАСПИСАНИЕ</text><text x="3584" y="124" font-size="14" fill="#475569" font-weight="600" text-anchor="start" class="sans">ДИСЦИПЛИНЫ И РЕСУРСЫ</text><text x="4288" y="124" font-size="14" fill="#475569" font-weight="600" text-anchor="start" class="sans">ИЗМЕНЕНИЯ И ЗАЯВКИ</text><g id="relations"><g id="fk-1-0" class="relation" data-source="specialty_profiles" data-target="specialties" data-number="1"><title>FK01: specialty_profiles.(specialty_id) → specialties.(id) · ON DELETE CASCADE</title><path class="wire-under" d="M 576 724 L 592 724 Q 600 724 600 716 L 600 236 Q 600 228 592 228 L 576 228"/><path class="wire" d="M 576 724 L 592 724 Q 600 724 600 716 L 600 236 Q 600 228 592 228 L 576 228" marker-end="url(#fk-arrow)"/><path class="wire-hit" d="M 576 724 L 592 724 Q 600 724 600 716 L 600 236 Q 600 228 592 228 L 576 228"/></g><g id="fk-2-0" class="relation" data-source="users" data-target="departments" data-number="2"><title>FK02: users.(department_id) → departments.(id) · ON DELETE NO ACTION</title><path class="wire-under" d="M 2688 2042 L 2752 2042 Q 2760 2042 2760 2034 L 2760 1064 Q 2760 1056 2752 1056 L 2688 1056"/><path class="wire" d="M 2688 2042 L 2752 2042 Q 2760 2042 2760 2034 L 2760 1064 Q 2760 1056 2752 1056 L 2688 1056" marker-end="url(#fk-arrow)"/><path class="wire-hit" d="M 2688 2042 L 2752 2042 Q 2760 2042 2760 2034 L 2760 1064 Q 2760 1056 2752 1056 L 2688 1056"/></g><g id="fk-3-0" class="relation" data-source="auth_refresh_tokens" data-target="users" data-number="3"><title>FK03: auth_refresh_tokens.(user_id) → users.(id) · ON DELETE CASCADE</title><path class="wire-under" d="M 2688 2498 L 2740 2498 Q 2748 2498 2748 2490 L 2748 1524 Q 2748 1516 2740 1516 L 2688 1516"/><path class="wire" d="M 2688 2498 L 2740 2498 Q 2748 2498 2748 2490 L 2748 1524 Q 2748 1516 2740 1516 L 2688 1516" marker-end="url(#fk-arrow)"/><path class="wire-hit" d="M 2688 2498 L 2740 2498 Q 2748 2498 2748 2490 L 2748 1524 Q 2748 1516 2740 1516 L 2688 1516"/></g><g id="fk-4-0" class="relation" data-source="teacher_department_assignments" data-target="users" data-number="4"><title>FK04: teacher_department_assignments.(teacher_id) → users.(id) · ON DELETE NO ACTION</title><path class="wire-under" d="M 2688 2954 L 2788 2954 Q 2796 2954 2796 2946 L 2796 1536 Q 2796 1528 2788 1528 L 2688 1528"/><path class="wire" d="M 2688 2954 L 2788 2954 Q 2796 2954 2796 2946 L 2796 1536 Q 2796 1528 2788 1528 L 2688 1528" marker-end="url(#fk-arrow)"/><path class="wire-hit" d="M 2688 2954 L 2788 2954 Q 2796 2954 2796 2946 L 2796 1536 Q 2796 1528 2788 1528 L 2688 1528"/></g><g id="fk-5-0" class="relation" data-source="teacher_department_assignments" data-target="departments" data-number="5"><title>FK05: teacher_department_assignments.(department_id) → departments.(id) · ON DELETE NO ACTION</title><path class="wire-under" d="M 2688 2982 L 2836 2982 Q 2844 2982 2844 2974 L 2844 1076 Q 2844 1068 2836 1068 L 2688 1068"/><path class="wire" d="M 2688 2982 L 2836 2982 Q 2844 2982 2844 2974 LLine truncated
9 столбцов · 1 исходящих и 5 входящих FK</title><rect class="table-box" x="2176" y="980" width="512" height="348" rx="6"/><path d="M 2182 980 H 2682 Q 2688 980 2688 986 V 1044 H 2176 V 986 Q 2176 980 2182 980 Z" fill="#e8edf3"/><text x="2192" y="1006" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">departments</text><text x="2192" y="1028" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Кафедры</text><g data-column="id" data-row-top="1044" data-row-height="60"><title>id BIGSERIAL UNIQUE PRIMARY KEY NOT NULL</title><rect x="2177" y="1044" width="510" height="60" fill="#eef2f7"/><text x="2188" y="1078.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK·UQ</text><text x="2258" y="1078.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="2644" y="1078.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="2670" y="1078.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="name" data-row-top="1104" data-row-height="28"><title>name VARCHAR(255) NOT NULL</title><rect x="2177" y="1104" width="510" height="28" fill="#f8fafc"/><text x="2258" y="1122.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">name</text><text x="2644" y="1122.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(255)</text><text x="2670" y="1122.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="code" data-row-top="1132" data-row-height="28"><title>code BIGINT UNIQUE NOT NULL</title><rect x="2177" y="1132" width="510" height="28" fill="#eef2f7"/><text x="2188" y="1150.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">UQ</text><text x="2258" y="1150.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">code</text><text x="2644" y="1150.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="2670" y="1150.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="status" data-row-top="1160" data-row-height="28"><title>status VARCHAR(20) NOT NULL DEFAULT &#x27;ACTIVE&#x27;</title><rect x="2177" y="1160" width="510" height="28" fill="#f8fafc"/><text x="2258" y="1178.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">status</text><text x="2644" y="1178.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(20)</text><text x="2670" y="1178.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="active_from" data-row-top="1188" data-row-height="28"><title>active_from DATE</title><rect x="2177" y="1188" width="510" height="28" fill="#eef2f7"/><text x="2258" y="1206.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">active_from</text><text x="2644" y="1206.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="2670" y="1206.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="active_to" data-row-top="1216" data-row-height="28"><title>active_to DATE</title><rect x="2177" y="1216" width="510" height="28" fill="#f8fafc"/><text x="2258" y="1234.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">active_to</text><text x="2644" y="1234.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="2670" y="1234.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="archived_at" data-row-top="1244" data-row-height="28"><title>archived_at TIMESTAMPTZ</title><rect x="2177" y="1244" width="510" height="28" fill="#eef2f7"/><text x="2258" y="1262.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">archived_at</text><text x="2644" y="1262.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">timestamptz</text><text x="2670" y="1262.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="archived_by" data-row-top="1272" data-row-height="28"><title>archived_by BIGINT</title><rect x="2177" y="1272" width="510" height="28" fill="#f8fafc"/><text x="2188" y="1290.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK96</text><text x="2258" y="1290.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">archived_by</text><text x="2644" y="1290.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="Line truncated
9 столбцов · 1 исходящих и 3 входящих FK</title><rect class="table-box" x="64" y="152" width="512" height="336" rx="6"/><path d="M 70 152 H 570 Q 576 152 576 158 V 216 H 64 V 158 Q 64 152 70 152 Z" fill="#e8edf3"/><text x="80" y="178" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">specialties</text><text x="80" y="200" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Направления подготовки</text><g data-column="id" data-row-top="216" data-row-height="48"><title>id BIGSERIAL PRIMARY KEY</title><rect x="65" y="216" width="510" height="48" fill="#eef2f7"/><text x="76" y="244.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="146" y="244.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="532" y="244.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="558" y="244.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="name" data-row-top="264" data-row-height="28"><title>name VARCHAR(255) NOT NULL</title><rect x="65" y="264" width="510" height="28" fill="#f8fafc"/><text x="146" y="282.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">name</text><text x="532" y="282.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(255)</text><text x="558" y="282.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="specialty_code" data-row-top="292" data-row-height="28"><title>specialty_code VARCHAR(255) UNIQUE NOT NULL</title><rect x="65" y="292" width="510" height="28" fill="#eef2f7"/><text x="76" y="310.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">UQ</text><text x="146" y="310.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">specialty_code</text><text x="532" y="310.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(255)</text><text x="558" y="310.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="status" data-row-top="320" data-row-height="28"><title>status VARCHAR(20) NOT NULL DEFAULT &#x27;ACTIVE&#x27;</title><rect x="65" y="320" width="510" height="28" fill="#f8fafc"/><text x="146" y="338.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">status</text><text x="532" y="338.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(20)</text><text x="558" y="338.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="active_from" data-row-top="348" data-row-height="28"><title>active_from DATE</title><rect x="65" y="348" width="510" height="28" fill="#eef2f7"/><text x="146" y="366.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">active_from</text><text x="532" y="366.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="558" y="366.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="active_to" data-row-top="376" data-row-height="28"><title>active_to DATE</title><rect x="65" y="376" width="510" height="28" fill="#f8fafc"/><text x="146" y="394.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">active_to</text><text x="532" y="394.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="558" y="394.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="archived_at" data-row-top="404" data-row-height="28"><title>archived_at TIMESTAMPTZ</title><rect x="65" y="404" width="510" height="28" fill="#eef2f7"/><text x="146" y="422.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">archived_at</text><text x="532" y="422.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">timestamptz</text><text x="558" y="422.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="archived_by" data-row-top="432" data-row-height="28"><title>archived_by BIGINT</title><rect x="65" y="432" width="510" height="28" fill="#f8fafc"/><text x="76" y="450.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK97</text><text x="146" y="450.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">archived_by</text><text x="532" y="450.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="558" y="450.0" font-size="10Line truncated
11 столбцов · 2 исходящих и 3 входящих FK</title><rect class="table-box" x="64" y="600" width="512" height="412" rx="6"/><path d="M 70 600 H 570 Q 576 600 576 606 V 664 H 64 V 606 Q 64 600 70 600 Z" fill="#e8edf3"/><text x="80" y="626" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">specialty_profiles</text><text x="80" y="648" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Профили подготовки</text><g data-column="id" data-row-top="664" data-row-height="48"><title>id BIGSERIAL PRIMARY KEY</title><rect x="65" y="664" width="510" height="48" fill="#eef2f7"/><text x="76" y="692.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="146" y="692.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="532" y="692.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="558" y="692.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="specialty_id" data-row-top="712" data-row-height="48"><title>specialty_id BIGINT NOT NULL REFERENCES specialties(id) ON DELETE CASCADE</title><rect x="65" y="712" width="510" height="48" fill="#f8fafc"/><text x="76" y="740.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK01</text><text x="146" y="740.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">specialty_id</text><text x="532" y="740.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="558" y="740.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="name" data-row-top="760" data-row-height="28"><title>name VARCHAR(500) NOT NULL</title><rect x="65" y="760" width="510" height="28" fill="#eef2f7"/><text x="146" y="778.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">name</text><text x="532" y="778.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(500)</text><text x="558" y="778.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="description" data-row-top="788" data-row-height="28"><title>description TEXT</title><rect x="65" y="788" width="510" height="28" fill="#f8fafc"/><text x="146" y="806.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">description</text><text x="532" y="806.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">text</text><text x="558" y="806.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="created_at" data-row-top="816" data-row-height="28"><title>created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP</title><rect x="65" y="816" width="510" height="28" fill="#eef2f7"/><text x="146" y="834.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">created_at</text><text x="532" y="834.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">timestamptz</text><text x="558" y="834.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="status" data-row-top="844" data-row-height="28"><title>status VARCHAR(20) NOT NULL DEFAULT &#x27;ACTIVE&#x27;</title><rect x="65" y="844" width="510" height="28" fill="#f8fafc"/><text x="146" y="862.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">status</text><text x="532" y="862.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(20)</text><text x="558" y="862.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="active_from" data-row-top="872" data-row-height="28"><title>active_from DATE</title><rect x="65" y="872" width="510" height="28" fill="#eef2f7"/><text x="146" y="890.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">active_from</text><text x="532" y="890.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="558" y="890.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="active_to" data-row-top="900" data-row-height="28"><title>active_to DATE</title><rect x="65" y="900" width="510" height="28" fill="#f8fafc"/><text x="146" y="918.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">active_to</text><text x="532" y="918.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="558" y="918.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○<Line truncated
15 столбцов · 2 исходящих и 37 входящих FK</title><rect class="table-box" x="2176" y="1440" width="512" height="840" rx="6"/><path d="M 2182 1440 H 2682 Q 2688 1440 2688 1446 V 1504 H 2176 V 1446 Q 2176 1440 2182 1440 Z" fill="#eeedff"/><text x="2192" y="1466" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">users</text><text x="2192" y="1488" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Пользователи</text><g data-column="id" data-row-top="1504" data-row-height="384"><title>id BIGSERIAL PRIMARY KEY</title><rect x="2177" y="1504" width="510" height="384" fill="#eef2f7"/><text x="2188" y="1700.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="2258" y="1700.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="2644" y="1700.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="2670" y="1700.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="username" data-row-top="1888" data-row-height="28"><title>username VARCHAR(50) UNIQUE NOT NULL</title><rect x="2177" y="1888" width="510" height="28" fill="#f8fafc"/><text x="2188" y="1906.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">UQ</text><text x="2258" y="1906.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">username</text><text x="2644" y="1906.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(50)</text><text x="2670" y="1906.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="password" data-row-top="1916" data-row-height="28"><title>password VARCHAR(255) NOT NULL</title><rect x="2177" y="1916" width="510" height="28" fill="#eef2f7"/><text x="2258" y="1934.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">password</text><text x="2644" y="1934.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(255)</text><text x="2670" y="1934.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="role" data-row-top="1944" data-row-height="28"><title>role VARCHAR(30) NOT NULL DEFAULT &#x27;STUDENT&#x27;</title><rect x="2177" y="1944" width="510" height="28" fill="#f8fafc"/><text x="2258" y="1962.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">role</text><text x="2644" y="1962.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(30)</text><text x="2670" y="1962.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="full_name" data-row-top="1972" data-row-height="28"><title>full_name VARCHAR(255) NOT NULL</title><rect x="2177" y="1972" width="510" height="28" fill="#eef2f7"/><text x="2258" y="1990.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">full_name</text><text x="2644" y="1990.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(255)</text><text x="2670" y="1990.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="job_title" data-row-top="2000" data-row-height="28"><title>job_title VARCHAR(255) NOT NULL</title><rect x="2177" y="2000" width="510" height="28" fill="#f8fafc"/><text x="2258" y="2018.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">job_title</text><text x="2644" y="2018.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(255)</text><text x="2670" y="2018.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="department_id" data-row-top="2028" data-row-height="28"><title>department_id BIGINT NOT NULL REFERENCES departments(id)</title><rect x="2177" y="2028" width="510" height="28" fill="#eef2f7"/><text x="2188" y="2046.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK02</text><text x="2258" y="2046.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">department_id</text><text x="2644" y="2046.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="2670" y="2046.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="created_at" data-row-top="2056" data-row-height="28"><title>created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP</title><rect x="2177" y="2056" width="510" height="28" fill="#f8fafc"/><text x="2258" y="2074.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" cLine truncated
10 столбцов · 1 исходящих и 0 входящих FK</title><rect class="table-box" x="2176" y="2392" width="512" height="344" rx="6"/><path d="M 2182 2392 H 2682 Q 2688 2392 2688 2398 V 2456 H 2176 V 2398 Q 2176 2392 2182 2392 Z" fill="#e8edf3"/><text x="2192" y="2418" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">auth_refresh_tokens</text><text x="2192" y="2440" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Refresh-токены</text><g data-column="id" data-row-top="2456" data-row-height="28"><title>id BIGSERIAL PRIMARY KEY</title><rect x="2177" y="2456" width="510" height="28" fill="#eef2f7"/><text x="2188" y="2474.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="2258" y="2474.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="2644" y="2474.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="2670" y="2474.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="user_id" data-row-top="2484" data-row-height="28"><title>user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE</title><rect x="2177" y="2484" width="510" height="28" fill="#f8fafc"/><text x="2188" y="2502.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK03</text><text x="2258" y="2502.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">user_id</text><text x="2644" y="2502.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="2670" y="2502.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="tenant" data-row-top="2512" data-row-height="28"><title>tenant VARCHAR(100) NOT NULL</title><rect x="2177" y="2512" width="510" height="28" fill="#eef2f7"/><text x="2258" y="2530.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">tenant</text><text x="2644" y="2530.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(100)</text><text x="2670" y="2530.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="token_hash" data-row-top="2540" data-row-height="28"><title>token_hash VARCHAR(64) UNIQUE NOT NULL</title><rect x="2177" y="2540" width="510" height="28" fill="#f8fafc"/><text x="2188" y="2558.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">UQ</text><text x="2258" y="2558.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">token_hash</text><text x="2644" y="2558.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(64)</text><text x="2670" y="2558.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="issued_at" data-row-top="2568" data-row-height="28"><title>issued_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP</title><rect x="2177" y="2568" width="510" height="28" fill="#eef2f7"/><text x="2258" y="2586.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">issued_at</text><text x="2644" y="2586.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">timestamptz</text><text x="2670" y="2586.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="expires_at" data-row-top="2596" data-row-height="28"><title>expires_at TIMESTAMPTZ NOT NULL</title><rect x="2177" y="2596" width="510" height="28" fill="#f8fafc"/><text x="2258" y="2614.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">expires_at</text><text x="2644" y="2614.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">timestamptz</text><text x="2670" y="2614.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="revoked_at" data-row-top="2624" data-row-height="28"><title>revoked_at TIMESTAMPTZ</title><rect x="2177" y="2624" width="510" height="28" fill="#eef2f7"/><text x="2258" y="2642.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">revoked_at</text><text x="2644" y="2642.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">timestamptz</text><text x="2670" y="2642.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="rotated_to_token_hash" data-row-top="2652" data-row-height="28"><title>rotated_to_token_hash VARCHAR(64)</title><rect x="2177" y="2652" width="510" height="28" fill="#f8fafc"/><text x="2258" y="2670.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="startLine truncated
10 столбцов · 0 исходящих и 0 входящих FK</title><rect class="table-box" x="2176" y="152" width="512" height="344" rx="6"/><path d="M 2182 152 H 2682 Q 2688 152 2688 158 V 216 H 2176 V 158 Q 2176 152 2182 152 Z" fill="#e8edf3"/><text x="2192" y="178" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">auth_login_rate_limits</text><text x="2192" y="200" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Ограничение попыток входа</text><g data-column="id" data-row-top="216" data-row-height="28"><title>id BIGSERIAL PRIMARY KEY</title><rect x="2177" y="216" width="510" height="28" fill="#eef2f7"/><text x="2188" y="234.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="2258" y="234.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="2644" y="234.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="2670" y="234.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="tenant" data-row-top="244" data-row-height="28"><title>tenant VARCHAR(100) NOT NULL</title><rect x="2177" y="244" width="510" height="28" fill="#f8fafc"/><text x="2258" y="262.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">tenant</text><text x="2644" y="262.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(100)</text><text x="2670" y="262.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="username_normalized" data-row-top="272" data-row-height="28"><title>username_normalized VARCHAR(100) NOT NULL</title><rect x="2177" y="272" width="510" height="28" fill="#eef2f7"/><text x="2258" y="290.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">username_normalized</text><text x="2644" y="290.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(100)</text><text x="2670" y="290.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="client_ip" data-row-top="300" data-row-height="28"><title>client_ip VARCHAR(64) NOT NULL</title><rect x="2177" y="300" width="510" height="28" fill="#f8fafc"/><text x="2258" y="318.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">client_ip</text><text x="2644" y="318.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(64)</text><text x="2670" y="318.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="failure_count" data-row-top="328" data-row-height="28"><title>failure_count INTEGER NOT NULL DEFAULT 0</title><rect x="2177" y="328" width="510" height="28" fill="#eef2f7"/><text x="2258" y="346.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">failure_count</text><text x="2644" y="346.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">integer</text><text x="2670" y="346.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="window_started_at" data-row-top="356" data-row-height="28"><title>window_started_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP</title><rect x="2177" y="356" width="510" height="28" fill="#f8fafc"/><text x="2258" y="374.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">window_started_at</text><text x="2644" y="374.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">timestamptz</text><text x="2670" y="374.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="last_failure_at" data-row-top="384" data-row-height="28"><title>last_failure_at TIMESTAMPTZ</title><rect x="2177" y="384" width="510" height="28" fill="#eef2f7"/><text x="2258" y="402.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">last_failure_at</text><text x="2644" y="402.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">timestamptz</text><text x="2670" y="402.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="blocked_until" data-row-top="412" data-row-height="28"><title>blocked_until TIMESTAMPTZ</title><rect x="2177" y="412" width="510" height="28" fill="#f8fafc"/><text x="2258" y="430.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">blocked_until</text><text x="2644" y="430.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">timestamptz</text><text x="2670" y="430.0" font-size="10" fill="#475569" font-Line truncated
7 столбцов · 0 исходящих и 0 входящих FK</title><rect class="table-box" x="2176" y="608" width="512" height="260" rx="6"/><path d="M 2182 608 H 2682 Q 2688 608 2688 614 V 672 H 2176 V 614 Q 2176 608 2182 608 Z" fill="#e8edf3"/><text x="2192" y="634" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">auth_login_attempt_audit</text><text x="2192" y="656" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Аудит неудачных входов</text><g data-column="id" data-row-top="672" data-row-height="28"><title>id BIGSERIAL PRIMARY KEY</title><rect x="2177" y="672" width="510" height="28" fill="#eef2f7"/><text x="2188" y="690.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="2258" y="690.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="2644" y="690.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="2670" y="690.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="tenant" data-row-top="700" data-row-height="28"><title>tenant VARCHAR(100) NOT NULL</title><rect x="2177" y="700" width="510" height="28" fill="#f8fafc"/><text x="2258" y="718.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">tenant</text><text x="2644" y="718.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(100)</text><text x="2670" y="718.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="username_normalized" data-row-top="728" data-row-height="28"><title>username_normalized VARCHAR(100) NOT NULL</title><rect x="2177" y="728" width="510" height="28" fill="#eef2f7"/><text x="2258" y="746.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">username_normalized</text><text x="2644" y="746.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(100)</text><text x="2670" y="746.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="client_ip" data-row-top="756" data-row-height="28"><title>client_ip VARCHAR(64) NOT NULL</title><rect x="2177" y="756" width="510" height="28" fill="#f8fafc"/><text x="2258" y="774.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">client_ip</text><text x="2644" y="774.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(64)</text><text x="2670" y="774.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="outcome" data-row-top="784" data-row-height="28"><title>outcome VARCHAR(20) NOT NULL</title><rect x="2177" y="784" width="510" height="28" fill="#eef2f7"/><text x="2258" y="802.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">outcome</text><text x="2644" y="802.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(20)</text><text x="2670" y="802.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="occurred_at" data-row-top="812" data-row-height="28"><title>occurred_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP</title><rect x="2177" y="812" width="510" height="28" fill="#f8fafc"/><text x="2258" y="830.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">occurred_at</text><text x="2644" y="830.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">timestamptz</text><text x="2670" y="830.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="retry_after_seconds" data-row-top="840" data-row-height="28"><title>retry_after_seconds INTEGER</title><rect x="2177" y="840" width="510" height="28" fill="#eef2f7"/><text x="2258" y="858.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">retry_after_seconds</text><text x="2644" y="858.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">integer</text><text x="2670" y="858.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g></g><g class="entity" id="table-teacher_department_assignments" data-table="teacher_department_assignments" tabindex="0" role="button" aria-label="teacher_department_assignments: История принадлежности к кафедрам"><title>teacher_department_assignments: История принадлежности к кафедрам
9 столбцов · 3 исходящих и 0 входящих FK</title><rect class="table-box" x="2176" y="2848" width="512" height="316" rx="6"/><path d="M 2182 2848 H 2682 Q 2688 2848 2688 2854 V 2912 H 2176 V 2854 Q 2176 2848 2182 2848 Z" fill="#e8edf3"/><text x="2192" y="2874" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">teacher_department_assignments</text><text x="2192" y="2896" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">История принадлежности к кафедрам</text><g data-column="id" data-row-top="2912" data-row-height="28"><title>id BIGSERIAL PRIMARY KEY</title><rect x="2177" y="2912" width="510" height="28" fill="#eef2f7"/><text x="2188" y="2930.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="2258" y="2930.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="2644" y="2930.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="2670" y="2930.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="teacher_id" data-row-top="2940" data-row-height="28"><title>teacher_id BIGINT NOT NULL REFERENCES users(id)</title><rect x="2177" y="2940" width="510" height="28" fill="#f8fafc"/><text x="2188" y="2958.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK04</text><text x="2258" y="2958.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">teacher_id</text><text x="2644" y="2958.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="2670" y="2958.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="department_id" data-row-top="2968" data-row-height="28"><title>department_id BIGINT NOT NULL REFERENCES departments(id)</title><rect x="2177" y="2968" width="510" height="28" fill="#eef2f7"/><text x="2188" y="2986.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK05</text><text x="2258" y="2986.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">department_id</text><text x="2644" y="2986.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="2670" y="2986.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="valid_from" data-row-top="2996" data-row-height="28"><title>valid_from DATE NOT NULL</title><rect x="2177" y="2996" width="510" height="28" fill="#f8fafc"/><text x="2258" y="3014.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">valid_from</text><text x="2644" y="3014.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="2670" y="3014.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="valid_to" data-row-top="3024" data-row-height="28"><title>valid_to DATE</title><rect x="2177" y="3024" width="510" height="28" fill="#eef2f7"/><text x="2258" y="3042.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">valid_to</text><text x="2644" y="3042.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="2670" y="3042.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="is_primary" data-row-top="3052" data-row-height="28"><title>is_primary BOOLEAN NOT NULL DEFAULT TRUE</title><rect x="2177" y="3052" width="510" height="28" fill="#f8fafc"/><text x="2258" y="3070.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">is_primary</text><text x="2644" y="3070.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">boolean</text><text x="2670" y="3070.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="comment" data-row-top="3080" data-row-height="28"><title>comment TEXT</title><rect x="2177" y="3080" width="510" height="28" fill="#eef2f7"/><text x="2258" y="3098.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">comment</text><text x="2644" y="3098.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">text</text><text x="2670" y="3098.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="created_at" data-row-top="3108" data-row-height="28"><title>created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP</title><rect x="2177" y="3108" width="510" height="28" fill="#f8fafc"/><text x="2258" y="3126.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="sLine truncated
14 столбцов · 4 исходящих и 0 входящих FK</title><rect class="table-box" x="2176" y="3276" width="512" height="456" rx="6"/><path d="M 2182 3276 H 2682 Q 2688 3276 2688 3282 V 3340 H 2176 V 3282 Q 2176 3276 2182 3276 Z" fill="#e8edf3"/><text x="2192" y="3302" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">teacher_creation_requests</text><text x="2192" y="3324" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Заявки на создание преподавателя</text><g data-column="id" data-row-top="3340" data-row-height="28"><title>id BIGSERIAL PRIMARY KEY</title><rect x="2177" y="3340" width="510" height="28" fill="#eef2f7"/><text x="2188" y="3358.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="2258" y="3358.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="2644" y="3358.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="2670" y="3358.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="department_id" data-row-top="3368" data-row-height="28"><title>department_id BIGINT NOT NULL REFERENCES departments(id)</title><rect x="2177" y="3368" width="510" height="28" fill="#f8fafc"/><text x="2188" y="3386.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK07</text><text x="2258" y="3386.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">department_id</text><text x="2644" y="3386.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="2670" y="3386.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="username" data-row-top="3396" data-row-height="28"><title>username VARCHAR(50) NOT NULL</title><rect x="2177" y="3396" width="510" height="28" fill="#eef2f7"/><text x="2258" y="3414.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">username</text><text x="2644" y="3414.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(50)</text><text x="2670" y="3414.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="full_name" data-row-top="3424" data-row-height="28"><title>full_name VARCHAR(255) NOT NULL</title><rect x="2177" y="3424" width="510" height="28" fill="#f8fafc"/><text x="2258" y="3442.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">full_name</text><text x="2644" y="3442.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(255)</text><text x="2670" y="3442.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="job_title" data-row-top="3452" data-row-height="28"><title>job_title VARCHAR(255) NOT NULL</title><rect x="2177" y="3452" width="510" height="28" fill="#eef2f7"/><text x="2258" y="3470.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">job_title</text><text x="2644" y="3470.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(255)</text><text x="2670" y="3470.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="comment" data-row-top="3480" data-row-height="28"><title>comment TEXT</title><rect x="2177" y="3480" width="510" height="28" fill="#f8fafc"/><text x="2258" y="3498.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">comment</text><text x="2644" y="3498.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">text</text><text x="2670" y="3498.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="status" data-row-top="3508" data-row-height="28"><title>status VARCHAR(20) NOT NULL DEFAULT &#x27;PENDING&#x27;</title><rect x="2177" y="3508" width="510" height="28" fill="#eef2f7"/><text x="2258" y="3526.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">status</text><text x="2644" y="3526.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(20)</text><text x="2670" y="3526.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="requested_by" data-row-top="3536" data-row-height="28"><title>requested_by BIGINT REFERENCES users(id)</title><rect x="2177" y="3536" width="510" height="28" fill="#f8fafc"/><text x="2188" y="3554.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK08</text><text x="2258" y="3554.0" font-size="13" fill="#0f172a" font-weight="400" Line truncated
10 столбцов · 1 исходящих и 3 входящих FK</title><rect class="table-box" x="64" y="1124" width="512" height="364" rx="6"/><path d="M 70 1124 H 570 Q 576 1124 576 1130 V 1188 H 64 V 1130 Q 64 1124 70 1124 Z" fill="#e8edf3"/><text x="80" y="1150" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">education_forms</text><text x="80" y="1172" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Формы обучения</text><g data-column="id" data-row-top="1188" data-row-height="48"><title>id BIGSERIAL PRIMARY KEY</title><rect x="65" y="1188" width="510" height="48" fill="#eef2f7"/><text x="76" y="1216.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="146" y="1216.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="532" y="1216.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="558" y="1216.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="name" data-row-top="1236" data-row-height="28"><title>name VARCHAR(100) UNIQUE NOT NULL</title><rect x="65" y="1236" width="510" height="28" fill="#f8fafc"/><text x="76" y="1254.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">UQ</text><text x="146" y="1254.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">name</text><text x="532" y="1254.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(100)</text><text x="558" y="1254.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="description" data-row-top="1264" data-row-height="28"><title>description TEXT</title><rect x="65" y="1264" width="510" height="28" fill="#eef2f7"/><text x="146" y="1282.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">description</text><text x="532" y="1282.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">text</text><text x="558" y="1282.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="created_at" data-row-top="1292" data-row-height="28"><title>created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP</title><rect x="65" y="1292" width="510" height="28" fill="#f8fafc"/><text x="146" y="1310.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">created_at</text><text x="532" y="1310.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">timestamptz</text><text x="558" y="1310.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="status" data-row-top="1320" data-row-height="28"><title>status VARCHAR(20) NOT NULL DEFAULT &#x27;ACTIVE&#x27;</title><rect x="65" y="1320" width="510" height="28" fill="#eef2f7"/><text x="146" y="1338.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">status</text><text x="532" y="1338.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(20)</text><text x="558" y="1338.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="active_from" data-row-top="1348" data-row-height="28"><title>active_from DATE</title><rect x="65" y="1348" width="510" height="28" fill="#f8fafc"/><text x="146" y="1366.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">active_from</text><text x="532" y="1366.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="558" y="1366.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="active_to" data-row-top="1376" data-row-height="28"><title>active_to DATE</title><rect x="65" y="1376" width="510" height="28" fill="#eef2f7"/><text x="146" y="1394.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">active_to</text><text x="532" y="1394.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="558" y="1394.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="archived_at" data-row-top="1404" data-row-height="28"><title>archived_at TIMESTAMPTZ</title><rect x="65" y="1404" width="510" height="28" fill="#f8fafc"/><text x="146" y="1422.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">archived_at</text><text x="532" y="1422.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">timestamptz</text><text x="558" y="1422.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</Line truncated
15 столбцов · 5 исходящих и 4 входящих FK</title><rect class="table-box" x="64" y="1600" width="512" height="524" rx="6"/><path d="M 70 1600 H 570 Q 576 1600 576 1606 V 1664 H 64 V 1606 Q 64 1600 70 1600 Z" fill="#e8edf3"/><text x="80" y="1626" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">student_groups</text><text x="80" y="1648" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Студенческие группы</text><g data-column="id" data-row-top="1664" data-row-height="60"><title>id BIGSERIAL PRIMARY KEY</title><rect x="65" y="1664" width="510" height="60" fill="#eef2f7"/><text x="76" y="1698.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="146" y="1698.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="532" y="1698.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="558" y="1698.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="name" data-row-top="1724" data-row-height="28"><title>name VARCHAR(100) NOT NULL</title><rect x="65" y="1724" width="510" height="28" fill="#f8fafc"/><text x="146" y="1742.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">name</text><text x="532" y="1742.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(100)</text><text x="558" y="1742.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="group_size" data-row-top="1752" data-row-height="28"><title>group_size BIGINT NOT NULL CONSTRAINT chk_student_groups_group_size_positive CHECK (group_size &gt; 0)</title><rect x="65" y="1752" width="510" height="28" fill="#eef2f7"/><text x="146" y="1770.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">group_size</text><text x="532" y="1770.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="558" y="1770.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="education_form_id" data-row-top="1780" data-row-height="28"><title>education_form_id BIGINT NOT NULL REFERENCES education_forms(id)</title><rect x="65" y="1780" width="510" height="28" fill="#f8fafc"/><text x="76" y="1798.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK11</text><text x="146" y="1798.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">education_form_id</text><text x="532" y="1798.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="558" y="1798.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="department_id" data-row-top="1808" data-row-height="28"><title>department_id BIGINT NOT NULL REFERENCES departments(id)</title><rect x="65" y="1808" width="510" height="28" fill="#eef2f7"/><text x="76" y="1826.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK12</text><text x="146" y="1826.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">department_id</text><text x="532" y="1826.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="558" y="1826.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="specialty_id" data-row-top="1836" data-row-height="36"><title>specialty_id BIGINT NOT NULL REFERENCES specialties(id)</title><rect x="65" y="1836" width="510" height="36" fill="#f8fafc"/><text x="76" y="1858.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK13·FK14</text><text x="146" y="1858.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">specialty_id</text><text x="532" y="1858.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="558" y="1858.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="specialty_profile_id" data-row-top="1872" data-row-height="28"><title>specialty_profile_id BIGINT NOT NULL</title><rect x="65" y="1872" width="510" height="28" fill="#eef2f7"/><text x="76" y="1890.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK14</text><text x="146" y="1890.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">specialty_profile_id</text><text x="532" y="1890.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="558" y="1890.0" font-size="10" fill="#475569" font-weight="400" text-anchoLine truncated
10 столбцов · 2 исходящих и 1 входящих FK</title><rect class="table-box" x="64" y="2236" width="512" height="344" rx="6"/><path d="M 70 2236 H 570 Q 576 2236 576 2242 V 2300 H 64 V 2242 Q 64 2236 70 2236 Z" fill="#e8edf3"/><text x="80" y="2262" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">subgroups</text><text x="80" y="2284" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Подгруппы</text><g data-column="id" data-row-top="2300" data-row-height="28"><title>id BIGSERIAL PRIMARY KEY</title><rect x="65" y="2300" width="510" height="28" fill="#eef2f7"/><text x="76" y="2318.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="146" y="2318.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="532" y="2318.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="558" y="2318.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="group_id" data-row-top="2328" data-row-height="28"><title>group_id BIGINT NOT NULL REFERENCES student_groups(id) ON DELETE CASCADE</title><rect x="65" y="2328" width="510" height="28" fill="#f8fafc"/><text x="76" y="2346.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK15</text><text x="146" y="2346.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">group_id</text><text x="532" y="2346.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="558" y="2346.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="name" data-row-top="2356" data-row-height="28"><title>name VARCHAR(100) NOT NULL</title><rect x="65" y="2356" width="510" height="28" fill="#eef2f7"/><text x="146" y="2374.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">name</text><text x="532" y="2374.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(100)</text><text x="558" y="2374.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="student_capacity" data-row-top="2384" data-row-height="28"><title>student_capacity INT NOT NULL CONSTRAINT chk_subgroups_student_capacity_positive CHECK (student_capacity &gt; 0)</title><rect x="65" y="2384" width="510" height="28" fill="#f8fafc"/><text x="146" y="2402.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">student_capacity</text><text x="532" y="2402.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">int</text><text x="558" y="2402.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="status" data-row-top="2412" data-row-height="28"><title>status VARCHAR(20) NOT NULL DEFAULT &#x27;ACTIVE&#x27;</title><rect x="65" y="2412" width="510" height="28" fill="#eef2f7"/><text x="146" y="2430.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">status</text><text x="532" y="2430.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(20)</text><text x="558" y="2430.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="active_from" data-row-top="2440" data-row-height="28"><title>active_from DATE</title><rect x="65" y="2440" width="510" height="28" fill="#f8fafc"/><text x="146" y="2458.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">active_from</text><text x="532" y="2458.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="558" y="2458.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="active_to" data-row-top="2468" data-row-height="28"><title>active_to DATE</title><rect x="65" y="2468" width="510" height="28" fill="#eef2f7"/><text x="146" y="2486.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">active_to</text><text x="532" y="2486.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="558" y="2486.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="archived_at" data-row-top="2496" data-row-height="28"><title>archived_at TIMESTAMPTZ</title><rect x="65" y="2496" width="510" height="28" fill="#f8fafc"/><text x="146" y="2514.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">archived_at</text><text x="532" y="2514.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">timestamptz</text><text x="558Line truncated
12 столбцов · 2 исходящих и 5 входящих FK</title><rect class="table-box" x="3584" y="152" width="512" height="420" rx="6"/><path d="M 3590 152 H 4090 Q 4096 152 4096 158 V 216 H 3584 V 158 Q 3584 152 3590 152 Z" fill="#e8edf3"/><text x="3600" y="178" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">subjects</text><text x="3600" y="200" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Дисциплины</text><g data-column="id" data-row-top="216" data-row-height="48"><title>id BIGSERIAL PRIMARY KEY</title><rect x="3585" y="216" width="510" height="48" fill="#eef2f7"/><text x="3596" y="244.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="3666" y="244.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="4052" y="244.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="4078" y="244.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="name" data-row-top="264" data-row-height="28"><title>name VARCHAR(200) NOT NULL</title><rect x="3585" y="264" width="510" height="28" fill="#f8fafc"/><text x="3666" y="282.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">name</text><text x="4052" y="282.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(200)</text><text x="4078" y="282.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="code" data-row-top="292" data-row-height="28"><title>code VARCHAR(20)</title><rect x="3585" y="292" width="510" height="28" fill="#eef2f7"/><text x="3666" y="310.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">code</text><text x="4052" y="310.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(20)</text><text x="4078" y="310.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="department_id" data-row-top="320" data-row-height="28"><title>department_id BIGINT NOT NULL REFERENCES departments(id)</title><rect x="3585" y="320" width="510" height="28" fill="#f8fafc"/><text x="3596" y="338.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK16</text><text x="3666" y="338.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">department_id</text><text x="4052" y="338.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="4078" y="338.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="description" data-row-top="348" data-row-height="28"><title>description TEXT</title><rect x="3585" y="348" width="510" height="28" fill="#eef2f7"/><text x="3666" y="366.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">description</text><text x="4052" y="366.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">text</text><text x="4078" y="366.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="created_at" data-row-top="376" data-row-height="28"><title>created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP</title><rect x="3585" y="376" width="510" height="28" fill="#f8fafc"/><text x="3666" y="394.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">created_at</text><text x="4052" y="394.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">timestamptz</text><text x="4078" y="394.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="status" data-row-top="404" data-row-height="28"><title>status VARCHAR(20) NOT NULL DEFAULT &#x27;ACTIVE&#x27;</title><rect x="3585" y="404" width="510" height="28" fill="#eef2f7"/><text x="3666" y="422.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">status</text><text x="4052" y="422.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(20)</text><text x="4078" y="422.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="active_from" data-row-top="432" data-row-height="28"><title>active_from DATE</title><rect x="3585" y="432" width="510" height="28" fill="#f8fafc"/><text x="3666" y="450.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">active_from</text><text x="4052" y="450.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="4078" y="450.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middlLine truncated
5 столбцов · 2 исходящих и 0 входящих FK</title><rect class="table-box" x="3584" y="1400" width="512" height="204" rx="6"/><path d="M 3590 1400 H 4090 Q 4096 1400 4096 1406 V 1464 H 3584 V 1406 Q 3584 1400 3590 1400 Z" fill="#e8edf3"/><text x="3600" y="1426" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">subject_comments</text><text x="3600" y="1448" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Комментарии к дисциплинам</text><g data-column="id" data-row-top="1464" data-row-height="28"><title>id BIGSERIAL PRIMARY KEY</title><rect x="3585" y="1464" width="510" height="28" fill="#eef2f7"/><text x="3596" y="1482.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="3666" y="1482.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="4052" y="1482.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="4078" y="1482.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="subject_id" data-row-top="1492" data-row-height="28"><title>subject_id BIGINT NOT NULL REFERENCES subjects(id)</title><rect x="3585" y="1492" width="510" height="28" fill="#f8fafc"/><text x="3596" y="1510.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK17</text><text x="3666" y="1510.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">subject_id</text><text x="4052" y="1510.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="4078" y="1510.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="author_id" data-row-top="1520" data-row-height="28"><title>author_id BIGINT REFERENCES users(id)</title><rect x="3585" y="1520" width="510" height="28" fill="#eef2f7"/><text x="3596" y="1538.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK18</text><text x="3666" y="1538.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">author_id</text><text x="4052" y="1538.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="4078" y="1538.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="comment" data-row-top="1548" data-row-height="28"><title>comment TEXT NOT NULL</title><rect x="3585" y="1548" width="510" height="28" fill="#f8fafc"/><text x="3666" y="1566.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">comment</text><text x="4052" y="1566.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">text</text><text x="4078" y="1566.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="created_at" data-row-top="1576" data-row-height="28"><title>created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP</title><rect x="3585" y="1576" width="510" height="28" fill="#eef2f7"/><text x="3666" y="1594.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">created_at</text><text x="4052" y="1594.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">timestamptz</text><text x="4078" y="1594.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g></g><g class="entity" id="table-lesson_types" data-table="lesson_types" tabindex="0" role="button" aria-label="lesson_types: Виды занятий"><title>lesson_types: Виды занятий
5 столбцов · 0 исходящих и 3 входящих FK</title><rect class="table-box" x="3584" y="684" width="512" height="204" rx="6"/><path d="M 3590 684 H 4090 Q 4096 684 4096 690 V 748 H 3584 V 690 Q 3584 684 3590 684 Z" fill="#e8edf3"/><text x="3600" y="710" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">lesson_types</text><text x="3600" y="732" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Виды занятий</text><g data-column="id" data-row-top="748" data-row-height="28"><title>id BIGSERIAL PRIMARY KEY</title><rect x="3585" y="748" width="510" height="28" fill="#eef2f7"/><text x="3596" y="766.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="3666" y="766.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="4052" y="766.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="4078" y="766.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="name" data-row-top="776" data-row-height="28"><title>name VARCHAR(50) UNIQUE NOT NULL</title><rect x="3585" y="776" width="510" height="28" fill="#f8fafc"/><text x="3596" y="794.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">UQ</text><text x="3666" y="794.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">name</text><text x="4052" y="794.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(50)</text><text x="4078" y="794.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="code" data-row-top="804" data-row-height="28"><title>code VARCHAR(30) NOT NULL UNIQUE CONSTRAINT chk_lesson_types_code CHECK (code ~ &#x27;^[A-Z][A-Z0-9_]*$&#x27;)</title><rect x="3585" y="804" width="510" height="28" fill="#eef2f7"/><text x="3596" y="822.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">UQ</text><text x="3666" y="822.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">code</text><text x="4052" y="822.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(30)</text><text x="4078" y="822.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="color_code" data-row-top="832" data-row-height="28"><title>color_code VARCHAR(7) DEFAULT &#x27;#3788d8&#x27;</title><rect x="3585" y="832" width="510" height="28" fill="#f8fafc"/><text x="3666" y="850.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">color_code</text><text x="4052" y="850.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(7)</text><text x="4078" y="850.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="duration_minutes" data-row-top="860" data-row-height="28"><title>duration_minutes INT DEFAULT 90</title><rect x="3585" y="860" width="510" height="28" fill="#eef2f7"/><text x="3666" y="878.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">duration_minutes</text><text x="4052" y="878.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">int</text><text x="4078" y="878.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g></g><g class="entity" id="table-equipments" data-table="equipments" tabindex="0" role="button" aria-label="equipments: Оборудование"><title>equipments: Оборудование
10 столбцов · 1 исходящих и 1 входящих FK</title><rect class="table-box" x="3584" y="2304" width="512" height="344" rx="6"/><path d="M 3590 2304 H 4090 Q 4096 2304 4096 2310 V 2368 H 3584 V 2310 Q 3584 2304 3590 2304 Z" fill="#e8edf3"/><text x="3600" y="2330" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">equipments</text><text x="3600" y="2352" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Оборудование</text><g data-column="id" data-row-top="2368" data-row-height="28"><title>id BIGSERIAL PRIMARY KEY</title><rect x="3585" y="2368" width="510" height="28" fill="#eef2f7"/><text x="3596" y="2386.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="3666" y="2386.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="4052" y="2386.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="4078" y="2386.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="name" data-row-top="2396" data-row-height="28"><title>name VARCHAR(50) UNIQUE NOT NULL</title><rect x="3585" y="2396" width="510" height="28" fill="#f8fafc"/><text x="3596" y="2414.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">UQ</text><text x="3666" y="2414.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">name</text><text x="4052" y="2414.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(50)</text><text x="4078" y="2414.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="description" data-row-top="2424" data-row-height="28"><title>description TEXT</title><rect x="3585" y="2424" width="510" height="28" fill="#eef2f7"/><text x="3666" y="2442.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">description</text><text x="4052" y="2442.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">text</text><text x="4078" y="2442.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="inventory_number" data-row-top="2452" data-row-height="28"><title>inventory_number VARCHAR(50)</title><rect x="3585" y="2452" width="510" height="28" fill="#f8fafc"/><text x="3666" y="2470.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">inventory_number</text><text x="4052" y="2470.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(50)</text><text x="4078" y="2470.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="status" data-row-top="2480" data-row-height="28"><title>status VARCHAR(20) NOT NULL DEFAULT &#x27;ACTIVE&#x27;</title><rect x="3585" y="2480" width="510" height="28" fill="#eef2f7"/><text x="3666" y="2498.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">status</text><text x="4052" y="2498.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(20)</text><text x="4078" y="2498.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="active_from" data-row-top="2508" data-row-height="28"><title>active_from DATE</title><rect x="3585" y="2508" width="510" height="28" fill="#f8fafc"/><text x="3666" y="2526.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">active_from</text><text x="4052" y="2526.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="4078" y="2526.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="active_to" data-row-top="2536" data-row-height="28"><title>active_to DATE</title><rect x="3585" y="2536" width="510" height="28" fill="#eef2f7"/><text x="3666" y="2554.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">active_to</text><text x="4052" y="2554.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="4078" y="2554.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="archived_at" data-row-top="2564" data-row-height="28"><title>archived_at TIMESTAMPTZ</title><rect x="3585" y="2564" width="510" height="28" fill="#f8fafc"/><text x="3666" y="2582.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">archived_at</text><text x="4052" y="2582.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">timestamptz</text><text x="4078" y="2582.0" font-size="10" fill="#475569" font-weight="4Line truncated
14 столбцов · 1 исходящих и 4 входящих FK</title><rect class="table-box" x="3584" y="1716" width="512" height="476" rx="6"/><path d="M 3590 1716 H 4090 Q 4096 1716 4096 1722 V 1780 H 3584 V 1722 Q 3584 1716 3590 1716 Z" fill="#e8edf3"/><text x="3600" y="1742" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">classrooms</text><text x="3600" y="1764" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Аудитории</text><g data-column="id" data-row-top="1780" data-row-height="48"><title>id BIGSERIAL PRIMARY KEY</title><rect x="3585" y="1780" width="510" height="48" fill="#eef2f7"/><text x="3596" y="1808.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="3666" y="1808.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="4052" y="1808.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="4078" y="1808.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="name" data-row-top="1828" data-row-height="28"><title>name VARCHAR(50) UNIQUE NOT NULL</title><rect x="3585" y="1828" width="510" height="28" fill="#f8fafc"/><text x="3596" y="1846.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">UQ</text><text x="3666" y="1846.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">name</text><text x="4052" y="1846.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(50)</text><text x="4078" y="1846.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="capacity" data-row-top="1856" data-row-height="28"><title>capacity INT NOT NULL CHECK (capacity &gt; 0)</title><rect x="3585" y="1856" width="510" height="28" fill="#eef2f7"/><text x="3666" y="1874.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">capacity</text><text x="4052" y="1874.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">int</text><text x="4078" y="1874.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="building" data-row-top="1884" data-row-height="28"><title>building VARCHAR(50)</title><rect x="3585" y="1884" width="510" height="28" fill="#f8fafc"/><text x="3666" y="1902.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">building</text><text x="4052" y="1902.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(50)</text><text x="4078" y="1902.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="floor" data-row-top="1912" data-row-height="28"><title>floor INT</title><rect x="3585" y="1912" width="510" height="28" fill="#eef2f7"/><text x="3666" y="1930.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">floor</text><text x="4052" y="1930.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">int</text><text x="4078" y="1930.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="is_available" data-row-top="1940" data-row-height="28"><title>is_available BOOLEAN DEFAULT TRUE</title><rect x="3585" y="1940" width="510" height="28" fill="#f8fafc"/><text x="3666" y="1958.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">is_available</text><text x="4052" y="1958.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">boolean</text><text x="4078" y="1958.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="description" data-row-top="1968" data-row-height="28"><title>description TEXT</title><rect x="3585" y="1968" width="510" height="28" fill="#eef2f7"/><text x="3666" y="1986.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">description</text><text x="4052" y="1986.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">text</text><text x="4078" y="1986.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="created_at" data-row-top="1996" data-row-height="28"><title>created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP</title><rect x="3585" y="1996" width="510" height="28" fill="#f8fafc"/><text x="3666" y="2014.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">created_at</text><text x="4052" y="2014.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">timestamptz</text><text x="4078" y="2014.0" font-size="10" fill="#475569" font-weight="400" text-ancLine truncated
4 столбцов · 2 исходящих и 0 входящих FK</title><rect class="table-box" x="3584" y="2760" width="512" height="176" rx="6"/><path d="M 3590 2760 H 4090 Q 4096 2760 4096 2766 V 2824 H 3584 V 2766 Q 3584 2760 3590 2760 Z" fill="#e8edf3"/><text x="3600" y="2786" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">classroom_equipments</text><text x="3600" y="2808" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Оснащение аудиторий</text><g data-column="classroom_id" data-row-top="2824" data-row-height="28"><title>classroom_id BIGINT NOT NULL REFERENCES classrooms(id) ON DELETE CASCADE</title><rect x="3585" y="2824" width="510" height="28" fill="#eef2f7"/><text x="3596" y="2842.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK·FK19</text><text x="3666" y="2842.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">classroom_id</text><text x="4052" y="2842.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="4078" y="2842.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="equipment_id" data-row-top="2852" data-row-height="28"><title>equipment_id BIGINT NOT NULL REFERENCES equipments(id) ON DELETE CASCADE</title><rect x="3585" y="2852" width="510" height="28" fill="#f8fafc"/><text x="3596" y="2870.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK·FK20</text><text x="3666" y="2870.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">equipment_id</text><text x="4052" y="2870.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="4078" y="2870.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="quantity" data-row-top="2880" data-row-height="28"><title>quantity INT NOT NULL DEFAULT 1 CHECK (quantity &gt; 0)</title><rect x="3585" y="2880" width="510" height="28" fill="#eef2f7"/><text x="3666" y="2898.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">quantity</text><text x="4052" y="2898.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">int</text><text x="4078" y="2898.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="notes" data-row-top="2908" data-row-height="28"><title>notes TEXT</title><rect x="3585" y="2908" width="510" height="28" fill="#f8fafc"/><text x="3666" y="2926.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">notes</text><text x="4052" y="2926.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">text</text><text x="4078" y="2926.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g></g><g class="entity" id="table-teacher_subjects" data-table="teacher_subjects" tabindex="0" role="button" aria-label="teacher_subjects: Закрепление дисциплин за преподавателями"><title>teacher_subjects: Закрепление дисциплин за преподавателями
8 столбцов · 4 исходящих и 0 входящих FK</title><rect class="table-box" x="3584" y="1000" width="512" height="288" rx="6"/><path d="M 3590 1000 H 4090 Q 4096 1000 4096 1006 V 1064 H 3584 V 1006 Q 3584 1000 3590 1000 Z" fill="#e8edf3"/><text x="3600" y="1026" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">teacher_subjects</text><text x="3600" y="1048" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Закрепление дисциплин за преподавателями</text><g data-column="id" data-row-top="1064" data-row-height="28"><title>id BIGSERIAL PRIMARY KEY</title><rect x="3585" y="1064" width="510" height="28" fill="#eef2f7"/><text x="3596" y="1082.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="3666" y="1082.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="4052" y="1082.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="4078" y="1082.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="user_id" data-row-top="1092" data-row-height="28"><title>user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE</title><rect x="3585" y="1092" width="510" height="28" fill="#f8fafc"/><text x="3596" y="1110.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK21</text><text x="3666" y="1110.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">user_id</text><text x="4052" y="1110.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="4078" y="1110.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="subject_id" data-row-top="1120" data-row-height="28"><title>subject_id BIGINT NOT NULL REFERENCES subjects(id) ON DELETE CASCADE</title><rect x="3585" y="1120" width="510" height="28" fill="#eef2f7"/><text x="3596" y="1138.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK22</text><text x="3666" y="1138.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">subject_id</text><text x="4052" y="1138.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="4078" y="1138.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="academic_year_id" data-row-top="1148" data-row-height="28"><title>academic_year_id BIGINT</title><rect x="3585" y="1148" width="510" height="28" fill="#f8fafc"/><text x="3596" y="1166.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK26</text><text x="3666" y="1166.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">academic_year_id</text><text x="4052" y="1166.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="4078" y="1166.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="semester_number" data-row-top="1176" data-row-height="28"><title>semester_number INT</title><rect x="3585" y="1176" width="510" height="28" fill="#eef2f7"/><text x="3666" y="1194.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">semester_number</text><text x="4052" y="1194.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">int</text><text x="4078" y="1194.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="lesson_type_id" data-row-top="1204" data-row-height="28"><title>lesson_type_id BIGINT NOT NULL REFERENCES lesson_types(id) ON DELETE CASCADE</title><rect x="3585" y="1204" width="510" height="28" fill="#f8fafc"/><text x="3596" y="1222.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK23</text><text x="3666" y="1222.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">lesson_type_id</text><text x="4052" y="1222.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="4078" y="1222.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="qualification_level" data-row-top="1232" data-row-height="28"><title>qualification_level VARCHAR(50)</title><rect x="3585" y="1232" width="510" height="28" fill="#eef2f7"/><text x="3666" y="1250.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">qualification_level</text><text x="4052" y="1250.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(50)</text><text x="4078" y="1250.0" font-size="10" Line truncated
7 столбцов · 0 исходящих и 2 входящих FK</title><rect class="table-box" x="1472" y="1368" width="512" height="268" rx="6"/><path d="M 1478 1368 H 1978 Q 1984 1368 1984 1374 V 1432 H 1472 V 1374 Q 1472 1368 1478 1368 Z" fill="#e8edf3"/><text x="1488" y="1394" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">time_slot_scopes</text><text x="1488" y="1416" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Наборы звонков</text><g data-column="id" data-row-top="1432" data-row-height="36"><title>id BIGSERIAL PRIMARY KEY</title><rect x="1473" y="1432" width="510" height="36" fill="#eef2f7"/><text x="1484" y="1454.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="1554" y="1454.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="1940" y="1454.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="1966" y="1454.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="code" data-row-top="1468" data-row-height="28"><title>code VARCHAR(50) NOT NULL UNIQUE</title><rect x="1473" y="1468" width="510" height="28" fill="#f8fafc"/><text x="1484" y="1486.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">UQ</text><text x="1554" y="1486.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">code</text><text x="1940" y="1486.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(50)</text><text x="1966" y="1486.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="name" data-row-top="1496" data-row-height="28"><title>name VARCHAR(120) NOT NULL</title><rect x="1473" y="1496" width="510" height="28" fill="#eef2f7"/><text x="1554" y="1514.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">name</text><text x="1940" y="1514.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(120)</text><text x="1966" y="1514.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="apply_mode" data-row-top="1524" data-row-height="28"><title>apply_mode VARCHAR(20) NOT NULL</title><rect x="1473" y="1524" width="510" height="28" fill="#f8fafc"/><text x="1554" y="1542.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">apply_mode</text><text x="1940" y="1542.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(20)</text><text x="1966" y="1542.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="day_of_week" data-row-top="1552" data-row-height="28"><title>day_of_week INT NULL</title><rect x="1473" y="1552" width="510" height="28" fill="#eef2f7"/><text x="1554" y="1570.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">day_of_week</text><text x="1940" y="1570.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">int</text><text x="1966" y="1570.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="system_scope" data-row-top="1580" data-row-height="28"><title>system_scope BOOLEAN NOT NULL DEFAULT FALSE</title><rect x="1473" y="1580" width="510" height="28" fill="#f8fafc"/><text x="1554" y="1598.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">system_scope</text><text x="1940" y="1598.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">boolean</text><text x="1966" y="1598.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="display_order" data-row-top="1608" data-row-height="28"><title>display_order INT NOT NULL DEFAULT 100</title><rect x="1473" y="1608" width="510" height="28" fill="#eef2f7"/><text x="1554" y="1626.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">display_order</text><text x="1940" y="1626.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">int</text><text x="1966" y="1626.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g></g><g class="entity" id="table-time_slots" data-table="time_slots" tabindex="0" role="button" aria-label="time_slots: Временные слоты"><title>time_slots: Временные слоты
6 столбцов · 1 исходящих и 4 входящих FK</title><rect class="table-box" x="1472" y="1748" width="512" height="264" rx="6"/><path d="M 1478 1748 H 1978 Q 1984 1748 1984 1754 V 1812 H 1472 V 1754 Q 1472 1748 1478 1748 Z" fill="#e8edf3"/><text x="1488" y="1774" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">time_slots</text><text x="1488" y="1796" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Временные слоты</text><g data-column="id" data-row-top="1812" data-row-height="60"><title>id BIGSERIAL PRIMARY KEY</title><rect x="1473" y="1812" width="510" height="60" fill="#eef2f7"/><text x="1484" y="1846.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="1554" y="1846.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="1940" y="1846.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="1966" y="1846.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="time_slot_scope_id" data-row-top="1872" data-row-height="28"><title>time_slot_scope_id BIGINT NOT NULL REFERENCES time_slot_scopes(id) ON DELETE CASCADE</title><rect x="1473" y="1872" width="510" height="28" fill="#f8fafc"/><text x="1484" y="1890.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK24</text><text x="1554" y="1890.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">time_slot_scope_id</text><text x="1940" y="1890.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="1966" y="1890.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="order_number" data-row-top="1900" data-row-height="28"><title>order_number INT NOT NULL</title><rect x="1473" y="1900" width="510" height="28" fill="#eef2f7"/><text x="1554" y="1918.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">order_number</text><text x="1940" y="1918.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">int</text><text x="1966" y="1918.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="start_time" data-row-top="1928" data-row-height="28"><title>start_time TIME NOT NULL</title><rect x="1473" y="1928" width="510" height="28" fill="#f8fafc"/><text x="1554" y="1946.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">start_time</text><text x="1940" y="1946.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">time</text><text x="1966" y="1946.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="end_time" data-row-top="1956" data-row-height="28"><title>end_time TIME NOT NULL</title><rect x="1473" y="1956" width="510" height="28" fill="#eef2f7"/><text x="1554" y="1974.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">end_time</text><text x="1940" y="1974.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">time</text><text x="1966" y="1974.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="duration_minutes" data-row-top="1984" data-row-height="28"><title>duration_minutes INT NOT NULL</title><rect x="1473" y="1984" width="510" height="28" fill="#f8fafc"/><text x="1554" y="2002.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">duration_minutes</text><text x="1940" y="2002.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">int</text><text x="1966" y="2002.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g></g><g class="entity" id="table-time_slot_date_assignments" data-table="time_slot_date_assignments" tabindex="0" role="button" aria-label="time_slot_date_assignments: Наборы звонков по датам"><title>time_slot_date_assignments: Наборы звонков по датам
3 столбцов · 1 исходящих и 0 входящих FK</title><rect class="table-box" x="1472" y="2124" width="512" height="148" rx="6"/><path d="M 1478 2124 H 1978 Q 1984 2124 1984 2130 V 2188 H 1472 V 2130 Q 1472 2124 1478 2124 Z" fill="#e8edf3"/><text x="1488" y="2150" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">time_slot_date_assignments</text><text x="1488" y="2172" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Наборы звонков по датам</text><g data-column="id" data-row-top="2188" data-row-height="28"><title>id BIGSERIAL PRIMARY KEY</title><rect x="1473" y="2188" width="510" height="28" fill="#eef2f7"/><text x="1484" y="2206.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="1554" y="2206.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="1940" y="2206.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="1966" y="2206.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="assignment_date" data-row-top="2216" data-row-height="28"><title>assignment_date DATE NOT NULL UNIQUE</title><rect x="1473" y="2216" width="510" height="28" fill="#f8fafc"/><text x="1484" y="2234.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">UQ</text><text x="1554" y="2234.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">assignment_date</text><text x="1940" y="2234.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="1966" y="2234.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="time_slot_scope_id" data-row-top="2244" data-row-height="28"><title>time_slot_scope_id BIGINT NOT NULL REFERENCES time_slot_scopes(id) ON DELETE CASCADE</title><rect x="1473" y="2244" width="510" height="28" fill="#eef2f7"/><text x="1484" y="2262.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK25</text><text x="1554" y="2262.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">time_slot_scope_id</text><text x="1940" y="2262.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="1966" y="2262.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g></g><g class="entity" id="table-academic_years" data-table="academic_years" tabindex="0" role="button" aria-label="academic_years: Учебные годы"><title>academic_years: Учебные годы
4 столбцов · 0 исходящих и 4 входящих FK</title><rect class="table-box" x="768" y="152" width="512" height="208" rx="6"/><path d="M 774 152 H 1274 Q 1280 152 1280 158 V 216 H 768 V 158 Q 768 152 774 152 Z" fill="#e8edf3"/><text x="784" y="178" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">academic_years</text><text x="784" y="200" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Учебные годы</text><g data-column="id" data-row-top="216" data-row-height="60"><title>id BIGSERIAL PRIMARY KEY</title><rect x="769" y="216" width="510" height="60" fill="#eef2f7"/><text x="780" y="250.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="850" y="250.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="1236" y="250.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="1262" y="250.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="title" data-row-top="276" data-row-height="28"><title>title VARCHAR(20) NOT NULL UNIQUE</title><rect x="769" y="276" width="510" height="28" fill="#f8fafc"/><text x="780" y="294.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">UQ</text><text x="850" y="294.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">title</text><text x="1236" y="294.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(20)</text><text x="1262" y="294.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="start_date" data-row-top="304" data-row-height="28"><title>start_date DATE NOT NULL</title><rect x="769" y="304" width="510" height="28" fill="#eef2f7"/><text x="850" y="322.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">start_date</text><text x="1236" y="322.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="1262" y="322.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="end_date" data-row-top="332" data-row-height="28"><title>end_date DATE NOT NULL</title><rect x="769" y="332" width="510" height="28" fill="#f8fafc"/><text x="850" y="350.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">end_date</text><text x="1236" y="350.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="1262" y="350.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g></g><g class="entity" id="table-semesters" data-table="semesters" tabindex="0" role="button" aria-label="semesters: Семестры"><title>semesters: Семестры
5 столбцов · 1 исходящих и 4 входящих FK</title><rect class="table-box" x="768" y="472" width="512" height="236" rx="6"/><path d="M 774 472 H 1274 Q 1280 472 1280 478 V 536 H 768 V 478 Q 768 472 774 472 Z" fill="#e8edf3"/><text x="784" y="498" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">semesters</text><text x="784" y="520" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Семестры</text><g data-column="id" data-row-top="536" data-row-height="60"><title>id BIGSERIAL PRIMARY KEY</title><rect x="769" y="536" width="510" height="60" fill="#eef2f7"/><text x="780" y="570.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="850" y="570.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="1236" y="570.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="1262" y="570.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="academic_year_id" data-row-top="596" data-row-height="28"><title>academic_year_id BIGINT NOT NULL REFERENCES academic_years(id) ON DELETE CASCADE</title><rect x="769" y="596" width="510" height="28" fill="#f8fafc"/><text x="780" y="614.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK27</text><text x="850" y="614.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">academic_year_id</text><text x="1236" y="614.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="1262" y="614.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="semester_type" data-row-top="624" data-row-height="28"><title>semester_type VARCHAR(20) NOT NULL</title><rect x="769" y="624" width="510" height="28" fill="#eef2f7"/><text x="850" y="642.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">semester_type</text><text x="1236" y="642.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(20)</text><text x="1262" y="642.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="start_date" data-row-top="652" data-row-height="28"><title>start_date DATE NOT NULL</title><rect x="769" y="652" width="510" height="28" fill="#f8fafc"/><text x="850" y="670.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">start_date</text><text x="1236" y="670.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="1262" y="670.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="end_date" data-row-top="680" data-row-height="28"><title>end_date DATE NOT NULL</title><rect x="769" y="680" width="510" height="28" fill="#eef2f7"/><text x="850" y="698.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">end_date</text><text x="1236" y="698.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="1262" y="698.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g></g><g class="entity" id="table-academic_calendar_activity_types" data-table="academic_calendar_activity_types" tabindex="0" role="button" aria-label="academic_calendar_activity_types: Виды учебной активности"><title>academic_calendar_activity_types: Виды учебной активности
7 столбцов · 0 исходящих и 1 входящих FK</title><rect class="table-box" x="768" y="1276" width="512" height="260" rx="6"/><path d="M 774 1276 H 1274 Q 1280 1276 1280 1282 V 1340 H 768 V 1282 Q 768 1276 774 1276 Z" fill="#e8edf3"/><text x="784" y="1302" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">academic_calendar_activity_types</text><text x="784" y="1324" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Виды учебной активности</text><g data-column="id" data-row-top="1340" data-row-height="28"><title>id BIGSERIAL PRIMARY KEY</title><rect x="769" y="1340" width="510" height="28" fill="#eef2f7"/><text x="780" y="1358.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="850" y="1358.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="1236" y="1358.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="1262" y="1358.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="code" data-row-top="1368" data-row-height="28"><title>code VARCHAR(10) UNIQUE NOT NULL</title><rect x="769" y="1368" width="510" height="28" fill="#f8fafc"/><text x="780" y="1386.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">UQ</text><text x="850" y="1386.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">code</text><text x="1236" y="1386.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(10)</text><text x="1262" y="1386.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="name" data-row-top="1396" data-row-height="28"><title>name VARCHAR(255) NOT NULL</title><rect x="769" y="1396" width="510" height="28" fill="#eef2f7"/><text x="850" y="1414.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">name</text><text x="1236" y="1414.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(255)</text><text x="1262" y="1414.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="allow_schedule" data-row-top="1424" data-row-height="28"><title>allow_schedule BOOLEAN NOT NULL DEFAULT FALSE</title><rect x="769" y="1424" width="510" height="28" fill="#f8fafc"/><text x="850" y="1442.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">allow_schedule</text><text x="1236" y="1442.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">boolean</text><text x="1262" y="1442.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="color_code" data-row-top="1452" data-row-height="28"><title>color_code VARCHAR(7) NOT NULL DEFAULT &#x27;#64748b&#x27;</title><rect x="769" y="1452" width="510" height="28" fill="#eef2f7"/><text x="850" y="1470.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">color_code</text><text x="1236" y="1470.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(7)</text><text x="1262" y="1470.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="display_order" data-row-top="1480" data-row-height="28"><title>display_order INT NOT NULL DEFAULT 100</title><rect x="769" y="1480" width="510" height="28" fill="#f8fafc"/><text x="850" y="1498.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">display_order</text><text x="1236" y="1498.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">int</text><text x="1262" y="1498.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="description" data-row-top="1508" data-row-height="28"><title>description TEXT</title><rect x="769" y="1508" width="510" height="28" fill="#eef2f7"/><text x="850" y="1526.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">description</text><text x="1236" y="1526.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">text</text><text x="1262" y="1526.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g></g><g class="entity" id="table-academic_calendars" data-table="academic_calendars" tabindex="0" role="button" aria-label="academic_calendars: Учебные календари"><title>academic_calendars: Учебные календари
9 столбцов · 4 исходящих и 3 входящих FK</title><rect class="table-box" x="768" y="820" width="512" height="344" rx="6"/><path d="M 774 820 H 1274 Q 1280 820 1280 826 V 884 H 768 V 826 Q 768 820 774 820 Z" fill="#e8edf3"/><text x="784" y="846" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">academic_calendars</text><text x="784" y="868" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Учебные календари</text><g data-column="id" data-row-top="884" data-row-height="48"><title>id BIGSERIAL PRIMARY KEY</title><rect x="769" y="884" width="510" height="48" fill="#eef2f7"/><text x="780" y="912.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="850" y="912.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="1236" y="912.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="1262" y="912.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="title" data-row-top="932" data-row-height="28"><title>title VARCHAR(255) NOT NULL</title><rect x="769" y="932" width="510" height="28" fill="#f8fafc"/><text x="850" y="950.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">title</text><text x="1236" y="950.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(255)</text><text x="1262" y="950.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="academic_year_id" data-row-top="960" data-row-height="28"><title>academic_year_id BIGINT NOT NULL REFERENCES academic_years(id) ON DELETE CASCADE</title><rect x="769" y="960" width="510" height="28" fill="#eef2f7"/><text x="780" y="978.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK28</text><text x="850" y="978.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">academic_year_id</text><text x="1236" y="978.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="1262" y="978.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="specialty_id" data-row-top="988" data-row-height="36"><title>specialty_id BIGINT NOT NULL REFERENCES specialties(id)</title><rect x="769" y="988" width="510" height="36" fill="#f8fafc"/><text x="780" y="1010.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK29·FK31</text><text x="850" y="1010.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">specialty_id</text><text x="1236" y="1010.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="1262" y="1010.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="specialty_profile_id" data-row-top="1024" data-row-height="28"><title>specialty_profile_id BIGINT NOT NULL</title><rect x="769" y="1024" width="510" height="28" fill="#eef2f7"/><text x="780" y="1042.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK31</text><text x="850" y="1042.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">specialty_profile_id</text><text x="1236" y="1042.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="1262" y="1042.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="study_form_id" data-row-top="1052" data-row-height="28"><title>study_form_id BIGINT NOT NULL REFERENCES education_forms(id)</title><rect x="769" y="1052" width="510" height="28" fill="#f8fafc"/><text x="780" y="1070.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK30</text><text x="850" y="1070.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">study_form_id</text><text x="1236" y="1070.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="1262" y="1070.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="course_count" data-row-top="1080" data-row-height="28"><title>course_count INT NOT NULL DEFAULT 4</title><rect x="769" y="1080" width="510" height="28" fill="#eef2f7"/><text x="850" y="1098.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">course_count</text><text x="1236" y="1098.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">int</text><text x="1262" y="1098.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><Line truncated
6 столбцов · 2 исходящих и 0 входящих FK</title><rect class="table-box" x="768" y="1648" width="512" height="232" rx="6"/><path d="M 774 1648 H 1274 Q 1280 1648 1280 1654 V 1712 H 768 V 1654 Q 768 1648 774 1648 Z" fill="#e8edf3"/><text x="784" y="1674" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">academic_calendar_periods</text><text x="784" y="1696" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Календарные периоды</text><g data-column="id" data-row-top="1712" data-row-height="28"><title>id BIGSERIAL PRIMARY KEY</title><rect x="769" y="1712" width="510" height="28" fill="#eef2f7"/><text x="780" y="1730.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="850" y="1730.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="1236" y="1730.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="1262" y="1730.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="calendar_id" data-row-top="1740" data-row-height="28"><title>calendar_id BIGINT NOT NULL REFERENCES academic_calendars(id) ON DELETE CASCADE</title><rect x="769" y="1740" width="510" height="28" fill="#f8fafc"/><text x="780" y="1758.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK32</text><text x="850" y="1758.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">calendar_id</text><text x="1236" y="1758.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="1262" y="1758.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="course_number" data-row-top="1768" data-row-height="28"><title>course_number INT NOT NULL</title><rect x="769" y="1768" width="510" height="28" fill="#eef2f7"/><text x="850" y="1786.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">course_number</text><text x="1236" y="1786.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">int</text><text x="1262" y="1786.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="start_date" data-row-top="1796" data-row-height="28"><title>start_date DATE NOT NULL</title><rect x="769" y="1796" width="510" height="28" fill="#f8fafc"/><text x="850" y="1814.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">start_date</text><text x="1236" y="1814.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="1262" y="1814.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="end_date" data-row-top="1824" data-row-height="28"><title>end_date DATE NOT NULL</title><rect x="769" y="1824" width="510" height="28" fill="#eef2f7"/><text x="850" y="1842.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">end_date</text><text x="1236" y="1842.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="1262" y="1842.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="activity_type_id" data-row-top="1852" data-row-height="28"><title>activity_type_id BIGINT NOT NULL REFERENCES academic_calendar_activity_types(id)</title><rect x="769" y="1852" width="510" height="28" fill="#f8fafc"/><text x="780" y="1870.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK33</text><text x="850" y="1870.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">activity_type_id</text><text x="1236" y="1870.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="1262" y="1870.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g></g><g class="entity" id="table-academic_calendar_subjects" data-table="academic_calendar_subjects" tabindex="0" role="button" aria-label="academic_calendar_subjects: Дисциплины календаря"><title>academic_calendar_subjects: Дисциплины календаря
5 столбцов · 2 исходящих и 0 входящих FK</title><rect class="table-box" x="768" y="1992" width="512" height="204" rx="6"/><path d="M 774 1992 H 1274 Q 1280 1992 1280 1998 V 2056 H 768 V 1998 Q 768 1992 774 1992 Z" fill="#e8edf3"/><text x="784" y="2018" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">academic_calendar_subjects</text><text x="784" y="2040" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Дисциплины календаря</text><g data-column="id" data-row-top="2056" data-row-height="28"><title>id BIGSERIAL PRIMARY KEY</title><rect x="769" y="2056" width="510" height="28" fill="#eef2f7"/><text x="780" y="2074.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="850" y="2074.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="1236" y="2074.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="1262" y="2074.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="calendar_id" data-row-top="2084" data-row-height="28"><title>calendar_id BIGINT NOT NULL REFERENCES academic_calendars(id) ON DELETE CASCADE</title><rect x="769" y="2084" width="510" height="28" fill="#f8fafc"/><text x="780" y="2102.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK34</text><text x="850" y="2102.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">calendar_id</text><text x="1236" y="2102.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="1262" y="2102.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="semester_number" data-row-top="2112" data-row-height="28"><title>semester_number INT NOT NULL</title><rect x="769" y="2112" width="510" height="28" fill="#eef2f7"/><text x="850" y="2130.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">semester_number</text><text x="1236" y="2130.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">int</text><text x="1262" y="2130.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="subject_id" data-row-top="2140" data-row-height="28"><title>subject_id BIGINT NOT NULL REFERENCES subjects(id)</title><rect x="769" y="2140" width="510" height="28" fill="#f8fafc"/><text x="780" y="2158.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK35</text><text x="850" y="2158.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">subject_id</text><text x="1236" y="2158.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="1262" y="2158.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="created_at" data-row-top="2168" data-row-height="28"><title>created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP</title><rect x="769" y="2168" width="510" height="28" fill="#eef2f7"/><text x="850" y="2186.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">created_at</text><text x="1236" y="2186.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">timestamptz</text><text x="1262" y="2186.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g></g><g class="entity" id="table-student_group_calendar_assignments" data-table="student_group_calendar_assignments" tabindex="0" role="button" aria-label="student_group_calendar_assignments: Назначения календарей группам"><title>student_group_calendar_assignments: Назначения календарей группам
5 столбцов · 3 исходящих и 0 входящих FK</title><rect class="table-box" x="768" y="2308" width="512" height="204" rx="6"/><path d="M 774 2308 H 1274 Q 1280 2308 1280 2314 V 2372 H 768 V 2314 Q 768 2308 774 2308 Z" fill="#e8edf3"/><text x="784" y="2334" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">student_group_calendar_assignments</text><text x="784" y="2356" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Назначения календарей группам</text><g data-column="id" data-row-top="2372" data-row-height="28"><title>id BIGSERIAL PRIMARY KEY</title><rect x="769" y="2372" width="510" height="28" fill="#eef2f7"/><text x="780" y="2390.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="850" y="2390.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="1236" y="2390.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="1262" y="2390.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="group_id" data-row-top="2400" data-row-height="28"><title>group_id BIGINT NOT NULL REFERENCES student_groups(id) ON DELETE CASCADE</title><rect x="769" y="2400" width="510" height="28" fill="#f8fafc"/><text x="780" y="2418.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK36</text><text x="850" y="2418.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">group_id</text><text x="1236" y="2418.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="1262" y="2418.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="academic_year_id" data-row-top="2428" data-row-height="28"><title>academic_year_id BIGINT NOT NULL REFERENCES academic_years(id) ON DELETE CASCADE</title><rect x="769" y="2428" width="510" height="28" fill="#eef2f7"/><text x="780" y="2446.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK37</text><text x="850" y="2446.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">academic_year_id</text><text x="1236" y="2446.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="1262" y="2446.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="calendar_id" data-row-top="2456" data-row-height="28"><title>calendar_id BIGINT NOT NULL REFERENCES academic_calendars(id) ON DELETE CASCADE</title><rect x="769" y="2456" width="510" height="28" fill="#f8fafc"/><text x="780" y="2474.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK38</text><text x="850" y="2474.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">calendar_id</text><text x="1236" y="2474.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="1262" y="2474.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="created_at" data-row-top="2484" data-row-height="28"><title>created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP</title><rect x="769" y="2484" width="510" height="28" fill="#eef2f7"/><text x="850" y="2502.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">created_at</text><text x="1236" y="2502.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">timestamptz</text><text x="1262" y="2502.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g></g><g class="entity" id="table-schedule_rules" data-table="schedule_rules" tabindex="0" role="button" aria-label="schedule_rules: Правила расписания"><title>schedule_rules: Правила расписания
12 столбцов · 4 исходящих и 3 входящих FK</title><rect class="table-box" x="2880" y="1068" width="512" height="420" rx="6"/><path d="M 2886 1068 H 3386 Q 3392 1068 3392 1074 V 1132 H 2880 V 1074 Q 2880 1068 2886 1068 Z" fill="#eeedff"/><text x="2896" y="1094" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">schedule_rules</text><text x="2896" y="1116" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Правила расписания</text><g data-column="id" data-row-top="1132" data-row-height="48"><title>id BIGSERIAL PRIMARY KEY</title><rect x="2881" y="1132" width="510" height="48" fill="#eef2f7"/><text x="2892" y="1160.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="2962" y="1160.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="3348" y="1160.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="3374" y="1160.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="load_revision" data-row-top="1180" data-row-height="28"><title>load_revision BIGINT NOT NULL DEFAULT 0</title><rect x="2881" y="1180" width="510" height="28" fill="#f8fafc"/><text x="2962" y="1198.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">load_revision</text><text x="3348" y="1198.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="3374" y="1198.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="subject_id" data-row-top="1208" data-row-height="28"><title>subject_id BIGINT NOT NULL REFERENCES subjects(id)</title><rect x="2881" y="1208" width="510" height="28" fill="#eef2f7"/><text x="2892" y="1226.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK39</text><text x="2962" y="1226.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">subject_id</text><text x="3348" y="1226.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="3374" y="1226.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="semester_id" data-row-top="1236" data-row-height="28"><title>semester_id BIGINT NOT NULL REFERENCES semesters(id) ON DELETE CASCADE</title><rect x="2881" y="1236" width="510" height="28" fill="#f8fafc"/><text x="2892" y="1254.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK40·FK84</text><text x="2962" y="1254.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">semester_id</text><text x="3348" y="1254.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="3374" y="1254.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="status" data-row-top="1264" data-row-height="28"><title>status VARCHAR(20) NOT NULL DEFAULT &#x27;ACTIVE&#x27;</title><rect x="2881" y="1264" width="510" height="28" fill="#eef2f7"/><text x="2962" y="1282.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">status</text><text x="3348" y="1282.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(20)</text><text x="3374" y="1282.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="valid_from" data-row-top="1292" data-row-height="28"><title>valid_from DATE</title><rect x="2881" y="1292" width="510" height="28" fill="#f8fafc"/><text x="2962" y="1310.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">valid_from</text><text x="3348" y="1310.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="3374" y="1310.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="valid_to" data-row-top="1320" data-row-height="28"><title>valid_to DATE</title><rect x="2881" y="1320" width="510" height="28" fill="#eef2f7"/><text x="2962" y="1338.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">valid_to</text><text x="3348" y="1338.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="3374" y="1338.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="version_group_id" data-row-top="1348" data-row-height="28"><title>version_group_id BIGINT</title><rect x="2881" y="1348" width="510" height="28" fill="#f8fafc"/><text x="2962" y="1366.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" clasLine truncated
4 столбцов · 2 исходящих и 0 входящих FK</title><rect class="table-box" x="2880" y="1600" width="512" height="176" rx="6"/><path d="M 2886 1600 H 3386 Q 3392 1600 3392 1606 V 1664 H 2880 V 1606 Q 2880 1600 2886 1600 Z" fill="#e8edf3"/><text x="2896" y="1626" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">schedule_rule_loads</text><text x="2896" y="1648" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Нагрузка правила по видам занятий</text><g data-column="schedule_rule_id" data-row-top="1664" data-row-height="28"><title>schedule_rule_id BIGINT NOT NULL REFERENCES schedule_rules(id) ON DELETE CASCADE</title><rect x="2881" y="1664" width="510" height="28" fill="#eef2f7"/><text x="2892" y="1682.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK·FK42</text><text x="2962" y="1682.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">schedule_rule_id</text><text x="3348" y="1682.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="3374" y="1682.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="lesson_type_code" data-row-top="1692" data-row-height="28"><title>lesson_type_code VARCHAR(30) NOT NULL REFERENCES lesson_types(code)</title><rect x="2881" y="1692" width="510" height="28" fill="#f8fafc"/><text x="2892" y="1710.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK·FK43</text><text x="2962" y="1710.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">lesson_type_code</text><text x="3348" y="1710.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(30)</text><text x="3374" y="1710.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="academic_hours" data-row-top="1720" data-row-height="28"><title>academic_hours INT NOT NULL</title><rect x="2881" y="1720" width="510" height="28" fill="#eef2f7"/><text x="2962" y="1738.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">academic_hours</text><text x="3348" y="1738.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">int</text><text x="3374" y="1738.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="start_week" data-row-top="1748" data-row-height="28"><title>start_week INT NOT NULL DEFAULT 1</title><rect x="2881" y="1748" width="510" height="28" fill="#f8fafc"/><text x="2962" y="1766.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">start_week</text><text x="3348" y="1766.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">int</text><text x="3374" y="1766.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g></g><g class="entity" id="table-schedule_rule_groups" data-table="schedule_rule_groups" tabindex="0" role="button" aria-label="schedule_rule_groups: Группы правила"><title>schedule_rule_groups: Группы правила
2 столбцов · 2 исходящих и 0 входящих FK</title><rect class="table-box" x="2880" y="1888" width="512" height="120" rx="6"/><path d="M 2886 1888 H 3386 Q 3392 1888 3392 1894 V 1952 H 2880 V 1894 Q 2880 1888 2886 1888 Z" fill="#e8edf3"/><text x="2896" y="1914" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">schedule_rule_groups</text><text x="2896" y="1936" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Группы правила</text><g data-column="schedule_rule_id" data-row-top="1952" data-row-height="28"><title>schedule_rule_id BIGINT NOT NULL REFERENCES schedule_rules(id) ON DELETE CASCADE</title><rect x="2881" y="1952" width="510" height="28" fill="#eef2f7"/><text x="2892" y="1970.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK·FK44</text><text x="2962" y="1970.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">schedule_rule_id</text><text x="3348" y="1970.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="3374" y="1970.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="group_id" data-row-top="1980" data-row-height="28"><title>group_id BIGINT NOT NULL REFERENCES student_groups(id) ON DELETE CASCADE</title><rect x="2881" y="1980" width="510" height="28" fill="#f8fafc"/><text x="2892" y="1998.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK·FK45</text><text x="2962" y="1998.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">group_id</text><text x="3348" y="1998.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="3374" y="1998.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g></g><g class="entity" id="table-schedule_rule_slots" data-table="schedule_rule_slots" tabindex="0" role="button" aria-label="schedule_rule_slots: Повторяющиеся занятия"><title>schedule_rule_slots: Повторяющиеся занятия
15 столбцов · 6 исходящих и 4 входящих FK</title><rect class="table-box" x="2880" y="2120" width="512" height="516" rx="6"/><path d="M 2886 2120 H 3386 Q 3392 2120 3392 2126 V 2184 H 2880 V 2126 Q 2880 2120 2886 2120 Z" fill="#e8edf3"/><text x="2896" y="2146" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">schedule_rule_slots</text><text x="2896" y="2168" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Повторяющиеся занятия</text><g data-column="id" data-row-top="2184" data-row-height="60"><title>id BIGSERIAL PRIMARY KEY</title><rect x="2881" y="2184" width="510" height="60" fill="#eef2f7"/><text x="2892" y="2218.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="2962" y="2218.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="3348" y="2218.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="3374" y="2218.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="schedule_rule_id" data-row-top="2244" data-row-height="28"><title>schedule_rule_id BIGINT NOT NULL REFERENCES schedule_rules(id) ON DELETE CASCADE</title><rect x="2881" y="2244" width="510" height="28" fill="#f8fafc"/><text x="2892" y="2262.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK46</text><text x="2962" y="2262.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">schedule_rule_id</text><text x="3348" y="2262.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="3374" y="2262.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="day_of_week" data-row-top="2272" data-row-height="28"><title>day_of_week INT NOT NULL</title><rect x="2881" y="2272" width="510" height="28" fill="#eef2f7"/><text x="2962" y="2290.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">day_of_week</text><text x="3348" y="2290.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">int</text><text x="3374" y="2290.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="parity" data-row-top="2300" data-row-height="28"><title>parity VARCHAR(10) NOT NULL</title><rect x="2881" y="2300" width="510" height="28" fill="#f8fafc"/><text x="2962" y="2318.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">parity</text><text x="3348" y="2318.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(10)</text><text x="3374" y="2318.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="time_slot_id" data-row-top="2328" data-row-height="28"><title>time_slot_id BIGINT NOT NULL REFERENCES time_slots(id)</title><rect x="2881" y="2328" width="510" height="28" fill="#eef2f7"/><text x="2892" y="2346.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK47</text><text x="2962" y="2346.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">time_slot_id</text><text x="3348" y="2346.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="3374" y="2346.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="teacher_id" data-row-top="2356" data-row-height="28"><title>teacher_id BIGINT NOT NULL REFERENCES users(id)</title><rect x="2881" y="2356" width="510" height="28" fill="#f8fafc"/><text x="2892" y="2374.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK48</text><text x="2962" y="2374.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">teacher_id</text><text x="3348" y="2374.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="3374" y="2374.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="classroom_id" data-row-top="2384" data-row-height="28"><title>classroom_id BIGINT NOT NULL REFERENCES classrooms(id)</title><rect x="2881" y="2384" width="510" height="28" fill="#eef2f7"/><text x="2892" y="2402.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK49</text><text x="2962" y="2402.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">classroom_id</text><text x="3348" y="2402.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="3374" y="2402.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle"Line truncated
2 столбцов · 2 исходящих и 0 входящих FK</title><rect class="table-box" x="2880" y="2748" width="512" height="120" rx="6"/><path d="M 2886 2748 H 3386 Q 3392 2748 3392 2754 V 2812 H 2880 V 2754 Q 2880 2748 2886 2748 Z" fill="#e8edf3"/><text x="2896" y="2774" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">schedule_rule_slot_subgroups</text><text x="2896" y="2796" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Подгруппы занятия</text><g data-column="schedule_rule_slot_id" data-row-top="2812" data-row-height="28"><title>schedule_rule_slot_id BIGINT NOT NULL REFERENCES schedule_rule_slots(id) ON DELETE CASCADE</title><rect x="2881" y="2812" width="510" height="28" fill="#eef2f7"/><text x="2892" y="2830.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK·FK52</text><text x="2962" y="2830.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">schedule_rule_slot_id</text><text x="3348" y="2830.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="3374" y="2830.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="subgroup_id" data-row-top="2840" data-row-height="28"><title>subgroup_id BIGINT NOT NULL REFERENCES subgroups(id) ON DELETE CASCADE</title><rect x="2881" y="2840" width="510" height="28" fill="#f8fafc"/><text x="2892" y="2858.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK·FK53</text><text x="2962" y="2858.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">subgroup_id</text><text x="3348" y="2858.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="3374" y="2858.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g></g><g class="entity" id="table-schedule_overrides" data-table="schedule_overrides" tabindex="0" role="button" aria-label="schedule_overrides: Точечные изменения занятий"><title>schedule_overrides: Точечные изменения занятий
12 столбцов · 5 исходящих и 2 входящих FK</title><rect class="table-box" x="4288" y="1716" width="512" height="408" rx="6"/><path d="M 4294 1716 H 4794 Q 4800 1716 4800 1722 V 1780 H 4288 V 1722 Q 4288 1716 4294 1716 Z" fill="#e8edf3"/><text x="4304" y="1742" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">schedule_overrides</text><text x="4304" y="1764" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Точечные изменения занятий</text><g data-column="id" data-row-top="1780" data-row-height="36"><title>id BIGSERIAL PRIMARY KEY</title><rect x="4289" y="1780" width="510" height="36" fill="#eef2f7"/><text x="4300" y="1802.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="4370" y="1802.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="4756" y="1802.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="4782" y="1802.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="base_rule_slot_id" data-row-top="1816" data-row-height="28"><title>base_rule_slot_id BIGINT NOT NULL REFERENCES schedule_rule_slots(id)</title><rect x="4289" y="1816" width="510" height="28" fill="#f8fafc"/><text x="4300" y="1834.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK54</text><text x="4370" y="1834.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">base_rule_slot_id</text><text x="4756" y="1834.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="4782" y="1834.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="lesson_date" data-row-top="1844" data-row-height="28"><title>lesson_date DATE NOT NULL</title><rect x="4289" y="1844" width="510" height="28" fill="#eef2f7"/><text x="4370" y="1862.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">lesson_date</text><text x="4756" y="1862.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="4782" y="1862.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="target_lesson_date" data-row-top="1872" data-row-height="28"><title>target_lesson_date DATE</title><rect x="4289" y="1872" width="510" height="28" fill="#f8fafc"/><text x="4370" y="1890.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">target_lesson_date</text><text x="4756" y="1890.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="4782" y="1890.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="action" data-row-top="1900" data-row-height="28"><title>action VARCHAR(20) NOT NULL</title><rect x="4289" y="1900" width="510" height="28" fill="#eef2f7"/><text x="4370" y="1918.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">action</text><text x="4756" y="1918.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(20)</text><text x="4782" y="1918.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="new_time_slot_id" data-row-top="1928" data-row-height="28"><title>new_time_slot_id BIGINT REFERENCES time_slots(id)</title><rect x="4289" y="1928" width="510" height="28" fill="#f8fafc"/><text x="4300" y="1946.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK55</text><text x="4370" y="1946.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">new_time_slot_id</text><text x="4756" y="1946.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="4782" y="1946.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="new_classroom_id" data-row-top="1956" data-row-height="28"><title>new_classroom_id BIGINT REFERENCES classrooms(id)</title><rect x="4289" y="1956" width="510" height="28" fill="#eef2f7"/><text x="4300" y="1974.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK56</text><text x="4370" y="1974.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">new_classroom_id</text><text x="4756" y="1974.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="4782" y="1974.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="new_teacher_id" data-row-top="1984" data-row-height="28"><title>new_teacher_iLine truncated
12 столбцов · 3 исходящих и 1 входящих FK</title><rect class="table-box" x="4288" y="2236" width="512" height="400" rx="6"/><path d="M 4294 2236 H 4794 Q 4800 2236 4800 2242 V 2300 H 4288 V 2242 Q 4288 2236 4294 2236 Z" fill="#e8edf3"/><text x="4304" y="2262" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">teacher_absences</text><text x="4304" y="2284" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Отсутствия преподавателей</text><g data-column="id" data-row-top="2300" data-row-height="28"><title>id BIGSERIAL PRIMARY KEY</title><rect x="4289" y="2300" width="510" height="28" fill="#eef2f7"/><text x="4300" y="2318.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="4370" y="2318.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="4756" y="2318.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="4782" y="2318.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="teacher_id" data-row-top="2328" data-row-height="28"><title>teacher_id BIGINT NOT NULL REFERENCES users(id)</title><rect x="4289" y="2328" width="510" height="28" fill="#f8fafc"/><text x="4300" y="2346.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK59</text><text x="4370" y="2346.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">teacher_id</text><text x="4756" y="2346.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="4782" y="2346.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="start_date" data-row-top="2356" data-row-height="28"><title>start_date DATE NOT NULL</title><rect x="4289" y="2356" width="510" height="28" fill="#eef2f7"/><text x="4370" y="2374.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">start_date</text><text x="4756" y="2374.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="4782" y="2374.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="end_date" data-row-top="2384" data-row-height="28"><title>end_date DATE NOT NULL</title><rect x="4289" y="2384" width="510" height="28" fill="#f8fafc"/><text x="4370" y="2402.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">end_date</text><text x="4756" y="2402.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="4782" y="2402.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="reason" data-row-top="2412" data-row-height="28"><title>reason TEXT NOT NULL</title><rect x="4289" y="2412" width="510" height="28" fill="#eef2f7"/><text x="4370" y="2430.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">reason</text><text x="4756" y="2430.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">text</text><text x="4782" y="2430.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="status" data-row-top="2440" data-row-height="28"><title>status VARCHAR(20) NOT NULL</title><rect x="4289" y="2440" width="510" height="28" fill="#f8fafc"/><text x="4370" y="2458.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">status</text><text x="4756" y="2458.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(20)</text><text x="4782" y="2458.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="requested_by" data-row-top="2468" data-row-height="28"><title>requested_by BIGINT REFERENCES users(id)</title><rect x="4289" y="2468" width="510" height="28" fill="#eef2f7"/><text x="4300" y="2486.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK60</text><text x="4370" y="2486.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">requested_by</text><text x="4756" y="2486.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="4782" y="2486.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="reviewed_by" data-row-top="2496" data-row-height="28"><title>reviewed_by BIGINT REFERENCES users(id)</title><rect x="4289" y="2496" width="510" height="28" fill="#f8fafc"/><text x="4300" y="2514.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK61</text><text x="4370" y="2514.0" font-sizeLine truncated
10 столбцов · 4 исходящих и 0 входящих FK</title><rect class="table-box" x="4288" y="2748" width="512" height="344" rx="6"/><path d="M 4294 2748 H 4794 Q 4800 2748 4800 2754 V 2812 H 4288 V 2754 Q 4288 2748 4294 2748 Z" fill="#e8edf3"/><text x="4304" y="2774" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">teacher_absence_decisions</text><text x="4304" y="2796" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Решения мастера замены</text><g data-column="id" data-row-top="2812" data-row-height="28"><title>id BIGSERIAL PRIMARY KEY</title><rect x="4289" y="2812" width="510" height="28" fill="#eef2f7"/><text x="4300" y="2830.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="4370" y="2830.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="4756" y="2830.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="4782" y="2830.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="absence_id" data-row-top="2840" data-row-height="28"><title>absence_id BIGINT NOT NULL REFERENCES teacher_absences(id) ON DELETE CASCADE</title><rect x="4289" y="2840" width="510" height="28" fill="#f8fafc"/><text x="4300" y="2858.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK62</text><text x="4370" y="2858.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">absence_id</text><text x="4756" y="2858.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="4782" y="2858.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="base_rule_slot_id" data-row-top="2868" data-row-height="28"><title>base_rule_slot_id BIGINT NOT NULL REFERENCES schedule_rule_slots(id)</title><rect x="4289" y="2868" width="510" height="28" fill="#eef2f7"/><text x="4300" y="2886.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK63</text><text x="4370" y="2886.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">base_rule_slot_id</text><text x="4756" y="2886.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="4782" y="2886.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="lesson_date" data-row-top="2896" data-row-height="28"><title>lesson_date DATE NOT NULL</title><rect x="4289" y="2896" width="510" height="28" fill="#f8fafc"/><text x="4370" y="2914.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">lesson_date</text><text x="4756" y="2914.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="4782" y="2914.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="resolution" data-row-top="2924" data-row-height="28"><title>resolution VARCHAR(30) NOT NULL</title><rect x="4289" y="2924" width="510" height="28" fill="#eef2f7"/><text x="4370" y="2942.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">resolution</text><text x="4756" y="2942.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(30)</text><text x="4782" y="2942.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="decision_status" data-row-top="2952" data-row-height="28"><title>decision_status VARCHAR(20) NOT NULL</title><rect x="4289" y="2952" width="510" height="28" fill="#f8fafc"/><text x="4370" y="2970.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">decision_status</text><text x="4756" y="2970.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(20)</text><text x="4782" y="2970.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="schedule_override_id" data-row-top="2980" data-row-height="28"><title>schedule_override_id BIGINT REFERENCES schedule_overrides(id) ON DELETE SET NULL</title><rect x="4289" y="2980" width="510" height="28" fill="#eef2f7"/><text x="4300" y="2998.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK64</text><text x="4370" y="2998.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">schedule_override_id</text><text x="4756" y="2998.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="4782" y="2998.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-columnLine truncated
15 столбцов · 5 исходящих и 0 входящих FK</title><rect class="table-box" x="4288" y="152" width="512" height="484" rx="6"/><path d="M 4294 152 H 4794 Q 4800 152 4800 158 V 216 H 4288 V 158 Q 4288 152 4294 152 Z" fill="#e8edf3"/><text x="4304" y="178" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">teacher_preferences</text><text x="4304" y="200" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Пожелания преподавателей</text><g data-column="id" data-row-top="216" data-row-height="28"><title>id BIGSERIAL PRIMARY KEY</title><rect x="4289" y="216" width="510" height="28" fill="#eef2f7"/><text x="4300" y="234.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="4370" y="234.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="4756" y="234.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="4782" y="234.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="teacher_id" data-row-top="244" data-row-height="28"><title>teacher_id BIGINT NOT NULL REFERENCES users(id)</title><rect x="4289" y="244" width="510" height="28" fill="#f8fafc"/><text x="4300" y="262.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK66</text><text x="4370" y="262.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">teacher_id</text><text x="4756" y="262.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="4782" y="262.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="semester_id" data-row-top="272" data-row-height="28"><title>semester_id BIGINT NOT NULL REFERENCES semesters(id)</title><rect x="4289" y="272" width="510" height="28" fill="#eef2f7"/><text x="4300" y="290.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK67</text><text x="4370" y="290.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">semester_id</text><text x="4756" y="290.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="4782" y="290.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="preference_type" data-row-top="300" data-row-height="28"><title>preference_type VARCHAR(30) NOT NULL</title><rect x="4289" y="300" width="510" height="28" fill="#f8fafc"/><text x="4370" y="318.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">preference_type</text><text x="4756" y="318.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(30)</text><text x="4782" y="318.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="day_of_week" data-row-top="328" data-row-height="28"><title>day_of_week SMALLINT</title><rect x="4289" y="328" width="510" height="28" fill="#eef2f7"/><text x="4370" y="346.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">day_of_week</text><text x="4756" y="346.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">smallint</text><text x="4782" y="346.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="time_slot_id" data-row-top="356" data-row-height="28"><title>time_slot_id BIGINT REFERENCES time_slots(id)</title><rect x="4289" y="356" width="510" height="28" fill="#f8fafc"/><text x="4300" y="374.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK68</text><text x="4370" y="374.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">time_slot_id</text><text x="4756" y="374.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="4782" y="374.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="preference_date" data-row-top="384" data-row-height="28"><title>preference_date DATE</title><rect x="4289" y="384" width="510" height="28" fill="#eef2f7"/><text x="4370" y="402.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">preference_date</text><text x="4756" y="402.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="4782" y="402.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="comment" data-row-top="412" data-row-height="28"><title>comment TEXT</title><rect x="4289" y="412" width="510" height="28" fill="#f8fafc"/><text x="4370" y="430.0" fLine truncated
16 столбцов · 6 исходящих и 1 входящих FK</title><rect class="table-box" x="4288" y="748" width="512" height="512" rx="6"/><path d="M 4294 748 H 4794 Q 4800 748 4800 754 V 812 H 4288 V 754 Q 4288 748 4294 748 Z" fill="#e8edf3"/><text x="4304" y="774" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">teacher_change_requests</text><text x="4304" y="796" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Заявки на изменение занятия</text><g data-column="id" data-row-top="812" data-row-height="28"><title>id BIGSERIAL PRIMARY KEY</title><rect x="4289" y="812" width="510" height="28" fill="#eef2f7"/><text x="4300" y="830.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="4370" y="830.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="4756" y="830.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="4782" y="830.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="teacher_id" data-row-top="840" data-row-height="28"><title>teacher_id BIGINT NOT NULL REFERENCES users(id)</title><rect x="4289" y="840" width="510" height="28" fill="#f8fafc"/><text x="4300" y="858.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK71</text><text x="4370" y="858.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">teacher_id</text><text x="4756" y="858.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="4782" y="858.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="base_rule_slot_id" data-row-top="868" data-row-height="28"><title>base_rule_slot_id BIGINT NOT NULL REFERENCES schedule_rule_slots(id)</title><rect x="4289" y="868" width="510" height="28" fill="#eef2f7"/><text x="4300" y="886.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK72</text><text x="4370" y="886.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">base_rule_slot_id</text><text x="4756" y="886.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="4782" y="886.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="lesson_date" data-row-top="896" data-row-height="28"><title>lesson_date DATE NOT NULL</title><rect x="4289" y="896" width="510" height="28" fill="#f8fafc"/><text x="4370" y="914.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">lesson_date</text><text x="4756" y="914.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="4782" y="914.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="request_type" data-row-top="924" data-row-height="28"><title>request_type VARCHAR(30) NOT NULL</title><rect x="4289" y="924" width="510" height="28" fill="#eef2f7"/><text x="4370" y="942.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">request_type</text><text x="4756" y="942.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(30)</text><text x="4782" y="942.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="target_lesson_date" data-row-top="952" data-row-height="28"><title>target_lesson_date DATE</title><rect x="4289" y="952" width="510" height="28" fill="#f8fafc"/><text x="4370" y="970.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">target_lesson_date</text><text x="4756" y="970.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">date</text><text x="4782" y="970.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="requested_time_slot_id" data-row-top="980" data-row-height="28"><title>requested_time_slot_id BIGINT REFERENCES time_slots(id)</title><rect x="4289" y="980" width="510" height="28" fill="#eef2f7"/><text x="4300" y="998.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK73</text><text x="4370" y="998.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">requested_time_slot_id</text><text x="4756" y="998.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="4782" y="998.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="requested_classroom_id" data-row-top="1008" data-row-height="28"><title>requested_classroom_id BIGLine truncated
6 столбцов · 2 исходящих и 0 входящих FK</title><rect class="table-box" x="4288" y="1372" width="512" height="232" rx="6"/><path d="M 4294 1372 H 4794 Q 4800 1372 4800 1378 V 1436 H 4288 V 1378 Q 4288 1372 4294 1372 Z" fill="#e8edf3"/><text x="4304" y="1398" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">teacher_change_request_history</text><text x="4304" y="1420" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">История согласования заявки</text><g data-column="id" data-row-top="1436" data-row-height="28"><title>id BIGSERIAL PRIMARY KEY</title><rect x="4289" y="1436" width="510" height="28" fill="#eef2f7"/><text x="4300" y="1454.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="4370" y="1454.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="4756" y="1454.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="4782" y="1454.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="request_id" data-row-top="1464" data-row-height="28"><title>request_id BIGINT NOT NULL REFERENCES teacher_change_requests(id) ON DELETE CASCADE</title><rect x="4289" y="1464" width="510" height="28" fill="#f8fafc"/><text x="4300" y="1482.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK77</text><text x="4370" y="1482.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">request_id</text><text x="4756" y="1482.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="4782" y="1482.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="status" data-row-top="1492" data-row-height="28"><title>status VARCHAR(20) NOT NULL</title><rect x="4289" y="1492" width="510" height="28" fill="#eef2f7"/><text x="4370" y="1510.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">status</text><text x="4756" y="1510.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(20)</text><text x="4782" y="1510.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="comment" data-row-top="1520" data-row-height="28"><title>comment TEXT</title><rect x="4289" y="1520" width="510" height="28" fill="#f8fafc"/><text x="4370" y="1538.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">comment</text><text x="4756" y="1538.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">text</text><text x="4782" y="1538.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="actor_id" data-row-top="1548" data-row-height="28"><title>actor_id BIGINT REFERENCES users(id)</title><rect x="4289" y="1548" width="510" height="28" fill="#eef2f7"/><text x="4300" y="1566.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK78</text><text x="4370" y="1566.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">actor_id</text><text x="4756" y="1566.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="4782" y="1566.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="created_at" data-row-top="1576" data-row-height="28"><title>created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP</title><rect x="4289" y="1576" width="510" height="28" fill="#f8fafc"/><text x="4370" y="1594.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">created_at</text><text x="4756" y="1594.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">timestamptz</text><text x="4782" y="1594.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g></g><g class="entity" id="table-schedule_versions" data-table="schedule_versions" tabindex="0" role="button" aria-label="schedule_versions: Версии расписания"><title>schedule_versions: Версии расписания
13 столбцов · 5 исходящих и 4 входящих FK</title><rect class="table-box" x="2880" y="152" width="512" height="460" rx="6"/><path d="M 2886 152 H 3386 Q 3392 152 3392 158 V 216 H 2880 V 158 Q 2880 152 2886 152 Z" fill="#e8edf3"/><text x="2896" y="178" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">schedule_versions</text><text x="2896" y="200" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Версии расписания</text><g data-column="id" data-row-top="216" data-row-height="60"><title>id BIGSERIAL PRIMARY KEY</title><rect x="2881" y="216" width="510" height="60" fill="#eef2f7"/><text x="2892" y="250.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="2962" y="250.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="3348" y="250.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="3374" y="250.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="semester_id" data-row-top="276" data-row-height="28"><title>semester_id BIGINT NOT NULL REFERENCES semesters(id) ON DELETE CASCADE</title><rect x="2881" y="276" width="510" height="28" fill="#f8fafc"/><text x="2892" y="294.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK79</text><text x="2962" y="294.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">semester_id</text><text x="3348" y="294.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="3374" y="294.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="version_number" data-row-top="304" data-row-height="28"><title>version_number INT NOT NULL</title><rect x="2881" y="304" width="510" height="28" fill="#eef2f7"/><text x="2962" y="322.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">version_number</text><text x="3348" y="322.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">int</text><text x="3374" y="322.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="name" data-row-top="332" data-row-height="28"><title>name VARCHAR(160) NOT NULL</title><rect x="2881" y="332" width="510" height="28" fill="#f8fafc"/><text x="2962" y="350.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">name</text><text x="3348" y="350.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(160)</text><text x="3374" y="350.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="status" data-row-top="360" data-row-height="28"><title>status VARCHAR(20) NOT NULL</title><rect x="2881" y="360" width="510" height="28" fill="#eef2f7"/><text x="2962" y="378.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">status</text><text x="3348" y="378.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(20)</text><text x="3374" y="378.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="based_on_version_id" data-row-top="388" data-row-height="28"><title>based_on_version_id BIGINT REFERENCES schedule_versions(id) ON DELETE SET NULL</title><rect x="2881" y="388" width="510" height="28" fill="#f8fafc"/><text x="2892" y="406.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK80</text><text x="2962" y="406.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">based_on_version_id</text><text x="3348" y="406.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="3374" y="406.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="restored_from_version_id" data-row-top="416" data-row-height="28"><title>restored_from_version_id BIGINT REFERENCES schedule_versions(id) ON DELETE SET NULL</title><rect x="2881" y="416" width="510" height="28" fill="#eef2f7"/><text x="2892" y="434.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK81</text><text x="2962" y="434.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">restored_from_version_id</text><text x="3348" y="434.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="3374" y="434.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="change_reason" data-row-top="444" data-row-height="28"><title>change_reason TEXLine truncated
6 столбцов · 2 исходящих и 0 входящих FK</title><rect class="table-box" x="2880" y="724" width="512" height="232" rx="6"/><path d="M 2886 724 H 3386 Q 3392 724 3392 730 V 788 H 2880 V 730 Q 2880 724 2886 724 Z" fill="#e8edf3"/><text x="2896" y="750" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">schedule_version_history</text><text x="2896" y="772" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">История версий расписания</text><g data-column="id" data-row-top="788" data-row-height="28"><title>id BIGSERIAL PRIMARY KEY</title><rect x="2881" y="788" width="510" height="28" fill="#eef2f7"/><text x="2892" y="806.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="2962" y="806.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="3348" y="806.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="3374" y="806.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="version_id" data-row-top="816" data-row-height="28"><title>version_id BIGINT NOT NULL REFERENCES schedule_versions(id) ON DELETE CASCADE</title><rect x="2881" y="816" width="510" height="28" fill="#f8fafc"/><text x="2892" y="834.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK85</text><text x="2962" y="834.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">version_id</text><text x="3348" y="834.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="3374" y="834.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="action" data-row-top="844" data-row-height="28"><title>action VARCHAR(30) NOT NULL</title><rect x="2881" y="844" width="510" height="28" fill="#eef2f7"/><text x="2962" y="862.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">action</text><text x="3348" y="862.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(30)</text><text x="3374" y="862.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="actor_id" data-row-top="872" data-row-height="28"><title>actor_id BIGINT REFERENCES users(id)</title><rect x="2881" y="872" width="510" height="28" fill="#f8fafc"/><text x="2892" y="890.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK86</text><text x="2962" y="890.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">actor_id</text><text x="3348" y="890.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="3374" y="890.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="reason" data-row-top="900" data-row-height="28"><title>reason TEXT</title><rect x="2881" y="900" width="510" height="28" fill="#eef2f7"/><text x="2962" y="918.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">reason</text><text x="3348" y="918.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">text</text><text x="3374" y="918.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g><g data-column="created_at" data-row-top="928" data-row-height="28"><title>created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP</title><rect x="2881" y="928" width="510" height="28" fill="#f8fafc"/><text x="2962" y="946.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">created_at</text><text x="3348" y="946.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">timestamptz</text><text x="3374" y="946.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g></g><g class="entity" id="table-study_plans" data-table="study_plans" tabindex="0" role="button" aria-label="study_plans: Учебные планы"><title>study_plans: Учебные планы
6 столбцов · 2 исходящих и 2 входящих FK</title><rect class="table-box" x="1472" y="152" width="512" height="240" rx="6"/><path d="M 1478 152 H 1978 Q 1984 152 1984 158 V 216 H 1472 V 158 Q 1472 152 1478 152 Z" fill="#e8edf3"/><text x="1488" y="178" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">study_plans</text><text x="1488" y="200" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Учебные планы</text><g data-column="id" data-row-top="216" data-row-height="36"><title>id BIGSERIAL PRIMARY KEY</title><rect x="1473" y="216" width="510" height="36" fill="#eef2f7"/><text x="1484" y="238.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="1554" y="238.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="1940" y="238.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="1966" y="238.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="title" data-row-top="252" data-row-height="28"><title>title VARCHAR(255) NOT NULL CHECK (length(trim(title)) &gt; 0)</title><rect x="1473" y="252" width="510" height="28" fill="#f8fafc"/><text x="1554" y="270.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">title</text><text x="1940" y="270.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(255)</text><text x="1966" y="270.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="specialty_profile_id" data-row-top="280" data-row-height="28"><title>specialty_profile_id BIGINT NOT NULL REFERENCES specialty_profiles(id)</title><rect x="1473" y="280" width="510" height="28" fill="#eef2f7"/><text x="1484" y="298.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK87</text><text x="1554" y="298.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">specialty_profile_id</text><text x="1940" y="298.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="1966" y="298.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="education_form_id" data-row-top="308" data-row-height="28"><title>education_form_id BIGINT NOT NULL REFERENCES education_forms(id)</title><rect x="1473" y="308" width="510" height="28" fill="#f8fafc"/><text x="1484" y="326.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK88</text><text x="1554" y="326.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">education_form_id</text><text x="1940" y="326.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="1966" y="326.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="semester_number" data-row-top="336" data-row-height="28"><title>semester_number INT NOT NULL CONSTRAINT chk_study_plan_semester CHECK (semester_number BETWEEN 1 AND 20)</title><rect x="1473" y="336" width="510" height="28" fill="#eef2f7"/><text x="1554" y="354.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">semester_number</text><text x="1940" y="354.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">int</text><text x="1966" y="354.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="revision" data-row-top="364" data-row-height="28"><title>revision BIGINT NOT NULL DEFAULT 0</title><rect x="1473" y="364" width="510" height="28" fill="#f8fafc"/><text x="1554" y="382.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">revision</text><text x="1940" y="382.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="1966" y="382.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g></g><g class="entity" id="table-study_plan_subjects" data-table="study_plan_subjects" tabindex="0" role="button" aria-label="study_plan_subjects: Дисциплины учебного плана"><title>study_plan_subjects: Дисциплины учебного плана
3 столбцов · 2 исходящих и 1 входящих FK</title><rect class="table-box" x="1472" y="504" width="512" height="148" rx="6"/><path d="M 1478 504 H 1978 Q 1984 504 1984 510 V 568 H 1472 V 510 Q 1472 504 1478 504 Z" fill="#e8edf3"/><text x="1488" y="530" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">study_plan_subjects</text><text x="1488" y="552" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Дисциплины учебного плана</text><g data-column="id" data-row-top="568" data-row-height="28"><title>id BIGSERIAL PRIMARY KEY</title><rect x="1473" y="568" width="510" height="28" fill="#eef2f7"/><text x="1484" y="586.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="1554" y="586.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="1940" y="586.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="1966" y="586.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="plan_id" data-row-top="596" data-row-height="28"><title>plan_id BIGINT NOT NULL REFERENCES study_plans(id) ON DELETE CASCADE</title><rect x="1473" y="596" width="510" height="28" fill="#f8fafc"/><text x="1484" y="614.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK89</text><text x="1554" y="614.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">plan_id</text><text x="1940" y="614.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="1966" y="614.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="subject_id" data-row-top="624" data-row-height="28"><title>subject_id BIGINT NOT NULL REFERENCES subjects(id)</title><rect x="1473" y="624" width="510" height="28" fill="#eef2f7"/><text x="1484" y="642.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK90</text><text x="1554" y="642.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">subject_id</text><text x="1940" y="642.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="1966" y="642.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g></g><g class="entity" id="table-study_plan_loads" data-table="study_plan_loads" tabindex="0" role="button" aria-label="study_plan_loads: Нагрузка учебного плана"><title>study_plan_loads: Нагрузка учебного плана
6 столбцов · 2 исходящих и 0 входящих FK</title><rect class="table-box" x="1472" y="764" width="512" height="232" rx="6"/><path d="M 1478 764 H 1978 Q 1984 764 1984 770 V 828 H 1472 V 770 Q 1472 764 1478 764 Z" fill="#e8edf3"/><text x="1488" y="790" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">study_plan_loads</text><text x="1488" y="812" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Нагрузка учебного плана</text><g data-column="id" data-row-top="828" data-row-height="28"><title>id BIGSERIAL PRIMARY KEY</title><rect x="1473" y="828" width="510" height="28" fill="#eef2f7"/><text x="1484" y="846.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK</text><text x="1554" y="846.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">id</text><text x="1940" y="846.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigserial</text><text x="1966" y="846.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="plan_subject_id" data-row-top="856" data-row-height="28"><title>plan_subject_id BIGINT NOT NULL REFERENCES study_plan_subjects(id) ON DELETE CASCADE</title><rect x="1473" y="856" width="510" height="28" fill="#f8fafc"/><text x="1484" y="874.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK91</text><text x="1554" y="874.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">plan_subject_id</text><text x="1940" y="874.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="1966" y="874.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="category" data-row-top="884" data-row-height="28"><title>category VARCHAR(20) NOT NULL CONSTRAINT chk_study_plan_category CHECK (category IN (&#x27;LECTURE&#x27;, &#x27;PRACTICE&#x27;, &#x27;LABORATORY&#x27;))</title><rect x="1473" y="884" width="510" height="28" fill="#eef2f7"/><text x="1554" y="902.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">category</text><text x="1940" y="902.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">varchar(20)</text><text x="1966" y="902.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="academic_hours" data-row-top="912" data-row-height="28"><title>academic_hours INT NOT NULL CONSTRAINT chk_study_plan_hours CHECK (academic_hours BETWEEN 0 AND 100000 AND mod(academic_hours, 2) = 0)</title><rect x="1473" y="912" width="510" height="28" fill="#f8fafc"/><text x="1554" y="930.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">academic_hours</text><text x="1940" y="930.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">int</text><text x="1966" y="930.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="split_subgroups" data-row-top="940" data-row-height="28"><title>split_subgroups BOOLEAN NOT NULL DEFAULT FALSE</title><rect x="1473" y="940" width="510" height="28" fill="#eef2f7"/><text x="1554" y="958.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">split_subgroups</text><text x="1940" y="958.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">boolean</text><text x="1966" y="958.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="teacher_id" data-row-top="968" data-row-height="28"><title>teacher_id BIGINT REFERENCES users(id)</title><rect x="1473" y="968" width="510" height="28" fill="#f8fafc"/><text x="1484" y="986.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK92</text><text x="1554" y="986.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">teacher_id</text><text x="1940" y="986.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="1966" y="986.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">○</text></g></g><g class="entity" id="table-student_group_plan_assignments" data-table="student_group_plan_assignments" tabindex="0" role="button" aria-label="student_group_plan_assignments: Назначения планов группам"><title>student_group_plan_assignments: Назначения планов группам
3 столбцов · 3 исходящих и 0 входящих FK</title><rect class="table-box" x="1472" y="1108" width="512" height="148" rx="6"/><path d="M 1478 1108 H 1978 Q 1984 1108 1984 1114 V 1172 H 1472 V 1114 Q 1472 1108 1478 1108 Z" fill="#e8edf3"/><text x="1488" y="1134" font-size="16" fill="#0f172a" font-weight="600" text-anchor="start" class="sans">student_group_plan_assignments</text><text x="1488" y="1156" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Назначения планов группам</text><g data-column="group_id" data-row-top="1172" data-row-height="28"><title>group_id BIGINT NOT NULL REFERENCES student_groups(id)</title><rect x="1473" y="1172" width="510" height="28" fill="#eef2f7"/><text x="1484" y="1190.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK·FK93</text><text x="1554" y="1190.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">group_id</text><text x="1940" y="1190.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="1966" y="1190.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="semester_id" data-row-top="1200" data-row-height="28"><title>semester_id BIGINT NOT NULL REFERENCES semesters(id)</title><rect x="1473" y="1200" width="510" height="28" fill="#f8fafc"/><text x="1484" y="1218.0" font-size="9" fill="#4f46e5" font-weight="400" text-anchor="start" class="mono">PK·FK94</text><text x="1554" y="1218.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">semester_id</text><text x="1940" y="1218.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="1966" y="1218.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g><g data-column="plan_id" data-row-top="1228" data-row-height="28"><title>plan_id BIGINT NOT NULL REFERENCES study_plans(id)</title><rect x="1473" y="1228" width="510" height="28" fill="#eef2f7"/><text x="1484" y="1246.0" font-size="9" fill="#475569" font-weight="400" text-anchor="start" class="mono">FK95</text><text x="1554" y="1246.0" font-size="13" fill="#0f172a" font-weight="400" text-anchor="start" class="sans">plan_id</text><text x="1940" y="1246.0" font-size="11" fill="#475569" font-weight="400" text-anchor="end" class="mono">bigint</text><text x="1966" y="1246.0" font-size="10" fill="#475569" font-weight="400" text-anchor="middle" class="sans">●</text></g></g></g><text x="64" y="3792" font-size="13" fill="#475569" font-weight="400" text-anchor="start" class="sans">PK — первичный ключ FK01…FK105 — внешние ключи UQ — одиночный UNIQUE ● NOT NULL ○ NULL</text><text x="64" y="3820" font-size="13" fill="#475569" font-weight="400" text-anchor="start" class="sans">Каждая стрелка: столбец FK → столбец PK. Имя связи и ON DELETE доступны при наведении на линию или выборе таблицы.</text><text x="64" y="3848" font-size="12" fill="#475569" font-weight="400" text-anchor="start" class="sans">Составные FK показаны отдельными линиями столбцов с одним номером. version_group_id и semester_number не являются REFERENCES.</text></svg></div></main>
<aside id="inspector" class="inspector" hidden aria-label="Выбранная таблица"></aside>
<div class="hint" id="hint">Перетаскивайте полотно · Ctrl + колесо — масштаб · нажмите таблицу для связей · двойной щелчок — приблизить</div>
</div>
<footer class="status"><span id="status" role="status">Все 46 таблиц и 105 связей на одном полотне. Стрелки: FK → PK/UQ. ● NOT NULL · ○ NULL</span><span class="source">V1__init.sql · 83bad8887177</span></footer>
<noscript><style>.viewport{height:90vh}.canvas{width:max-content}</style><p class="fallback">JavaScript выключен: полная статическая схема доступна с прокруткой.</p></noscript>
<script id="schema-data" type="application/json">{"width": 4864, "height": 3884, "source": "V1__init.sql", "sha256": "83bad888717777e6a3c5fe44b3a5d74871b044314a6de72753648d8300358adb", "tables": {"departments": {"label": "Кафедры", "columns": {"id": {"name": "id", "type": "BIGSERIAL", "pk": true, "nn": true, "uq": true, "ddl": "id BIGSERIAL UNIQUE PRIMARY KEY NOT NULL"}, "name": {"name": "name", "type": "VARCHAR(255)", "pk": false, "nn": true, "uq": false, "ddl": "name VARCHAR(255) NOT NULL"}, "code": {"name": "code", "type": "BIGINT", "pk": false, "nn": true, "uq": true, "ddl": "code BIGINT UNIQUE NOT NULL"}, "status": {"name": "status", "type": "VARCHAR(20)", "pk": false, "nn": true, "uq": false, "ddl": "status VARCHAR(20) NOT NULL DEFAULT 'ACTIVE'"}, "active_from": {"name": "active_from", "type": "DATE", "pk": false, "nn": false, "uq": false, "ddl": "active_from DATE"}, "active_to": {"name": "active_to", "type": "DATE", "pk": false, "nn": false, "uq": false, "ddl": "active_to DATE"}, "archived_at": {"name": "archived_at", "type": "TIMESTAMPTZ", "pk": false, "nn": false, "uq": false, "ddl": "archived_at TIMESTAMPTZ"}, "archived_by": {"name": "archived_by", "type": "BIGINT", "pk": false, "nn": false, "uq": false, "ddl": "archived_by BIGINT", "fks": [{"source": "departments", "columns": ["archived_by"], "column": "archived_by", "target": "users", "keys": ["id"], "key": "id", "action": "SET NULL", "number": 96}]}, "archive_reason": {"name": "archive_reason", "type": "TEXT", "pk": false, "nn": false, "uq": false, "ddl": "archive_reason TEXT"}}, "constraints": ["CONSTRAINT chk_departments_lifecycle_status CHECK (status IN ('ACTIVE', 'ARCHIVED'))", "CONSTRAINT chk_departments_lifecycle_period CHECK ( status = 'ARCHIVED' OR active_from IS NULL OR active_to IS NULL OR active_from \u003c= active_to )", "CONSTRAINT chk_departments_lifecycle_archive CHECK ( (status = 'ARCHIVED' AND archived_at IS NOT NULL) OR (status \u003c> 'ARCHIVED' AND archived_at IS NULL AND archived_by IS NULL AND archive_reason IS NULL) )", "CONSTRAINT fk_departments_archived_by FOREIGN KEY (archived_by) REFERENCES users(id) ON DELETE SET NULL"], "indexes": ["CREATE INDEX IF NOT EXISTS idx_departments_status ON departments(status)"], "x": 2176, "y": 980, "width": 512, "height": 348, "rows": {"id": {"top": 1044, "height": 60, "center": 1074.0}, "name": {"top": 1104, "height": 28, "center": 1118.0}, "code": {"top": 1132, "height": 28, "center": 1146.0}, "status": {"top": 1160, "height": 28, "center": 1174.0}, "active_from": {"top": 1188, "height": 28, "center": 1202.0}, "active_to": {"top": 1216, "height": 28, "center": 1230.0}, "archived_at": {"top": 1244, "height": 28, "center": 1258.0}, "archived_by": {"top": 1272, "height": 28, "center": 1286.0}, "archive_reason": {"top": 1300, "height": 28, "center": 1314.0}}, "column": 3}, "specialties": {"label": "Направления подготовки", "columns": {"id": {"name": "id", "type": "BIGSERIAL", "pk": true, "nn": true, "uq": false, "ddl": "id BIGSERIAL PRIMARY KEY"}, "name": {"name": "name", "type": "VARCHAR(255)", "pk": false, "nn": true, "uq": false, "ddl": "name VARCHAR(255) NOT NULL"}, "specialty_code": {"name": "specialty_code", "type": "VARCHAR(255)", "pk": false, "nn": true, "uq": true, "ddl": "specialty_code VARCHAR(255) UNIQUE NOT NULL"}, "status": {"name": "status", "type": "VARCHAR(20)", "pk": false, "nn": true, "uq": false, "ddl": "status VARCHAR(20) NOT NULL DEFAULT 'ACTIVE'"}, "active_from": {"name": "active_from", "type": "DATE", "pk": false, "nn": false, "uq": false, "ddl": "active_from DATE"}, "active_to": {"name": "active_to", "type": "DATE", "pk": false, "nn": false, "uq": false, "ddl": "active_to DATE"}, "archived_at": {"name": "archived_at", "type": "TIMESTAMPTZ", "pk": false, "nn": false, "uq": false, "ddl": "archived_at TIMESTAMPTZ"}, "archived_by": {"name": "archived_by", "type": "BIGINT", "pk": false, "nn": false, "uq": false, "ddl": "archived_by BIGINT", "fks": [{"source": "specialties", "columns": ["archived_by"], "column": "archived_by", "target": "users", "keys": ["id"], "key": "id", "action": "SET NULL", "number": 97}]}, "archive_reason": {"name": "archive_reason", "type": "TEXT", "pk": false, "nn": false, "uq": false, "ddl": "archive_reason TEXT"}}, "constraints": ["CONSTRAINT chk_specialties_lifecycle_status CHECK (status IN ('ACTIVE', 'ARCHIVED'))", "CONSTRAINT chk_specialties_lifecycle_period CHECK ( status = 'ARCHIVED' OR active_from IS NULL OR active_to IS NULL OR active_from \u003c= active_to )", "CONSTRAINT chk_specialties_lifecycle_archive CHECK ( (status = 'ARCHIVED' AND archived_at IS NOT NULL) OR (status \u003c> 'ARCHIVED' AND archived_at IS NULL AND archived_by IS NULL AND archive_reason IS NULL) )", "CONSTRAINT fk_specialties_archived_by FOREIGN KEY (archived_by) REFERENCES users(id) ON DELETE SET NULL"], "indexes": ["CREATE INDEX IF NOT EXISTS idx_specialties_status ON specialties(status)"], "x": 64, "y": 152, "width": 512, "height": 3Line truncated
<script>
(() => {
'use strict';
const data = JSON.parse(document.getElementById('schema-data').textContent);
const svg = document.getElementById('schema');
const viewport = document.getElementById('viewport');
const canvas = document.getElementById('canvas');
const inspector = document.getElementById('inspector');
const status = document.getElementById('status');
const zoomValue = document.getElementById('zoom-value');
const search = document.getElementById('search');
const entities = [...svg.querySelectorAll('.entity')];
const relations = [...svg.querySelectorAll('.relation')];
let scale = 1, selected = null, dragging = null, moved = false;
const escape = value => String(value).replace(/[&<>"']/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]));
function zoom(next, x=viewport.clientWidth/2, y=viewport.clientHeight/2) {
next = Math.max(.06,Math.min(2.5,next));
const worldX = (viewport.scrollLeft+x-20)/scale;
const worldY = (viewport.scrollTop+y-20)/scale;
scale = next;
svg.style.width = `${data.width*scale}px`;
svg.style.height = `${data.height*scale}px`;
viewport.scrollLeft = worldX*scale-x+20;
viewport.scrollTop = worldY*scale-y+20;
zoomValue.value = `${Math.round(scale*100)}%`;
}
function fit() {
zoom(Math.min((viewport.clientWidth-40)/data.width,(viewport.clientHeight-40)/data.height));
viewport.scrollTo(0,0);
}
function highlight(name, edgeNumber=null) {
svg.classList.toggle('schema-focused',Boolean(name || edgeNumber));
const connected = new Set(name?[name]:[]);
relations.forEach(r=>{
const active = edgeNumber ? Number(r.dataset.number)===edgeNumber : name && (r.dataset.source===name || r.dataset.target===name);
r.classList.toggle('active',Boolean(active));
if(active){connected.add(r.dataset.source);connected.add(r.dataset.target);}
});
entities.forEach(e=>{e.classList.toggle('selected',e.dataset.table===name);e.classList.toggle('related',connected.has(e.dataset.table));});
}
function clear() {
selected = null;
inspector.hidden = true;
highlight(null);
status.textContent = 'Все 46 таблиц и 105 связей на одном полотне. Стрелки: FK → PK/UQ. ● NOT NULL · ○ NULL';
}
function focus(name) {
if(!data.tables[name])return;
select(name);
zoom(1);
const t = data.tables[name];
viewport.scrollLeft = t.x*scale-viewport.clientWidth/2+t.width*scale/2+20;
viewport.scrollTop = t.y*scale-60;
}
function edgeList(edges,direction) {
if(!edges.length)return '<p>Нет.</p>';
return '<ul class="link-list">'+edges.map(e=>`<li><button type="button" data-link="${escape(direction==='out'?e.target:e.source)}" data-edge="${e.number}"><code>FK${String(e.number).padStart(2,'0')} · ${escape(e.source)}.${escape(e.columns.join(', '))} → ${escape(e.target)}.${escape(e.keys.join(', '))}</code></button><small>ON DELETE ${escape(e.action)} · ${data.tables[e.source].columns[e.column].nn?'обязательная ссылка':'NULL допустим'}</small></li>`).join('')+'</ul>';
}
function select(name) {
selected = name;
highlight(name);
const table = data.tables[name];
const outgoing = data.edges.filter(e=>e.source===name);
const incoming = data.edges.filter(e=>e.target===name);
inspector.innerHTML = `<button class="close" type="button" aria-label="Закрыть сведения">×</button><h2>${escape(name)}</h2><p>${escape(table.label)}</p><p>${Object.keys(table.columns).length} столбцов · ${outgoing.length} исходящих FK · ${incoming.length} входящих FK</p><h3>Исходящие связи</h3>${edgeList(outgoing,'out')}<h3>Входящие связи</h3>${edgeList(incoming,'in')}<h3>Ограничения</h3>${table.constraints.length?table.constraints.map(c=>`<code class="constraint">${escape(c)}</code>`).join(''):'<p>Отдельные ограничения не объявлены.</p>'}<h3>Явные индексы</h3>${table.indexes.length?table.indexes.map(c=>`<code class="constraint">${escape(c)}</code>`).join(''):'<p>Нет. Индексы PK и UNIQUE создаются PostgreSQL автоматически.</p>'}`;
inspector.hidden = false;
inspector.querySelector('.close').addEventListener('click',clear);
inspector.querySelectorAll('[data-link]').forEach(button=>button.addEventListener('click',()=>focus(button.dataset.link)));
status.textContent = `${name} · ${outgoing.length} исходящих и ${incoming.length} входящих FK · все остальные таблицы остаются на полотне`;
}
entities.forEach(entity=>{
const name = entity.dataset.table;
entity.addEventListener('mouseenter',()=>{if(!selected && !dragging)highlight(name);});
entity.addEventListener('mouseleave',()=>{if(!selected)highlight(null);});
entity.addEventListener('click',()=>{if(!moved)select(name);});
entity.addEventListener('dblclick',()=>focus(name));
entity.addEventListener('keydown',e=>{if(e.key==='Enter'||e.key===' '){e.preventDefault();select(name);}});
});
relations.forEach(relation=>{
relation.addEventListener('mouseenter',()=>{
if(!selected)highlight(null,Number(relation.dataset.number));
const e = data.edges.find(e=>e.number===Number(relation.dataset.number));
status.textContent = `FK${String(e.number).padStart(2,'0')}: ${e.source}.${e.column} → ${e.target}.${e.key} · ON DELETE ${e.action}`;
});
relation.addEventListener('mouseleave',()=>{if(!selected){highlight(null);status.textContent='Все 46 таблиц и 105 связей на одном полотне. Стрелки: FK → PK/UQ. ● NOT NULL · ○ NULL';}});
});
document.getElementById('zoom-in').addEventListener('click',()=>zoom(scale*1.25));
document.getElementById('zoom-out').addEventListener('click',()=>zoom(scale/1.25));
document.getElementById('actual').addEventListener('click',()=>zoom(1));
document.getElementById('fit').addEventListener('click',()=>{clear();fit();});
document.getElementById('clear').addEventListener('click',clear);
viewport.addEventListener('wheel',e=>{
if(!e.ctrlKey&&!e.metaKey)return;
e.preventDefault();
const rect=viewport.getBoundingClientRect();
zoom(scale*Math.exp(-e.deltaY*.002),e.clientX-rect.left,e.clientY-rect.top);
},{passive:false});
viewport.addEventListener('pointerdown',e=>{
if(e.button!==0||e.target.closest('.entity'))return;
dragging={x:e.clientX,y:e.clientY,left:viewport.scrollLeft,top:viewport.scrollTop};
moved=false;
viewport.setPointerCapture(e.pointerId);
viewport.classList.add('dragging');
});
viewport.addEventListener('pointermove',e=>{
if(!dragging)return;
const dx=e.clientX-dragging.x,dy=e.clientY-dragging.y;
moved=moved||Math.abs(dx)+Math.abs(dy)>4;
viewport.scrollLeft=dragging.left-dx;viewport.scrollTop=dragging.top-dy;
});
function stop(){if(dragging&&!moved)clear();dragging=null;viewport.classList.remove('dragging');setTimeout(()=>{moved=false;},0);}
viewport.addEventListener('pointerup',stop);viewport.addEventListener('pointercancel',stop);
document.addEventListener('keydown',e=>{if(e.key==='Escape')clear();});
const names = document.getElementById('table-names');
Object.keys(data.tables).sort().forEach(name=>{const option=document.createElement('option');option.value=name;option.label=data.tables[name].label;names.append(option);});
function searchTable(){const term=search.value.trim().toLowerCase();const name=data.tables[term]?term:Object.keys(data.tables).find(n=>n.includes(term)||data.tables[n].label.toLowerCase().includes(term));if(term&&name)focus(name);}
search.addEventListener('change',searchTable);search.addEventListener('keydown',e=>{if(e.key==='Enter')searchTable();});
requestAnimationFrame(fit);
window.addEventListener('resize',()=>{if(scale<.3)fit();});
})();
</script>
</body>
</html>
+151
View File
@@ -0,0 +1,151 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Магистр — полная схема базы данных</title>
<style>
*{box-sizing:border-box}html,body{margin:0;height:100%;overflow:hidden}body{background:#f8fafc;color:#0f172a;font:13px/1.4 Inter,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;display:grid;grid-template-rows:auto minmax(0,1fr) 36px;grid-template-columns:minmax(0,1fr);height:100dvh}.sans{font-family:Inter,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif}.mono,code{font-family:'Cascadia Mono','SFMono-Regular',Consolas,'Noto Sans Mono',monospace}button,input,select{font:inherit}button,select,input{border:1px solid #cbd5e1;background:#fdfefe;color:#0f172a;border-radius:5px;height:34px}button{cursor:pointer;padding:0 12px;white-space:nowrap}button:hover{background:#eeedff;border-color:#4f46e5}button:focus-visible,input:focus-visible,select:focus-visible,.entity:focus-visible{outline:2px solid #4f46e5;outline-offset:2px}.toolbar{display:flex;align-items:center;gap:20px;min-height:76px;padding:12px 20px;border-bottom:1px solid #cbd5e1;background:#fdfefe}.brand{display:flex;align-items:center;gap:12px;flex-shrink:0}.logo{width:32px;height:32px;background:#4f46e5;color:#f8fafc;border-radius:5px;display:grid;place-items:center;font-size:20px;font-weight:600}.brand h1{font-size:15px;letter-spacing:-.02em;margin:0;font-weight:600}.brand p{font-size:11px;color:#475569;margin:3px 0 0}.controls{display:flex;align-items:center;gap:6px;margin-left:auto}.zoom-value{min-width:50px;text-align:center;font-variant-numeric:tabular-nums;color:#475569}.search{width:250px;padding:0 10px}.workspace{height:auto;min-height:0;min-width:0;width:100%;position:relative;display:flex}.viewport{flex:1;min-width:0;overflow:auto;cursor:grab;overscroll-behavior:contain;background-color:#e8edf3;touch-action:pan-x pan-y}.viewport.dragging{cursor:grabbing;user-select:none}.canvas{position:relative;margin:20px;line-height:0;width:max-content;min-width:0}.canvas>svg{display:block;background:#f8fafc}.table-box{fill:#f8fafc;stroke:#475569;stroke-width:1.25}.entity{cursor:pointer;outline:none}.entity.selected .table-box,.entity:focus-visible .table-box{stroke:#4f46e5;stroke-width:3}.wire-under{fill:none;stroke:#f8fafc;stroke-width:5;stroke-linejoin:round}.wire{fill:none;stroke:#64748b;stroke-width:1.65;stroke-linejoin:round;pointer-events:none}.wire-hit{fill:none;stroke:transparent;stroke-width:10;cursor:crosshair}.relation.active .wire{stroke:#4f46e5;stroke-width:3}.relation.active .wire-under{stroke-width:7}.schema-focused .relation:not(.active){opacity:.16}.schema-focused .entity:not(.related):not(.selected){opacity:.38}.relation:hover .wire{stroke:#4f46e5;stroke-width:3}.inspector{width:350px;flex-shrink:0;background:#fdfefe;border-left:1px solid #cbd5e1;overflow:auto;padding:20px;line-height:1.6}.inspector[hidden]{display:none}.inspector h2{font-size:14px;overflow-wrap:anywhere;margin:0 0 4px}.inspector h3{font-size:12px;color:#475569;text-transform:uppercase;letter-spacing:.06em;margin:24px 0 12px}.inspector p{font-size:12px;color:#475569;margin:6px 0}.inspector .close{float:right;height:28px;margin:-6px -6px 8px 8px;padding:0 8px}.link-list{list-style:none;padding:0;margin:0}.link-list li{padding:10px 0;border-top:1px solid #e2e8f0}.link-list button{height:auto;text-align:left;border:0;border-radius:0;padding:0;background:transparent;color:#4338ca;display:block;overflow-wrap:anywhere;white-space:normal;font-size:11px}.link-list small{color:#475569;display:block;font-size:10px;padding-top:3px}.constraint{font-size:10px;overflow-wrap:anywhere;white-space:normal;color:#475569;display:block;padding:8px 0;border-top:1px solid #e2e8f0}.status{height:36px;display:flex;align-items:center;gap:16px;padding:0 20px;background:#fdfefe;border-top:1px solid #cbd5e1;font-size:11px;color:#475569}.status>span:first-child{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.source{white-space:nowrap}.hint{position:absolute;bottom:20px;left:20px;pointer-events:none;padding:8px 12px;background:#fdfefe;border:1px solid #cbd5e1;border-radius:5px;color:#475569;font-size:11px;max-width:calc(100% - 40px)}.help{margin-left:6px}.fallback{padding:16px;background:#eeedff;color:#0f172a;font-size:13px}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0)}
@media(max-width:1100px){.toolbar{gap:10px;flex-wrap:wrap}.controls{flex-wrap:wrap}.brand{margin-right:auto}.search{width:210px}.workspace{height:auto}.toolbar{min-height:116px}.help{display:none}}@media(max-width:640px){.toolbar{padding:10px 12px;gap:8px}.brand{width:100%}.controls{margin-left:0;width:100%;gap:4px}.search{flex:1;min-width:130px;width:auto}.controls button{padding:0 8px}.controls .reset{display:none}.brand h1{font-size:14px}.workspace{height:auto}.inspector{position:absolute;right:0;top:0;bottom:0;width:min(350px,88vw)}.source{display:none}.status{padding:0 12px}.hint{left:12px;bottom:12px;font-size:10px}}
@media print{html,body{overflow:visible;height:auto}.toolbar,.inspector,.status,.hint{display:none}.workspace,.viewport{height:auto;overflow:visible;display:block}.canvas{margin:0;width:100%!important;height:auto!important}.canvas>svg{width:100%!important;height:auto!important}.schema-focused .relation,.schema-focused .entity{opacity:1!important}}
</style>
</head>
<body>
<header class="toolbar">
<div class="brand"><span class="logo" aria-hidden="true">М</span><div><h1>Магистр · Полная схема БД</h1><p>@@TABLE_COUNT@@ таблиц · @@COLUMN_COUNT@@ столбцов · @@FK_COUNT@@ внешних ключей</p></div></div>
<div class="controls">
<label for="search" class="sr-only">Найти таблицу</label><input id="search" class="search" type="search" list="table-names" placeholder="Найти таблицу…" autocomplete="off"><datalist id="table-names"></datalist>
<button id="zoom-out" aria-label="Уменьшить масштаб">−</button><output id="zoom-value" class="zoom-value" aria-live="polite">100%</output><button id="zoom-in" aria-label="Увеличить масштаб">+</button><button id="actual">100%</button><button id="fit">Вся схема</button><button id="clear" class="reset">Сбросить выделение</button>
</div>
</header>
<div class="workspace">
<main id="viewport" class="viewport" aria-label="Полотно полной схемы базы данных"><div id="canvas" class="canvas">@@SCHEMA@@</div></main>
<aside id="inspector" class="inspector" hidden aria-label="Выбранная таблица"></aside>
<div class="hint" id="hint">Перетаскивайте полотно · Ctrl + колесо — масштаб · нажмите таблицу для связей · двойной щелчок — приблизить</div>
</div>
<footer class="status"><span id="status" role="status">Все @@TABLE_COUNT@@ таблиц и @@FK_COUNT@@ связей на одном полотне. Стрелки: FK → PK/UQ. ● NOT NULL · ○ NULL</span><span class="source">V1__init.sql · @@SHA@@</span></footer>
<noscript><style>.viewport{height:90vh}.canvas{width:max-content}</style><p class="fallback">JavaScript выключен: полная статическая схема доступна с прокруткой.</p></noscript>
<script id="schema-data" type="application/json">@@DATA@@</script>
<script>
(() => {
'use strict';
const data = JSON.parse(document.getElementById('schema-data').textContent);
const svg = document.getElementById('schema');
const viewport = document.getElementById('viewport');
const canvas = document.getElementById('canvas');
const inspector = document.getElementById('inspector');
const status = document.getElementById('status');
const zoomValue = document.getElementById('zoom-value');
const search = document.getElementById('search');
const entities = [...svg.querySelectorAll('.entity')];
const relations = [...svg.querySelectorAll('.relation')];
let scale = 1, selected = null, dragging = null, moved = false;
const escape = value => String(value).replace(/[&<>"']/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]));
function zoom(next, x=viewport.clientWidth/2, y=viewport.clientHeight/2) {
next = Math.max(.06,Math.min(2.5,next));
const worldX = (viewport.scrollLeft+x-20)/scale;
const worldY = (viewport.scrollTop+y-20)/scale;
scale = next;
svg.style.width = `${data.width*scale}px`;
svg.style.height = `${data.height*scale}px`;
viewport.scrollLeft = worldX*scale-x+20;
viewport.scrollTop = worldY*scale-y+20;
zoomValue.value = `${Math.round(scale*100)}%`;
}
function fit() {
zoom(Math.min((viewport.clientWidth-40)/data.width,(viewport.clientHeight-40)/data.height));
viewport.scrollTo(0,0);
}
function highlight(name, edgeNumber=null) {
svg.classList.toggle('schema-focused',Boolean(name || edgeNumber));
const connected = new Set(name?[name]:[]);
relations.forEach(r=>{
const active = edgeNumber ? Number(r.dataset.number)===edgeNumber : name && (r.dataset.source===name || r.dataset.target===name);
r.classList.toggle('active',Boolean(active));
if(active){connected.add(r.dataset.source);connected.add(r.dataset.target);}
});
entities.forEach(e=>{e.classList.toggle('selected',e.dataset.table===name);e.classList.toggle('related',connected.has(e.dataset.table));});
}
function clear() {
selected = null;
inspector.hidden = true;
highlight(null);
status.textContent = 'Все @@TABLE_COUNT@@ таблиц и @@FK_COUNT@@ связей на одном полотне. Стрелки: FK → PK/UQ. ● NOT NULL · ○ NULL';
}
function focus(name) {
if(!data.tables[name])return;
select(name);
zoom(1);
const t = data.tables[name];
viewport.scrollLeft = t.x*scale-viewport.clientWidth/2+t.width*scale/2+20;
viewport.scrollTop = t.y*scale-60;
}
function edgeList(edges,direction) {
if(!edges.length)return '<p>Нет.</p>';
return '<ul class="link-list">'+edges.map(e=>`<li><button type="button" data-link="${escape(direction==='out'?e.target:e.source)}" data-edge="${e.number}"><code>FK${String(e.number).padStart(2,'0')} · ${escape(e.source)}.${escape(e.columns.join(', '))} → ${escape(e.target)}.${escape(e.keys.join(', '))}</code></button><small>ON DELETE ${escape(e.action)} · ${data.tables[e.source].columns[e.column].nn?'обязательная ссылка':'NULL допустим'}</small></li>`).join('')+'</ul>';
}
function select(name) {
selected = name;
highlight(name);
const table = data.tables[name];
const outgoing = data.edges.filter(e=>e.source===name);
const incoming = data.edges.filter(e=>e.target===name);
inspector.innerHTML = `<button class="close" type="button" aria-label="Закрыть сведения">×</button><h2>${escape(name)}</h2><p>${escape(table.label)}</p><p>${Object.keys(table.columns).length} столбцов · ${outgoing.length} исходящих FK · ${incoming.length} входящих FK</p><h3>Исходящие связи</h3>${edgeList(outgoing,'out')}<h3>Входящие связи</h3>${edgeList(incoming,'in')}<h3>Ограничения</h3>${table.constraints.length?table.constraints.map(c=>`<code class="constraint">${escape(c)}</code>`).join(''):'<p>Отдельные ограничения не объявлены.</p>'}<h3>Явные индексы</h3>${table.indexes.length?table.indexes.map(c=>`<code class="constraint">${escape(c)}</code>`).join(''):'<p>Нет. Индексы PK и UNIQUE создаются PostgreSQL автоматически.</p>'}`;
inspector.hidden = false;
inspector.querySelector('.close').addEventListener('click',clear);
inspector.querySelectorAll('[data-link]').forEach(button=>button.addEventListener('click',()=>focus(button.dataset.link)));
status.textContent = `${name} · ${outgoing.length} исходящих и ${incoming.length} входящих FK · все остальные таблицы остаются на полотне`;
}
entities.forEach(entity=>{
const name = entity.dataset.table;
entity.addEventListener('mouseenter',()=>{if(!selected && !dragging)highlight(name);});
entity.addEventListener('mouseleave',()=>{if(!selected)highlight(null);});
entity.addEventListener('click',()=>{if(!moved)select(name);});
entity.addEventListener('dblclick',()=>focus(name));
entity.addEventListener('keydown',e=>{if(e.key==='Enter'||e.key===' '){e.preventDefault();select(name);}});
});
relations.forEach(relation=>{
relation.addEventListener('mouseenter',()=>{
if(!selected)highlight(null,Number(relation.dataset.number));
const e = data.edges.find(e=>e.number===Number(relation.dataset.number));
status.textContent = `FK${String(e.number).padStart(2,'0')}: ${e.source}.${e.column} → ${e.target}.${e.key} · ON DELETE ${e.action}`;
});
relation.addEventListener('mouseleave',()=>{if(!selected){highlight(null);status.textContent='Все @@TABLE_COUNT@@ таблиц и @@FK_COUNT@@ связей на одном полотне. Стрелки: FK → PK/UQ. ● NOT NULL · ○ NULL';}});
});
document.getElementById('zoom-in').addEventListener('click',()=>zoom(scale*1.25));
document.getElementById('zoom-out').addEventListener('click',()=>zoom(scale/1.25));
document.getElementById('actual').addEventListener('click',()=>zoom(1));
document.getElementById('fit').addEventListener('click',()=>{clear();fit();});
document.getElementById('clear').addEventListener('click',clear);
viewport.addEventListener('wheel',e=>{
if(!e.ctrlKey&&!e.metaKey)return;
e.preventDefault();
const rect=viewport.getBoundingClientRect();
zoom(scale*Math.exp(-e.deltaY*.002),e.clientX-rect.left,e.clientY-rect.top);
},{passive:false});
viewport.addEventListener('pointerdown',e=>{
if(e.button!==0||e.target.closest('.entity'))return;
dragging={x:e.clientX,y:e.clientY,left:viewport.scrollLeft,top:viewport.scrollTop};
moved=false;
viewport.setPointerCapture(e.pointerId);
viewport.classList.add('dragging');
});
viewport.addEventListener('pointermove',e=>{
if(!dragging)return;
const dx=e.clientX-dragging.x,dy=e.clientY-dragging.y;
moved=moved||Math.abs(dx)+Math.abs(dy)>4;
viewport.scrollLeft=dragging.left-dx;viewport.scrollTop=dragging.top-dy;
});
function stop(){if(dragging&&!moved)clear();dragging=null;viewport.classList.remove('dragging');setTimeout(()=>{moved=false;},0);}
viewport.addEventListener('pointerup',stop);viewport.addEventListener('pointercancel',stop);
document.addEventListener('keydown',e=>{if(e.key==='Escape')clear();});
const names = document.getElementById('table-names');
Object.keys(data.tables).sort().forEach(name=>{const option=document.createElement('option');option.value=name;option.label=data.tables[name].label;names.append(option);});
function searchTable(){const term=search.value.trim().toLowerCase();const name=data.tables[term]?term:Object.keys(data.tables).find(n=>n.includes(term)||data.tables[n].label.toLowerCase().includes(term));if(term&&name)focus(name);}
search.addEventListener('change',searchTable);search.addEventListener('keydown',e=>{if(e.key==='Enter')searchTable();});
requestAnimationFrame(fit);
window.addEventListener('resize',()=>{if(scale<.3)fit();});
})();
</script>
</body>
</html>
+390
View File
@@ -0,0 +1,390 @@
#!/usr/bin/env python3
"""Собирает единую полную схему из DDL; база данных не используется."""
from pathlib import Path
from html import escape as esc
import hashlib
import re
ROOT = Path(__file__).resolve().parents[2]
SOURCE = ROOT / 'backend/src/main/resources/db/migration/V1__init.sql'
OUTPUT = Path(__file__).with_name('database-schema.html')
RAW = SOURCE.read_text()
def clean_sql(text):
# Строки сохраняются; комментарии и тела процедур не участвуют в разборе DDL.
pattern = r"('(?:''|[^'])*')|\$\$.*?\$\$|--[^\n]*|/\*.*?\*/"
return re.sub(pattern, lambda m: m[1] or ' ', text, flags=re.S)
def split_top(text, separator=','):
parts, start, depth, quoted, i = [], 0, 0, False, 0
while i < len(text):
char = text[i]
if char == "'":
if quoted and i + 1 < len(text) and text[i + 1] == "'":
i += 2
continue
quoted = not quoted
if not quoted:
depth += (char == '(') - (char == ')')
if char == separator and depth == 0:
parts.append(text[start:i].strip())
start = i + 1
i += 1
parts.append(text[start:].strip())
return parts
TABLES, FKS = {}, []
def add_fk(table, columns, target, keys, action=None):
columns = [c.strip() for c in columns.split(',')]
keys = [k.strip() for k in keys.split(',')]
assert len(columns) == len(keys)
FKS.append(dict(source=table, columns=columns, column=columns[0], target=target,
keys=keys, key=keys[0], action=action or 'NO ACTION'))
def constraint_fk(table, entry):
ref = re.search(r'FOREIGN KEY\s*\(([^)]+)\)\s+REFERENCES\s+(\w+)\s*\(([^)]+)\)(?:\s+ON DELETE\s+(CASCADE|SET NULL|RESTRICT|NO ACTION))?', entry)
if ref:
columns, target, keys, action = ref.groups()
add_fk(table, columns, target, keys, action)
def add_column(table, definition):
match = re.match(r'(\w+)\s+((?:BIGSERIAL|BIGINT|SMALLINT|INTEGER|INT|BOOLEAN|DATE|TIME\b|TIMESTAMPTZ|TEXT|VARCHAR)(?:\s*\(\d+\))?)', definition, re.I)
if not match:
raise ValueError(f'Не удалось разобрать столбец {table}: {definition}')
name, sql_type = match.groups()
pk = 'PRIMARY KEY' in definition
TABLES[table]['columns'][name] = dict(name=name, type=sql_type.upper(), pk=pk,
nn=pk or 'NOT NULL' in definition, uq=bool(re.search(r'\bUNIQUE\b', definition)), ddl=definition)
ref = re.search(r'REFERENCES\s+(\w+)\s*\((\w+)\)(?:\s+ON DELETE\s+(CASCADE|SET NULL|RESTRICT|NO ACTION))?', definition, re.I)
if ref:
target, key, action = ref.groups()
add_fk(table, name, target, key, action)
for statement in split_top(clean_sql(RAW), ';'):
statement = ' '.join(statement.split())
create = re.match(r'CREATE TABLE (?:IF NOT EXISTS )?(\w+)\s*\((.*)\)$', statement, re.S)
if create:
table, body = create.groups()
TABLES[table] = dict(columns={}, constraints=[], indexes=[])
for entry in split_top(body):
if re.match(r'(CONSTRAINT|PRIMARY|UNIQUE|CHECK|FOREIGN|EXCLUDE)\b', entry):
TABLES[table]['constraints'].append(entry)
constraint_fk(table, entry)
key = re.search(r'PRIMARY KEY\s*\(([^)]+)\)', entry)
if key:
for name in key[1].split(','):
TABLES[table]['columns'][name.strip()].update(pk=True, nn=True)
else:
add_column(table, entry)
continue
alter = re.match(r'ALTER TABLE (\w+) (.*)', statement, re.S)
if alter:
table, body = alter.groups()
for entry in split_top(body):
if entry.startswith('ADD COLUMN '):
add_column(table, entry[len('ADD COLUMN '):])
elif entry.startswith('ALTER COLUMN ') and entry.endswith(' SET NOT NULL'):
TABLES[table]['columns'][entry.split()[2]]['nn'] = True
elif entry.startswith('DROP CONSTRAINT '):
# Единственное удаление в baseline — старый UNIQUE(group_id, name).
if table == 'subgroups':
TABLES[table]['constraints'] = [x for x in TABLES[table]['constraints'] if x != 'UNIQUE(group_id, name)']
elif entry.startswith('ADD CONSTRAINT '):
TABLES[table]['constraints'].append(entry[4:])
constraint_fk(table, entry)
elif entry.startswith('VALIDATE CONSTRAINT '):
constraint_name = entry.split()[2]
TABLES[table]['constraints'] = [
re.sub(r' NOT VALID$', '', c) if c.startswith('CONSTRAINT ' + constraint_name + ' ') else c
for c in TABLES[table]['constraints']
]
continue
index = re.match(r'CREATE (?:UNIQUE )?INDEX (?:IF NOT EXISTS )?(\w+) ON (\w+)\b', statement)
if index:
TABLES[index[2]]['indexes'].append(statement)
ROUTES = []
for number, fk in enumerate(FKS, 1):
fk['number'] = number
for part, (column, key) in enumerate(zip(fk['columns'], fk['keys'])):
assert column in TABLES[fk['source']]['columns'], fk
assert key in TABLES[fk['target']]['columns'], fk
TABLES[fk['source']]['columns'][column].setdefault('fks', []).append(fk)
ROUTES.append(dict(fk, column=column, key=key, part=part))
LABELS = {
'schedule_rule_loads':'Нагрузка правила по видам занятий',
'departments':'Кафедры', 'specialties':'Направления подготовки', 'specialty_profiles':'Профили подготовки',
'users':'Пользователи', 'auth_refresh_tokens':'Refresh-токены', 'auth_login_rate_limits':'Ограничение попыток входа', 'auth_login_attempt_audit':'Аудит неудачных входов',
'teacher_department_assignments':'История принадлежности к кафедрам', 'teacher_creation_requests':'Заявки на создание преподавателя',
'education_forms':'Формы обучения', 'student_groups':'Студенческие группы', 'subgroups':'Подгруппы',
'subjects':'Дисциплины', 'subject_comments':'Комментарии к дисциплинам', 'lesson_types':'Виды занятий',
'equipments':'Оборудование', 'classrooms':'Аудитории', 'classroom_equipments':'Оснащение аудиторий', 'teacher_subjects':'Закрепление дисциплин за преподавателями',
'time_slot_scopes':'Наборы звонков', 'time_slots':'Временные слоты', 'time_slot_date_assignments':'Наборы звонков по датам',
'academic_years':'Учебные годы', 'semesters':'Семестры', 'academic_calendar_activity_types':'Виды учебной активности',
'academic_calendars':'Учебные календари', 'academic_calendar_periods':'Календарные периоды', 'academic_calendar_subjects':'Дисциплины календаря',
'student_group_calendar_assignments':'Назначения календарей группам', 'schedule_rules':'Правила расписания',
'schedule_rule_groups':'Группы правила', 'schedule_rule_slots':'Повторяющиеся занятия', 'schedule_rule_slot_subgroups':'Подгруппы занятия',
'schedule_overrides':'Точечные изменения занятий', 'teacher_absences':'Отсутствия преподавателей', 'teacher_absence_decisions':'Решения мастера замены',
'teacher_preferences':'Пожелания преподавателей', 'teacher_change_requests':'Заявки на изменение занятия', 'teacher_change_request_history':'История согласования заявки',
'schedule_versions':'Версии расписания', 'schedule_version_history':'История версий расписания',
'study_plans':'Учебные планы', 'study_plan_subjects':'Дисциплины учебного плана', 'study_plan_loads':'Нагрузка учебного плана', 'student_group_plan_assignments':'Назначения планов группам',
}
# Все таблицы располагаются на одном полотне. Колонки задают только компоновку:
# между ними сохраняются все связи, включая служебные и самоссылки.
COLUMNS = [
('ГРУППЫ И НАПРАВЛЕНИЯ', ['specialties', 'specialty_profiles', 'education_forms', 'student_groups', 'subgroups']),
('УЧЕБНЫЙ КАЛЕНДАРЬ', ['academic_years', 'semesters', 'academic_calendars', 'academic_calendar_activity_types', 'academic_calendar_periods', 'academic_calendar_subjects', 'student_group_calendar_assignments']),
('ПЛАНЫ И ВРЕМЯ', ['study_plans', 'study_plan_subjects', 'study_plan_loads', 'student_group_plan_assignments', 'time_slot_scopes', 'time_slots', 'time_slot_date_assignments']),
('ПОЛЬЗОВАТЕЛИ И КАФЕДРЫ', ['auth_login_rate_limits', 'auth_login_attempt_audit', 'departments', 'users', 'auth_refresh_tokens', 'teacher_department_assignments', 'teacher_creation_requests']),
('РАСПИСАНИЕ', ['schedule_versions', 'schedule_version_history', 'schedule_rules', 'schedule_rule_loads', 'schedule_rule_groups', 'schedule_rule_slots', 'schedule_rule_slot_subgroups']),
('ДИСЦИПЛИНЫ И РЕСУРСЫ', ['subjects', 'lesson_types', 'teacher_subjects', 'subject_comments', 'classrooms', 'equipments', 'classroom_equipments']),
('ИЗМЕНЕНИЯ И ЗАЯВКИ', ['teacher_preferences', 'teacher_change_requests', 'teacher_change_request_history', 'schedule_overrides', 'teacher_absences', 'teacher_absence_decisions']),
]
assert set(TABLES) == set(LABELS) == {t for _, tables in COLUMNS for t in tables}
assert sum(len(tables) for _, tables in COLUMNS) == len(TABLES)
WIDTH, TABLE_WIDTH, HEADER, ROW = 4864, 512, 64, 28
PAPER, INK, MUTED, ACCENT = '#f8fafc', '#0f172a', '#475569', '#4f46e5'
def svg_text(x, y, value, size=12, fill=INK, weight=400, anchor='start', mono=False):
return f'<text x="{x}" y="{y}" font-size="{size}" fill="{fill}" font-weight="{weight}" text-anchor="{anchor}" class="{"mono" if mono else "sans"}">{esc(str(value))}</text>'
def layout():
from collections import defaultdict
colmap = {name: i for i, (_, names) in enumerate(COLUMNS) for name in names}
ports = defaultdict(list)
for e in ROUTES:
e['source_side'] = 'right' if colmap[e['target']] >= colmap[e['source']] else 'left'
e['target_side'] = 'left' if colmap[e['source']] < colmap[e['target']] else 'right'
ports[e['source'], e['column'], e['source_side']].append((e, 'start'))
ports[e['target'], e['key'], e['target_side']].append((e, 'end'))
positions = {}
for ci, (_, names) in enumerate(COLUMNS):
y = 152
for name in names:
rows, offset = {}, HEADER
for column, c in TABLES[name]['columns'].items():
n = max(len(ports[name, column, side]) for side in ['left', 'right'])
height = max(ROW, (n + 1) * 12)
rows[column] = dict(top=y+offset, height=height, center=y+offset+height/2)
offset += height
positions[name] = dict(x=64+ci*704, y=y, width=TABLE_WIDTH, height=offset, rows=rows, column=ci)
y += offset + 112
for e in ROUTES:
src, dst = positions[e['source']], positions[e['target']]
for kind, node, field, side in [('start', src, e['column'], e['source_side']),
('end', dst, e['key'], e['target_side'])]:
row = node['rows'][field]
attachments = ports[e['source'] if kind == 'start' else e['target'], field, side]
index = next(i for i, (route, endpoint) in enumerate(attachments) if route is e and endpoint == kind)
port = row['top'] + row['height'] * (index+1)/(len(attachments)+1)
e[kind] = (node['x'] + (TABLE_WIDTH if side == 'right' else 0), port)
e['start_stub'] = (e['start'][0] + (24 if e['source_side'] == 'right' else -24), e['start'][1])
e['end_stub'] = (e['end'][0] + (24 if e['target_side'] == 'right' else -24), e['end'][1])
height = int(max(p['y']+p['height'] for p in positions.values())+152)
return positions, height
def route_all(positions, height):
"""Ортогональные пути по свободным коридорам с учётом занятых трасс."""
import heapq
xs = {16, 28, 40, WIDTH-40, WIDTH-28, WIDTH-16}
for ci in range(len(COLUMNS)-1):
xs.update(64+ci*704+TABLE_WIDTH+24+j*12 for j in range(13))
ys = {28, 40, 52, 64, 88, 100, height-100, height-88, height-76}
for p in positions.values():
for j in range(1, 8):
ys.add(p['y']-j*12)
ys.add(p['y']+p['height']+j*12)
for e in ROUTES:
for key in ['start_stub', 'end_stub']:
xs.add(e[key][0])
ys.add(e[key][1])
xs, ys = sorted(xs), sorted(ys)
nx, ny = len(xs), len(ys)
xmap, ymap = {x:i for i,x in enumerate(xs)}, {y:i for i,y in enumerate(ys)}
barriers = []
for a,b in zip(xs,xs[1:]):
barriers.append(next((ci for ci in range(len(COLUMNS)) if a < 64+ci*704 < b), -1))
occupied = []
for ci in range(len(COLUMNS)):
boxes = [p for p in positions.values() if p['column'] == ci]
occupied.append([any(p['y']-12 <= y <= p['y']+p['height']+12 for p in boxes) for y in ys])
used = {}
def route(e):
start = (xmap[e['start_stub'][0]],ymap[e['start_stub'][1]])
goal = (xmap[e['end_stub'][0]],ymap[e['end_stub'][1]])
sx,sy = start
gx,gy = goal
initial = (sy*nx+sx)*2
queue = [(0, 0, initial)]
best, previous = {initial:0}, {}
final = None
while queue:
_, cost, state = heapq.heappop(queue)
if cost != best.get(state):
continue
axis, node = state%2, state//2
yi,xi = divmod(node,nx)
if (xi,yi) == goal:
final = state
break
options = []
if xi > 0 and (barriers[xi-1] < 0 or not occupied[barriers[xi-1]][yi]):
options.append((xi-1,yi,0,xs[xi]-xs[xi-1]))
if xi+1 < nx and (barriers[xi] < 0 or not occupied[barriers[xi]][yi]):
options.append((xi+1,yi,0,xs[xi+1]-xs[xi]))
if yi > 0:
options.append((xi,yi-1,1,ys[yi]-ys[yi-1]))
if yi+1 < ny:
options.append((xi,yi+1,1,ys[yi+1]-ys[yi]))
for xx,yy,aa,length in options:
neighbor = yy*nx+xx
key = (min(node,neighbor), max(node,neighbor))
nxt = neighbor*2+aa
new_cost = cost + length*(1+used.get(key,0)*1.4) + (20 if aa != axis else 0)
if new_cost < best.get(nxt,float('inf')):
best[nxt], previous[nxt] = new_cost, state
heuristic = abs(xs[xx]-xs[gx])+abs(ys[yy]-ys[gy])
heapq.heappush(queue,(new_cost+heuristic,new_cost,nxt))
if final is None:
raise ValueError(f'Не удалось провести FK {e["source"]}.{e["column"]}')
path = []
while True:
yi,xi = divmod(final//2,nx)
path.append((xs[xi],ys[yi]))
if final == initial:
break
before = previous[final]
a,b = final//2,before//2
key = (min(a,b),max(a,b))
used[key] = used.get(key,0)+1
final = before
path.reverse()
points = [e['start']] + path + [e['end']]
simplified = []
for p in points:
if simplified and p == simplified[-1]:
continue
if len(simplified)>1 and ((simplified[-2][0] == simplified[-1][0] == p[0]) or (simplified[-2][1] == simplified[-1][1] == p[1])):
simplified[-1] = p
else:
simplified.append(p)
e['points'] = simplified
# Короткие связи получают ближайшие коридоры, длинные обходят их.
for e in sorted(ROUTES,key=lambda e: sum(abs(a-b) for a,b in zip(e['start'],e['end']))):
route(e)
def rounded_path(points):
import math
result = f'M {points[0][0]:g} {points[0][1]:g}'
for a,b,c in zip(points,points[1:],points[2:]):
ab,bc = math.dist(a,b),math.dist(b,c)
radius = min(8,ab/2,bc/2)
before = tuple(b[i]+(a[i]-b[i])*radius/ab for i in range(2))
after = tuple(b[i]+(c[i]-b[i])*radius/bc for i in range(2))
result += f' L {before[0]:g} {before[1]:g} Q {b[0]:g} {b[1]:g} {after[0]:g} {after[1]:g}'
return result+f' L {points[-1][0]:g} {points[-1][1]:g}'
def build_svg(positions, height):
parts = [f'<svg id="schema" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {WIDTH} {height}" width="{WIDTH}" height="{height}" role="img" aria-labelledby="database-schema-title database-schema-desc">',
'<title id="database-schema-title">Полная схема базы данных «Магистр»</title>',
f'<desc id="database-schema-desc">Все {len(TABLES)} таблиц, {sum(len(t["columns"]) for t in TABLES.values())} столбцов и {len(FKS)} внешних ключей одной tenant-БД на едином полотне.</desc>',
'<defs><marker id="fk-arrow" viewBox="0 0 8 8" refX="7" refY="4" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M 1 1 L 7 4 L 1 7" fill="none" stroke="context-stroke" stroke-width="1.4"/></marker></defs>',
f'<rect width="{WIDTH}" height="{height}" fill="{PAPER}"/>',
svg_text(64,44,'МАГИСТР / ПОЛНАЯ ФИЗИЧЕСКАЯ СХЕМА',20,INK,600),
svg_text(64,72,f'{len(TABLES)} таблиц · {sum(len(t["columns"]) for t in TABLES.values())} столбцов · {len(FKS)} FK · одна tenant-БД · источник: V1__init.sql',12,MUTED)]
for ci,(title,_) in enumerate(COLUMNS):
parts.append(svg_text(64+ci*704,124,title,14,MUTED,600))
parts.append('<g id="relations">')
for e in ROUTES:
label = f'FK{e["number"]:02}: {e["source"]}.({", ".join(e["columns"])}) → {e["target"]}.({", ".join(e["keys"])}) · ON DELETE {e["action"]}'
path = rounded_path(e['points'])
parts.append(f'<g id="fk-{e["number"]}-{e["part"]}" class="relation" data-source="{e["source"]}" data-target="{e["target"]}" data-number="{e["number"]}"><title>{esc(label)}</title><path class="wire-under" d="{path}"/><path class="wire" d="{path}" marker-end="url(#fk-arrow)"/><path class="wire-hit" d="{path}"/></g>')
parts.append('</g><g id="tables">')
for name,table in TABLES.items():
p = positions[name]
x,y,w,h = p['x'],p['y'],p['width'],p['height']
outgoing = [e for e in FKS if e['source'] == name]
incoming = [e for e in FKS if e['target'] == name]
parts.append(f'<g class="entity" id="table-{name}" data-table="{name}" tabindex="0" role="button" aria-label="{name}: {LABELS[name]}">')
parts.append(f'<title>{esc(name+": "+LABELS[name])}\n{len(table["columns"])} столбцов · {len(outgoing)} исходящих и {len(incoming)} входящих FK</title>')
parts.append(f'<rect class="table-box" x="{x}" y="{y}" width="{w}" height="{h}" rx="6"/>')
parts.append(f'<path d="M {x+6} {y} H {x+w-6} Q {x+w} {y} {x+w} {y+6} V {y+HEADER} H {x} V {y+6} Q {x} {y} {x+6} {y} Z" fill="{"#eeedff" if name in ["users","schedule_rules"] else "#e8edf3"}"/>')
parts += [svg_text(x+16,y+26,name,16,INK,600),svg_text(x+16,y+48,LABELS[name],12,MUTED)]
for i,(column,c) in enumerate(table['columns'].items()):
row = p['rows'][column]
top,cy,rh = row['top'],row['center'],row['height']
parts.append(f'<g data-column="{column}" data-row-top="{top}" data-row-height="{rh}">')
parts.append(f'<title>{esc(c["ddl"])}</title>')
parts.append(f'<rect x="{x+1}" y="{top}" width="{w-2}" height="{rh}" fill="{"#eef2f7" if i%2==0 else PAPER}"/>')
flags = []
if c['pk']:
flags.append('PK')
for fk in c.get('fks', []):
flags.append(f'FK{fk["number"]:02}')
if c['uq']:
flags.append('UQ')
if flags:
parts.append(svg_text(x+12,cy+4,'·'.join(flags),9,ACCENT if c['pk'] else MUTED,mono=True))
parts += [svg_text(x+82,cy+4,column,13),svg_text(x+w-44,cy+4,c['type'].lower(),11,MUTED,anchor='end',mono=True),
svg_text(x+w-18,cy+4,'●' if c['nn'] else '○',10,MUTED,anchor='middle')]
parts.append('</g>')
parts.append('</g>')
parts.append('</g>')
parts += [svg_text(64,height-92,f'PK — первичный ключ FK01…FK{len(FKS):02} — внешние ключи UQ — одиночный UNIQUE ● NOT NULL ○ NULL',13,MUTED),
svg_text(64,height-64,'Каждая стрелка: столбец FK → столбец PK. Имя связи и ON DELETE доступны при наведении на линию или выборе таблицы.',13,MUTED),
svg_text(64,height-36,'Составные FK показаны отдельными линиями столбцов с одним номером. version_group_id и semester_number не являются REFERENCES.',12,MUTED),'</svg>']
return ''.join(parts)
def verify_geometry(positions):
# Трассы не должны проходить через таблицы; пересечения связей допустимы.
for e in ROUTES:
assert e['start'] == e['points'][0] and e['end'] == e['points'][-1]
for a,b in zip(e['points'],e['points'][1:]):
assert a[0] == b[0] or a[1] == b[1], e
for name,p in positions.items():
left,right,top,bottom = p['x'],p['x']+p['width'],p['y'],p['y']+p['height']
if a[1] == b[1]:
through = top+.1 < a[1] < bottom-.1 and max(min(a[0],b[0]),left+.1) < min(max(a[0],b[0]),right-.1)
else:
through = left+.1 < a[0] < right-.1 and max(min(a[1],b[1]),top+.1) < min(max(a[1],b[1]),bottom-.1)
assert not through, (e['source'],e['column'],name,a,b)
def generate():
import json
positions,height = layout()
route_all(positions,height)
verify_geometry(positions)
svg = build_svg(positions,height)
metadata = dict(width=WIDTH,height=height,source='V1__init.sql',sha256=hashlib.sha256(RAW.encode()).hexdigest(),
tables={name:dict(label=LABELS[name],columns=table['columns'],constraints=table['constraints'],indexes=table['indexes'],**positions[name]) for name,table in TABLES.items()},
edges=[{k:v for k,v in e.items() if k not in ['points','start_stub','end_stub']} for e in FKS])
template = Path(__file__).with_name('database-schema.template.html').read_text()
html = template.replace('@@SCHEMA@@',svg).replace('@@DATA@@',json.dumps(metadata,ensure_ascii=False).replace('<','\\u003c'))
html = html.replace('@@SHA@@',metadata['sha256'][:12]).replace('@@TABLE_COUNT@@',str(len(TABLES))).replace('@@COLUMN_COUNT@@',str(sum(len(t['columns']) for t in TABLES.values()))).replace('@@FK_COUNT@@',str(len(FKS)))
OUTPUT.write_text(html)
print(f'Создана единая схема: {OUTPUT}\nТаблиц: {len(TABLES)}; столбцов: {sum(len(t["columns"]) for t in TABLES.values())}; связей: {len(FKS)}; полотно: {WIDTH} × {height}')
if __name__ == '__main__':
generate()
+1 -5
View File
@@ -212,11 +212,7 @@ export function ruleMeta(rule, { groups, semesters }) {
// --- Типы занятий --- // --- Типы занятий ---
export function lessonTypeKey(lessonType) { export function lessonTypeKey(lessonType) {
const name = String(lessonType.name || lessonType.lessonType || '').toLowerCase(); return { LECTURE: 'lecture', LABORATORY: 'laboratory', PRACTICE: 'practice' }[lessonType.code] || null;
if (name.includes('лекц')) return 'lecture';
if (name.includes('лаб')) return 'laboratory';
if (name.includes('практ')) return 'practice';
return null;
} }
export function lessonTypeKeyById(lessonTypeId, lessonTypes) { export function lessonTypeKeyById(lessonTypeId, lessonTypes) {
+11 -2
View File
@@ -269,6 +269,7 @@ import {
buildRulePayloadFromRule, buildRulePayloadFromRule,
fetchRuleSubjectOptions, fetchRuleSubjectOptions,
formSlotsToPayloads, formSlotsToPayloads,
lessonTypeKey,
ruleSubjectOptionsEndpoint, ruleSubjectOptionsEndpoint,
validateTypeLimits validateTypeLimits
} from '../react/admin/schedule-service.js'; } from '../react/admin/schedule-service.js';
@@ -2663,10 +2664,18 @@ test('вкладка просмотра расписаний рендерит ф
assert.doesNotMatch(markup, /style="/); assert.doesNotMatch(markup, /style="/);
}); });
test('категория занятия определяется кодом и сохраняется при переименовании', () => {
assert.equal(lessonTypeKey({ code: 'LECTURE', name: 'Занятие А' }), 'lecture');
assert.equal(lessonTypeKey({ code: 'LABORATORY', name: 'Занятие Б' }), 'laboratory');
assert.equal(lessonTypeKey({ code: 'PRACTICE', name: 'Лабораторная работа' }), 'practice');
assert.equal(lessonTypeKey({ name: 'Лекция' }), null);
assert.equal(lessonTypeKey({ code: 'CONSULTATION', name: 'Лекция' }), null);
});
test('payload правила расписания валидируется как в legacy-конструкторе', () => { test('payload правила расписания валидируется как в legacy-конструкторе', () => {
const lessonTypes = [ const lessonTypes = [
{ id: 1, name: 'Лекция' }, { id: 1, name: 'Лекция', code: 'LECTURE' },
{ id: 2, name: 'Лабораторная работа' } { id: 2, name: 'Лабораторная работа', code: 'LABORATORY' }
]; ];
const subgroups = [ const subgroups = [
{ id: 11, groupId: 5, name: '1 подгруппа', groupName: 'Группа А' }, { id: 11, groupId: 5, name: '1 подгруппа', groupName: 'Группа А' },