Categories
Building In Public iOS Development

Building in Public – Expense Tracker 04: Creating Migrations with Vapor

Iā€™m building an expense tracker app, and live streaming the whole process! This is blog series is a written form of each livestream.

Iā€™m building an expense tracker app, and live streaming the whole process! This blog series is a written form of each livestream.

See all the previous posts.

FINALLY SOME CODING! šŸ˜

Finally creating the Vapor project, named ExpenseTrackerKit. I go through some basics on how Vapor works, and using Postman, Docker, and DBeaver, to test everything locally.

I started creating the migrations for the different tables. I had to reference the Vapor docs pretty frequently to properly make the primary and foreign key relationships.

Migrations are like a version control system for your database. Each migration defines a change to the database and how to undo it. By modifying your database through migrations, you create a consistent, testable, and shareable way to evolve your databases over time.

Vapor docs – Migrations

I created migrations for:

  • Category Type
    • an enum for income / expenses, to make everything type-safe
  • Category
  • Account
  • Expense
  • Income

I ended up changing the data type for how I’m saving currency. I’ll use a string for the currency’s denomination and an integer for the amount. Right now, I’ll most likely make it so that the user sets the currency once and can’t change it, but I may change that later.

Livestream

04 Expense Tracker – Creating Migrations with Vapor | Building in Public Livestream | Mikaela Caron