From cf949feeec0c70f18d1bf3a15a94aaa321a120a1 Mon Sep 17 00:00:00 2001 From: Jason De Lanerolle Date: Tue, 19 May 2026 14:48:54 -0400 Subject: [PATCH] initial changes to Tables + migration script --- app/Database/Migrations.hs | 12 +++++++++++- app/Database/Tables.hs | 13 ++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/Database/Migrations.hs b/app/Database/Migrations.hs index 1ac16ed00..e189dbbd0 100644 --- a/app/Database/Migrations.hs +++ b/app/Database/Migrations.hs @@ -31,7 +31,10 @@ applyMigrations currVersion migrations = do -- | List of migrations migrationList :: [MigrationWrapper] -migrationList = [MigrationWrapper {version=2, script=renamePostTables}] +migrationList = [ + MigrationWrapper {version=2, script=renamePostTables}, + MigrationWrapper {version=3, script=splitTimes} + ] -- | Migration script which renames the Post tables to Program renamePostTables :: Migration @@ -40,6 +43,13 @@ renamePostTables = do addMigration True "ALTER TABLE post_category RENAME TO program_category;" addMigration True "ALTER TABLE program_category RENAME COLUMN post TO program;" +-- | Migration script to add proper support for year-long courses +splitTimes :: Migration +splitTimes = do + addMigration True "ALTER TABLE times RENAME COLUMN first_room TO location;" + addMigration True "ALTER TABLE times DROP COLUMN second_room;" + addMigration True "ALTER TABLE times ADD session varchar(32);" + -- | Gets the current version of the database. -- If no version is defined, initialize the -- version to the latest version and return that. diff --git a/app/Database/Tables.hs b/app/Database/Tables.hs index edc6366c4..5bab8e3a5 100644 --- a/app/Database/Tables.hs +++ b/app/Database/Tables.hs @@ -71,12 +71,12 @@ Meeting UniqueMeeting code session section Times + session T.Text Maybe weekDay Double startHour Double endHour Double meeting MeetingId - firstRoom T.Text Maybe - secondRoom T.Text Maybe + location T.Text Maybe Breadth description T.Text @@ -312,22 +312,21 @@ convertTimeVals _ _ _ = (5.0, 25.0, 25.0) -- | Convert Times into Time buildTime :: Times -> SqlPersistM Time buildTime t = do - room1 <- getBuilding (timesFirstRoom t) - room2 <- getBuilding (timesSecondRoom t) + room1 <- getBuilding (timesLocation t) return $ Time (timesWeekDay t) (timesStartHour t) (timesEndHour t) room1 - room2 + Nothing -- Temporary null data buildTimes :: Key Meeting -> Time' -> Times buildTimes meetingKey t = - Times (weekDay' t) + Times (Just "") -- Temporary null data + (weekDay' t) (startHour' t) (endHour' t) meetingKey (firstLocation' t) - (secondLocation' t) -- | Given a building code, get the persistent Building associated with it getBuilding :: Maybe T.Text -> SqlPersistM (Maybe Building)