diff --git a/server/.sqlx/query-1ffddd843ece79fa10cfb98c2e8aff2842cad45867c3a72f807ae08c1b10cb37.json b/server/.sqlx/query-1ffddd843ece79fa10cfb98c2e8aff2842cad45867c3a72f807ae08c1b10cb37.json deleted file mode 100644 index 227c836a8..000000000 --- a/server/.sqlx/query-1ffddd843ece79fa10cfb98c2e8aff2842cad45867c3a72f807ae08c1b10cb37.json +++ /dev/null @@ -1,22 +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", - "Text", - "Text" - ] - }, - "nullable": [] - }, - "hash": "1ffddd843ece79fa10cfb98c2e8aff2842cad45867c3a72f807ae08c1b10cb37" -} diff --git a/server/.sqlx/query-bc0955e2d7a86890ddbe05808ef57645c4b7413815693ebe3db92a62f2909dab.json b/server/.sqlx/query-2668c0418c9e4853fe9f65d84d59d6216530909e31c417d5234ac270e4d851c8.json similarity index 75% rename from server/.sqlx/query-bc0955e2d7a86890ddbe05808ef57645c4b7413815693ebe3db92a62f2909dab.json rename to server/.sqlx/query-2668c0418c9e4853fe9f65d84d59d6216530909e31c417d5234ac270e4d851c8.json index 78422b683..c99be185f 100644 --- a/server/.sqlx/query-bc0955e2d7a86890ddbe05808ef57645c4b7413815693ebe3db92a62f2909dab.json +++ b/server/.sqlx/query-2668c0418c9e4853fe9f65d84d59d6216530909e31c417d5234ac270e4d851c8.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,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,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" }, { @@ -63,10 +63,10 @@ false, false, false, - false, + true, false, false ] }, - "hash": "bc0955e2d7a86890ddbe05808ef57645c4b7413815693ebe3db92a62f2909dab" + "hash": "2668c0418c9e4853fe9f65d84d59d6216530909e31c417d5234ac270e4d851c8" } diff --git a/server/.sqlx/query-3f063afa6b1cee235b60edc06dee94adea3223725f8906025b3abebd24704ee4.json b/server/.sqlx/query-3f063afa6b1cee235b60edc06dee94adea3223725f8906025b3abebd24704ee4.json new file mode 100644 index 000000000..22d13f8fe --- /dev/null +++ b/server/.sqlx/query-3f063afa6b1cee235b60edc06dee94adea3223725f8906025b3abebd24704ee4.json @@ -0,0 +1,22 @@ +{ + "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", + "Text", + "Text" + ] + }, + "nullable": [] + }, + "hash": "3f063afa6b1cee235b60edc06dee94adea3223725f8906025b3abebd24704ee4" +} 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 a7fe044c8..434db6e1f 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.to_string(), 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.to_string(), 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.to_string(), 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.to_string(), 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.to_string(), detailed_entry_type: "Abhaltung".into(), }, diff --git a/server/main-api/src/calendar/models.rs b/server/main-api/src/calendar/models.rs index 9dcde82f3..b07047a08 100644 --- a/server/main-api/src/calendar/models.rs +++ b/server/main-api/src/calendar/models.rs @@ -34,7 +34,7 @@ pub(super) struct LocationEvents { pub(super) location: CalendarLocation, } -#[derive(Serialize, Deserialize, Clone, Debug, sqlx::Type)] +#[derive(Serialize, Deserialize, Clone, Debug)] pub(super) struct Event { pub(super) id: i32, /// e.g. 5121.EG.003 @@ -48,7 +48,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 /// in reality this is a [EventType] pub(super) entry_type: String,