feat: add IF NOT EXISTS to migrations, add courses nav item, lock playwright deps
This commit is contained in:
@@ -1,35 +1,35 @@
|
||||
CREATE TABLE courses (
|
||||
CREATE TABLE IF NOT EXISTS courses (
|
||||
id INTEGER PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
semester TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE tutors (
|
||||
CREATE TABLE IF NOT EXISTS tutors (
|
||||
id INTEGER PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
email TEXT UNIQUE NOT NULL,
|
||||
password_hash TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE tutor_courses (
|
||||
CREATE TABLE IF NOT EXISTS tutor_courses (
|
||||
tutor_id INTEGER NOT NULL REFERENCES tutors(id),
|
||||
course_id INTEGER NOT NULL REFERENCES courses(id),
|
||||
PRIMARY KEY (tutor_id, course_id)
|
||||
);
|
||||
|
||||
CREATE TABLE students (
|
||||
CREATE TABLE IF NOT EXISTS students (
|
||||
id INTEGER PRIMARY KEY,
|
||||
course_id INTEGER NOT NULL REFERENCES courses(id),
|
||||
name TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE rooms (
|
||||
CREATE TABLE IF NOT EXISTS rooms (
|
||||
id INTEGER PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
layout_json TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE sessions (
|
||||
CREATE TABLE IF NOT EXISTS sessions (
|
||||
id INTEGER PRIMARY KEY,
|
||||
course_id INTEGER NOT NULL REFERENCES courses(id),
|
||||
week_nr INTEGER NOT NULL,
|
||||
@@ -37,7 +37,7 @@ CREATE TABLE sessions (
|
||||
UNIQUE(course_id, week_nr)
|
||||
);
|
||||
|
||||
CREATE TABLE slots (
|
||||
CREATE TABLE IF NOT EXISTS slots (
|
||||
id INTEGER PRIMARY KEY,
|
||||
session_id INTEGER NOT NULL REFERENCES sessions(id),
|
||||
room_id INTEGER REFERENCES rooms(id),
|
||||
@@ -48,7 +48,7 @@ CREATE TABLE slots (
|
||||
code TEXT UNIQUE
|
||||
);
|
||||
|
||||
CREATE TABLE attendances (
|
||||
CREATE TABLE IF NOT EXISTS attendances (
|
||||
id INTEGER PRIMARY KEY,
|
||||
slot_id INTEGER NOT NULL REFERENCES slots(id),
|
||||
student_id INTEGER NOT NULL REFERENCES students(id),
|
||||
@@ -58,7 +58,7 @@ CREATE TABLE attendances (
|
||||
UNIQUE(slot_id, seat_id)
|
||||
);
|
||||
|
||||
CREATE TABLE notes (
|
||||
CREATE TABLE IF NOT EXISTS notes (
|
||||
id INTEGER PRIMARY KEY,
|
||||
slot_id INTEGER NOT NULL REFERENCES slots(id),
|
||||
student_id INTEGER NOT NULL REFERENCES students(id),
|
||||
@@ -69,11 +69,11 @@ CREATE TABLE notes (
|
||||
);
|
||||
|
||||
-- Indexes on high-frequency FK columns (SQLite does not auto-index FKs)
|
||||
CREATE INDEX idx_students_course ON students(course_id);
|
||||
CREATE INDEX idx_sessions_course ON sessions(course_id);
|
||||
CREATE INDEX idx_slots_session ON slots(session_id);
|
||||
CREATE INDEX idx_slots_tutor ON slots(tutor_id);
|
||||
CREATE INDEX idx_attendances_slot ON attendances(slot_id);
|
||||
CREATE INDEX idx_attendances_student ON attendances(student_id);
|
||||
CREATE INDEX idx_notes_slot ON notes(slot_id);
|
||||
CREATE INDEX idx_notes_student ON notes(student_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_students_course ON students(course_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_sessions_course ON sessions(course_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_slots_session ON slots(session_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_slots_tutor ON slots(tutor_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_attendances_slot ON attendances(slot_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_attendances_student ON attendances(student_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_notes_slot ON notes(slot_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_notes_student ON notes(student_id);
|
||||
|
||||
Reference in New Issue
Block a user