Build a Twitter Clone With Adonis and Vue

Reply Model and Migration

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:

  • id
  • user_id
  • tweet_id
  • reply
  • created_at
  • updated_at

Next, run the migration:

 adonis migration:run