Changing database connection in Model


#1

I am using two database connections
mysql1{
database: database01
},
mysql2{
database: database02
}
mysql1 is the default connection and mysql2 is used in specific models using the static method get connection(). But while executing the migration all my models are creating its tables in the same database. I need to create the tables to its specific databases. Thanks in advance!


#2

According to docs, you need to do the following


const Schema = use('Schema')

class UsersSchema extends Schema {

static get connection() {
    return 'mysql'
}

}

//after you create the `up()` and `down` regular methods

up () {

}

down () {

}

NOTES


#3

Thank you.