Because we want to give users the ability to reply tweets. We need to create a Reply model and its migration file:

adonis make:model Reply -m

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

// database/migrations/TIMESTAMP_reply_schema.js

up () {
    this.create('replies', (table) => {
        table.increments()
        table.integer('user_id').unsigned().notNullable()
        table.integer('tweet_id').unsigned().notNullable()
        table.text('reply').notNullable()
        table.timestamps()
    })
}

This will create a replies table with the following fields:

Table of Contents

    • id
    • user_id
    • tweet_id
    • reply
    • 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 http://openlaravel.com