How update app if is on production

Hi Im want to know how to update an app if the app is on production.
For example add new tables or new fields on table are used on the current version.

I try on my pc to add new fields and make migration status and not show anything pending.
If I make migration refresh, the new fields are created on the db, but the data on the db is deleted.

At the moment I havent any app ruuning but I want to make small app and making updates with more features.

You can add migration for example you want to add new cloumn status for user table

  • first you need to adonis make:migration alter_table_user

then in schema file

up () {
    this.alter('users', (table) => {
      //query add new field

after that you can run adonis migration:run

Yeah, you wouldn’t ever want to migration:reset unless you were in fairly early development stage and nothing has been deployed… Even then it’s probably better to just get into the habit of using many migration files.

Think of migration files as the changes to the database over time… Each migration will add, or alter, a table in the database. As new features get added over time, additional migrations will be added to add new tables, or modify existing ones, to manage the data associated with those new features.

This is, obviously, specifically important for changes to an application that’s in development. As well as multi-developer projects… You need a clear repeatable way of ensuring the database is always updated to the state needed for the rest of the codebase, so migrations offload the DB schema to javascript code that gets run to add/modify or in the case of migration:rollback undo changes to tables.

As akirawinz said, add a new migration make your schema changes, then apply that with migration:run

Note – when running migrations in a production environment you’ll need to also include the --force option in the migration:run command.

Here’s a recent change I made to the users table in my app that’s in production:

'use strict'

const Schema = use('Schema')

class UsersSchema extends Schema {
  up () {
    this.table('users', (table) => {

  down () {
    this.table('users', (table) => {

module.exports = UsersSchema

I added a bit of code that updates that timestamp every time a user logs in, successfully resets their password (with ‘forgot password’ functionality) or refreshes their jwt token, etc…

This way despite being an API that doesn’t maintain sessions, I can see when users last authenticated to know who is active and who is not active, and eventually expire/disable inactive accounts and so forth.

1 Like