O'Reilly logo

Learning Sinatra by Manoj Sehrawat, Sudeep Agarwal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to define migrations

In Sequel, we need to define migrations to create tables. Migration is a systematic procedure to change the schema of our database from one version to another. So, in our case, we will have numbered files (001, 002, ... ) representing a new version. Sequel handles the migration files automatically and always checks for the newest file.

The users table

Currently, our database is empty and has no tables in it. The first schema change will be the first migration. So, let's write a 001_create_users_table.rb file in the db/migrations/ folder. Note that the filename can be anything as long as it starts with the proper number. We can also have 1_some_file_name. The leading zeros are not mandatory. Also, the first migration is numbered ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required