ImportTimeZoneChanges

struct ImportTimeZoneChanges : AsyncMigration

A Migration that imports timezone change data located in the seeds/ subdirectory of the project. The time-zone-changes.txt file should contain tab-delimited data, 3 fields on each line: 20220305T070000Z -5 EST This line says that on March 5, 2022 at 2:00 AM EST (7 AM UTC), the boat will be in the EST timezone, with a timezone offset of -5 hours. Because we usually use the previous year’s schedule data for testing until we get the next year’s schedule, it’s intended that the time-zone-changes.txt file will have more than one sailing’s worth of timezone changes in it.

  • prepare(on:) Asynchronous

    Required by Migration protocol. Reads in a TSV file.

    Requires

    time-zone-changes.txt file in seeds subdirectory.

    Declaration

    Swift

    func prepare(on database: Database) async throws

    Parameters

    database

    A connection to the database, provided automatically.

    Return Value

    Void.

  • Reads and parses the time-zone-changes.txt file, erases previous TimeZoneChange entries in db, replaces with new entries from file. Usable both within Migrations and while server is up and running.

    Declaration

    Swift

    func loadTZFile(on database: Database, isMigrationTime: Bool = true) async throws

    Parameters

    database

    A connection to the database.

    isMigrationTime

    TRUE if the app was launched with a migrate command. Affects how errors are handled.

    Return Value

    Void.

  • revert(on:) Asynchronous

    Required by Migration protocol. Deletes all timezone changes in the database.

    Declaration

    Swift

    func revert(on database: Database) async throws

    Parameters

    database

    A connection to the database, provided automatically.

    Return Value

    Void.