Active Record Migrations

Tish Faroul
2 min readNov 6, 2021

--

The third project I created for Flatiron School required me to learn about and use Active Record.

When I started my project, one of the most important skills I needed was to edit my database*. This is where Active Record Migrations came into play.

*Careful planning in the beginning of the project could have helped me avoid a lot of backtracking!

Each new migration I created, became a new version of my previous database.

I added new tables and deleted old ones, and added new columns.

After each update I took a glance at the schema to make sure I was satisfied, until finally, I had this:

Creating a new migration is simple.

For example, when I created the potions table, in the Terminal, I typed:

rake db:create_migration create_potion

It creates a blank migration where I can insert the columns and what data type goes into each of them as shown here:

Then, once you’re satisfied with your table, you type in the terminal

rake db:migrate

Which saves it to the schema and sets up your database.

Link to my project demo: https://youtu.be/sCBSPg5Q1Xo

--

--

Tish Faroul
Tish Faroul

No responses yet