In our previous project, our task editor would work a treat as long as the server kept running, but one quick re-start and everything we've saved would be lost forever – which is why persistence, particularly with databases, plays a massive part in software development.
In this section, we're going to continue to build on our TaskAPI project, adding persistence so that our data is always protected.
Getting ready
For this section, you'll need to install Docker on your Mac. Follow this link for information on Docker and containerization, along with a link to the installer: https://www.docker.com/products/docker-desktop.
How to do it...
First, we'll need to create our database. Luckily, Vapor can do that for us:
- Start by creating a new file under the Migration folder called CreateTasks.swift and copy the following:
struct CreateTask: Migration {
func prepare(on database: Database) -> EventLoopFuture<Void...