5

I Have installed @adonisjs/lucid. create a migration to use command

adonis make:migration task

** task code**

'use strict'

const Schema = use('Schema')

class TaskSchema extends Schema {
  up() {
    this.create('tasks', table => {
      table.increments()
      table.timestamps()
      table.string('name')
      table.text('description')
      table.integer('project_id').unsigned()
      table
        .foreign('project_id')
        .references('projects.id')
        .onDelete('cascade')
    })
  }

  down() {
    this.drop('tasks')
  }
}

module.exports = TaskSchema

i have run my migration to show this error

error: `migration:run` is not a registered command

**

i have not understand this bug. I know that if not install the dependencies @adonisjs/lucid than show this error but After I installed dependencies why the error occurred

**

Jamil Ahmed
  • 284
  • 3
  • 17

2 Answers2

1

What you need here is adonis/cli.

npm i -g @adonisjs/cli

But I think the you don't really need this extra dependencies. Using ace is enough

node ace make:migration task
Jonas Elan
  • 171
  • 1
  • 5
  • 2
    I installed this first time in my adonis js code to Quick Start – Jamil Ahmed Feb 16 '20 at 17:11
  • any command "adonis" throw this error? If u run "adonis --help", get similar error? If so I recommend to deletel node_modules folder and run npm install again – Jonas Elan Feb 16 '20 at 17:44
  • For anyone else new to AdonisJS, `adonis migration:run` can give this same error message (`error: 'migration:run' is not a registered command`) when you have accidentally deleted the `ace` file in the root of your project – zsepi Apr 28 '21 at 13:36
1

Here is the solution to this question

In fact, I don’t need to install the CLI in production. Run your server with node server.js and execute internal commands with node ace XXX.

node ace migration:run --force
Jamil Ahmed
  • 284
  • 3
  • 17
  • MD JAMIL AJ, while this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. [Answers that are little more than a link may be deleted.](//stackoverflow.com/help/deleted-answers) – 4b0 Sep 15 '20 at 11:14