Build a Twitter Clone With Adonis and Vue

Tweet Model and Migration

Just as we did for User, we need to create a Tweet model and its migration file. To do that, we'll use the Adonis CLI make:model command:

adonis make:model Tweet -m

The -m flag indicates we want a migration file created along with the Tweet model. Open database/migrations/TIMESTAMP_tweet_schema.js and update the up method as below:

// database/migrations/TIMESTAMP_tweet_schema.js

up () {
    this.create('tweets', (table) => {

This will create a tweets table with the following fields:

  • id
  • user_id
  • tweet
  • created_at
  • updated_at

Next, run the migration:

 adonis migration:run

Like this article? Follow @ammezie on Twitter