Users will be able to follow one another, and we need to create a database table structure that will cater to this. We don't need a separate model for this as it will make use of the User model. We only need to create just the migration file. For that, we'll make use of the Adonis CLI make:migration command:

 adonis make:migration followers

Then select Create table on the prompt.

Open database/migrations/TIMESTAMP_followers_schema.js and update the up method as below:

Table of Contents

    // database/migrations/TIMESTAMP_followers_schema.js
    up () {
        this.create('followers', (table) => {

    This will create a followers table with the following fields:

    • id
    • user_id
    • follower_id
    • created_at
    • updated_at

    Next, run the migration:

     adonis migration:run

    Chimezie Enyinnaya

    19 posts

    Software Developer [PHP Laravel JavaScript NodeJS AdonisJS VueJS] | movie lover | run