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) => {
        table.increments()
        table.integer('user_id').unsigned().notNullable()
        table.text('tweet').notNullable()
        table.timestamps()
    })
}

This will create a tweets table with the following fields:

Table of Contents

    • id
    • user_id
    • tweet
    • created_at
    • updated_at

    Next, run the migration:

     adonis migration:run

    Chimezie Enyinnaya

    20 posts

    Software Developer [PHP Laravel JavaScript NodeJS AdonisJS VueJS] | movie lover | run http://openlaravel.com