From 620fd94f8f1ee33564f7490c9ac1bb44a210615a Mon Sep 17 00:00:00 2001 From: andrewlalis Date: Thu, 23 Jan 2025 19:08:16 -0500 Subject: [PATCH] Updated service file and schema --- api/schema/classroom_compliance.sql | 8 ++++++-- teacher-tools-api.service | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/api/schema/classroom_compliance.sql b/api/schema/classroom_compliance.sql index d66666f..eaf109c 100644 --- a/api/schema/classroom_compliance.sql +++ b/api/schema/classroom_compliance.sql @@ -5,7 +5,9 @@ CREATE TABLE classroom_compliance_class ( school_year VARCHAR(9) NOT NULL, user_id BIGINT NOT NULL REFERENCES auth_user(id) - ON UPDATE CASCADE ON DELETE CASCADE + ON UPDATE CASCADE ON DELETE CASCADE, + CONSTRAINT unique_class_numbers_per_school_year + UNIQUE(number, school_year, user_id) ); CREATE TABLE classroom_compliance_student ( @@ -36,5 +38,7 @@ CREATE TABLE classroom_compliance_entry ( CONSTRAINT absence_nulls_check CHECK ( (absent AND phone_compliant IS NULL AND behavior_rating IS NULL) OR (NOT absent AND phone_compliant IS NOT NULL AND behavior_rating IS NOT NULL) - ) + ), + CONSTRAINT unique_entry_per_date + UNIQUE(class_id, student_id, date) ); diff --git a/teacher-tools-api.service b/teacher-tools-api.service index 5c8ee7f..d4063c7 100644 --- a/teacher-tools-api.service +++ b/teacher-tools-api.service @@ -1,12 +1,13 @@ [Unit] Description=teacher-tools-api -After=network.target +After=network.target postgresql.service +Wants=postgresql.service [Service] Type=simple User=root WorkingDirectory=/opt/teacher-tools -Environment="TEACHER_TOOLS_API_ENV=PROD" +EnvironmentFile=/opt/teacher-tools/prod.env ExecStart=/opt/teacher-tools/teacher-tools-api Restart=always