diff --git a/server/.sqlx/query-1ffddd843ece79fa10cfb98c2e8aff2842cad45867c3a72f807ae08c1b10cb37.json b/server/.sqlx/query-1ffddd843ece79fa10cfb98c2e8aff2842cad45867c3a72f807ae08c1b10cb37.json deleted file mode 100644 index 0d37f5584..000000000 --- a/server/.sqlx/query-1ffddd843ece79fa10cfb98c2e8aff2842cad45867c3a72f807ae08c1b10cb37.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "INSERT INTO calendar (id,room_code,start_at,end_at,stp_title_de,stp_title_en,stp_type,entry_type,detailed_entry_type)\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)\n ON CONFLICT (id) DO UPDATE SET\n room_code = EXCLUDED.room_code,\n start_at = EXCLUDED.start_at,\n end_at = EXCLUDED.end_at,\n stp_title_de = EXCLUDED.stp_title_de,\n stp_title_en = EXCLUDED.stp_title_en,\n stp_type = EXCLUDED.stp_type,\n entry_type = EXCLUDED.entry_type,\n detailed_entry_type = EXCLUDED.detailed_entry_type", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int4", - "Varchar", - "Timestamptz", - "Timestamptz", - "Text", - "Text", - "Text", - { - "Custom": { - "name": "eventtype", - "kind": { - "Enum": [ - "lecture", - "exercise", - "exam", - "barred", - "other" - ] - } - } - }, - "Text" - ] - }, - "nullable": [] - }, - "hash": "1ffddd843ece79fa10cfb98c2e8aff2842cad45867c3a72f807ae08c1b10cb37" -} diff --git a/server/.sqlx/query-3f063afa6b1cee235b60edc06dee94adea3223725f8906025b3abebd24704ee4.json b/server/.sqlx/query-3f063afa6b1cee235b60edc06dee94adea3223725f8906025b3abebd24704ee4.json new file mode 100644 index 000000000..ca93a020e --- /dev/null +++ b/server/.sqlx/query-3f063afa6b1cee235b60edc06dee94adea3223725f8906025b3abebd24704ee4.json @@ -0,0 +1,35 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO calendar (id,room_code,start_at,end_at,title_de,title_en,stp_type,entry_type,detailed_entry_type)\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)\n ON CONFLICT (id) DO UPDATE SET\n room_code = EXCLUDED.room_code,\n start_at = EXCLUDED.start_at,\n end_at = EXCLUDED.end_at,\n title_de = EXCLUDED.title_de,\n title_en = EXCLUDED.title_en,\n stp_type = EXCLUDED.stp_type,\n entry_type = EXCLUDED.entry_type,\n detailed_entry_type = EXCLUDED.detailed_entry_type", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int4", + "Varchar", + "Timestamptz", + "Timestamptz", + "Text", + "Text", + "Text", + { + "Custom": { + "name": "eventtype", + "kind": { + "Enum": [ + "lecture", + "exercise", + "exam", + "barred", + "other" + ] + } + } + }, + "Text" + ] + }, + "nullable": [] + }, + "hash": "3f063afa6b1cee235b60edc06dee94adea3223725f8906025b3abebd24704ee4" +} diff --git a/server/.sqlx/query-d2978b1b6a3b39bedda8e40cc2e53f91b262d8c42e7a6886ce25a14975c87f70.json b/server/.sqlx/query-46421658c130a3cdfe8fbf2d90cc2cf92df0147509f87cf194654e69c7cef696.json similarity index 77% rename from server/.sqlx/query-d2978b1b6a3b39bedda8e40cc2e53f91b262d8c42e7a6886ce25a14975c87f70.json rename to server/.sqlx/query-46421658c130a3cdfe8fbf2d90cc2cf92df0147509f87cf194654e69c7cef696.json index 3d1a0ec11..111a3f49e 100644 --- a/server/.sqlx/query-d2978b1b6a3b39bedda8e40cc2e53f91b262d8c42e7a6886ce25a14975c87f70.json +++ b/server/.sqlx/query-46421658c130a3cdfe8fbf2d90cc2cf92df0147509f87cf194654e69c7cef696.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "SELECT id,room_code,start_at,end_at,stp_title_de,stp_title_en,stp_type,entry_type AS \"entry_type!:crate::calendar::models::EventType\",detailed_entry_type\n FROM calendar\n WHERE room_code = $1 AND start_at >= $2 AND end_at <= $3", + "query": "SELECT id,room_code,start_at,end_at,title_de,title_en,stp_type,entry_type AS \"entry_type!:crate::calendar::models::EventType\",detailed_entry_type\n FROM calendar\n WHERE room_code = $1 AND start_at >= $2 AND end_at <= $3", "describe": { "columns": [ { @@ -25,12 +25,12 @@ }, { "ordinal": 4, - "name": "stp_title_de", + "name": "title_de", "type_info": "Text" }, { "ordinal": 5, - "name": "stp_title_en", + "name": "title_en", "type_info": "Text" }, { @@ -76,10 +76,10 @@ false, false, false, - false, + true, false, false ] }, - "hash": "d2978b1b6a3b39bedda8e40cc2e53f91b262d8c42e7a6886ce25a14975c87f70" + "hash": "46421658c130a3cdfe8fbf2d90cc2cf92df0147509f87cf194654e69c7cef696" } diff --git a/server/main-api/migrations/20240703163202_more_complete_calendar.down.sql b/server/main-api/migrations/20240703163202_more_complete_calendar.down.sql new file mode 100644 index 000000000..7e2f1e620 --- /dev/null +++ b/server/main-api/migrations/20240703163202_more_complete_calendar.down.sql @@ -0,0 +1,7 @@ +-- Add down migration script here + +ALTER TABLE calendar RENAME COLUMN title_de TO stp_title_de; +ALTER TABLE calendar RENAME COLUMN title_en TO stp_title_en; + +DELETE FROM calendar where stp_type is null; +ALTER TABLE calendar CHANGE COLUMN stp_type SET NOT NULL; \ No newline at end of file diff --git a/server/main-api/migrations/20240703163202_more_complete_calendar.up.sql b/server/main-api/migrations/20240703163202_more_complete_calendar.up.sql new file mode 100644 index 000000000..bc505c9a0 --- /dev/null +++ b/server/main-api/migrations/20240703163202_more_complete_calendar.up.sql @@ -0,0 +1,5 @@ +-- Add up migration script here +ALTER TABLE calendar RENAME COLUMN stp_title_de TO title_de; +ALTER TABLE calendar RENAME COLUMN stp_title_en TO title_en; + +ALTER TABLE calendar ALTER COLUMN stp_type drop not null; \ No newline at end of file diff --git a/server/main-api/src/calendar/mod.rs b/server/main-api/src/calendar/mod.rs index 4639b1cbf..c87e14b2e 100644 --- a/server/main-api/src/calendar/mod.rs +++ b/server/main-api/src/calendar/mod.rs @@ -201,7 +201,7 @@ mod tests { end_at: *TIME_2014, title_de: "Quantenteleportation".into(), title_en: "Quantum teleportation".into(), - stp_type: "Vorlesung mit Zentralübung".into(), + stp_type: Some("Vorlesung mit Zentralübung".into()), entry_type: models::EventType::Lecture, detailed_entry_type: "Abhaltung".into(), }, @@ -212,7 +212,7 @@ mod tests { end_at: *TIME_2016, title_de: "Quantenteleportation 2".into(), title_en: "Quantum teleportation 2".into(), - stp_type: "Vorlesung mit Zentralübung".into(), + stp_type: Some("Vorlesung mit Zentralübung".into()), entry_type: models::EventType::Lecture, detailed_entry_type: "Abhaltung".into(), }, @@ -223,7 +223,7 @@ mod tests { end_at: *TIME_2016, title_de: "Wartung".into(), title_en: "maintenance".into(), - stp_type: "Vorlesung mit Zentralübung".into(), + stp_type: Some("Vorlesung mit Zentralübung".into()), entry_type: models::EventType::Barred, detailed_entry_type: "Abhaltung".into(), }, @@ -234,7 +234,7 @@ mod tests { end_at: *TIME_2020, title_de: "Quantenteleportation 3".into(), title_en: "Quantum teleportation 3".into(), - stp_type: "Vorlesung".into(), + stp_type: Some("Vorlesung".into()), entry_type: models::EventType::Other, detailed_entry_type: "Abhaltung".into(), }, @@ -245,7 +245,7 @@ mod tests { end_at: *TIME_2010, title_de: "Quantenteleportation 3".into(), title_en: "Quantum teleportation 3".into(), - stp_type: "Vorlesung".into(), + stp_type: Some("Vorlesung".into()), entry_type: models::EventType::Exam, detailed_entry_type: "Abhaltung".into(), }, diff --git a/server/main-api/src/calendar/models.rs b/server/main-api/src/calendar/models.rs index 9c12a995d..fa668d14e 100644 --- a/server/main-api/src/calendar/models.rs +++ b/server/main-api/src/calendar/models.rs @@ -46,7 +46,7 @@ pub(super) struct Event { /// e.g. Quantum teleportation pub(super) title_en: String, /// e.g. Vorlesung mit Zentralübung - pub(super) stp_type: String, + pub(super) stp_type: Option, /// e.g. lecture pub(super) entry_type: EventType, /// e.g. Abhaltung