0
Hail, hail people!
I have a problem in a project with multiple databases, each database corresponds to a user that is created when the user confirms their registration.
I created a specific command for this. and this working perfectly, the user confirms his registration through your email and bingo! the data bank is assigned with its contract number in the suffix.
The difficulty I am facing is to run the migrate at this time. It is known that to work with multi database it is necessary to have a standard schema configured in . env.
so I’m doing the following, where db:create is a command created.
public function workspaceConfig($id)
{
$dataBaseName = 'apl_'.$id;
Artisan::call("db:create ". $dataBaseName);
Config::set('database.connections.mysql.database', $dataBaseName);
DB::reconnect();
Artisan::call('migrate:refresh', [
'--force' => true,
]);
Config::set('database.default','mysql');
DB::reconnect();
}
Returns the following:
"message": "SQLSTATE[42S02]: Base table or view not found: 1146 Table 'apl_15.migrations' doesn't exist (SQL: select `migration` from `migrations` order by `batch` asc, `migration` asc)",
my . env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=apl_padrao
DB_USERNAME=dbuser
DB_PASSWORD=minhasenha
Does anyone know how to solve?
Why instead of using migrate, you don’t create a DB::query with a query by creating the table?
– Glenys Mitchell
Glenys Mitchell, the project is already ready are more than 100 tables already encoded, the creation of tables through DB::query is outside the scope of the project.
– Marcelo Bezerra
Which of the lines is giving error and the current error is that there is no table...
– novic