ImportRegistrationCodes
struct ImportRegistrationCodes : AsyncMigration
A Migration that populates the RegistrationCode database from a registration-codes.txt
file located in the seeds/ subdirectory of the project.
-
prepare(on:Asynchronous) Required by
Migrationprotocol. Reads either a test or production text file in theseeds/subdirectory, converts the lines into elements of an array, then iterates over them to create newRegistrationCodemodels.Requires
registration-codes.txtfile in seeds subdirectory.Declaration
Swift
func prepare(on database: Database) async throwsParameters
databaseA connection to the database, provided automatically.
Return Value
Void
-
revert(on:Asynchronous) Deletes all registration codes in the “registrationcode” table.
Declaration
Swift
func revert(on database: Database) async throwsParameters
databaseA connection to the database, provided automatically.
Return Value
Void.
View on GitHub