You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, i've create a module and add it to PSR4 autoload, the module works fine!
The problem is that i've a migration inside a module and run $migrate->latests(); not create de tables, i call the migration with this code from the web UI:
<?php
namespace App\Controllers;
class Migrate extends BaseController
{
public function index()
{
echo 'Migrate';
$migrate = \Config\Services::migrations();
try
{
$migrate->latest();
}
catch (\Throwable $e)
{
print_r($e);
}
}
}
I see in MigrationRunner.php than the function findMigrations() search for the migration files, but exists a condition that makes me dubt:
// If a namespace is set then use it, otherwise load all namespaces from the autoloader
$namespaces = $this->namespace ? [$this->namespace] : array_keys(Services::autoloader()->getNamespace());
If i see MigrationRunner.php constructor, always set the $this->namespace:
/**
* Constructor.
*
* When passing in $db, you may pass any of the following to connect:
* - group name
* - existing connection instance
* - array of database configuration values
*
* @param MigrationsConfig $config
* @param ConnectionInterface|array|string|null $db
*
* @throws ConfigException
*/
public function __construct(MigrationsConfig $config, $db = null)
{
$this->enabled = $config->enabled ?? false;
$this->table = $config->table ?? 'migrations';
// Default name space is the app namespace
$this->namespace = APP_NAMESPACE;
// get default database group
$config = config('Database');
$this->group = $config->defaultGroup;
unset($config);
// If no db connection passed in, use
// default database group.
$this->db = db_connect($db);
}
and of course, the namespaces founded by FindMigrations es this:
Array ( [0] => App )
if i comment this condition get the correct array:
CI: 4.1.1 (composer)
Hi, i've create a module and add it to PSR4 autoload, the module works fine!
The problem is that i've a migration inside a module and run $migrate->latests(); not create de tables, i call the migration with this code from the web UI:
I see in MigrationRunner.php than the function findMigrations() search for the migration files, but exists a condition that makes me dubt:
If i see MigrationRunner.php constructor, always set the $this->namespace:
and of course, the namespaces founded by FindMigrations es this:
Array ( [0] => App )
if i comment this condition get the correct array:
Array ( [0] => CodeIgniter [1] => App [2] => Config [3] => Modules\Auth [4] => Translations [5] => Psr\Log [6] => Laminas\ZendFrameworkBridge [7] => Laminas\Escaper [8] => Kint [9] => Fluent\Auth )
what i'm doing wrong? how i get the correct migrations?
Regards!
The text was updated successfully, but these errors were encountered: