Skip to content

Commit

Permalink
made sure that stp_type is nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Jul 10, 2024
1 parent 2b62c12 commit c5e7ebc
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 34 deletions.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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;
10 changes: 5 additions & 5 deletions server/main-api/src/calendar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
Expand All @@ -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(),
},
Expand All @@ -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(),
},
Expand All @@ -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(),
},
Expand All @@ -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(),
},
Expand Down
4 changes: 2 additions & 2 deletions server/main-api/src/calendar/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<String>,
/// e.g. lecture
/// in reality this is a [EventType]
pub(super) entry_type: String,
Expand Down

0 comments on commit c5e7ebc

Please sign in to comment.