propelorm/Propel2

Error to import `config.php` because some DatabaseMap Error after change `phpName` from `schema.xml`

filiperochalopes opened this issue · 1 comments

Hello there. I am in a bug for days. I used propel init to introspect database, then I changed some phpName and schema.xml structure and run propel model:build. Now when I try to run this migration or import generated-confi/config.php:

<?php

require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../generated-conf/config.php';

use Propel\Generator\Manager\MigrationManager;
use Api\Models\Base\TabelaQuery;

/**
 * Data object containing the SQL and PHP code to migrate the database
 * up to version 1672150730.
 * Generated on 2022-12-27 14:18:50 by root 
 */
class PropelMigration_1672150730
{
    public $comment = '';

    public function preUp(MigrationManager $manager)
    {

        $pdo = $manager->getAdapterConnection('default');

        $tabela_records = TabelaQuery::create()->find();
        echo $tabela_records;
        foreach ($tabela_records as $row) {
            echo $row;
            echo $row['id'];
            echo $row['data'];
[...]

I get this error tracing:

Fatal error: Uncaught Error: Class "\Models\Map\FisioterapeutaTableMap" not found in /var/www/html/vendor/propel/propel/src/Propel/Runtime/Map/DatabaseMap.php on line 117

Error: Class "\Models\Map\FisioterapeutaTableMap" not found in /var/www/html/vendor/propel/propel/src/Propel/Runtime/Map/DatabaseMap.php on line 117

Call Stack:
    0.0003     410888   1. {main}() /var/www/html/vendor/bin/propel:0
    0.0004     411448   2. include('/var/www/html/vendor/propel/propel/bin/propel') /var/www/html/vendor/bin/propel:120
    0.0006     417824   3. require('/var/www/html/vendor/propel/propel/bin/propel.php') /var/www/html/vendor/propel/propel/bin/propel:4
    0.0254    2255560   4. Symfony\Component\Console\Application->run($input = ???, $output = ???) /var/www/html/vendor/propel/propel/bin/propel.php:37
    0.0313    2494744   5. Propel\Generator\Application->doRun($input = class Symfony\Component\Console\Input\ArgvInput { protected $definition = class Symfony\Component\Console\Input\InputDefinition { private array $arguments = [...]; private int $requiredCount = 1; private ?Symfony\Component\Console\Input\InputArgument $lastArrayArgument = NULL; private ?Symfony\Component\Console\Input\InputArgument $lastOptionalArgument = NULL; private array $options = [...]; private array $negations = [...]; private array $shortcuts = [...] }; protected $stream = NULL; protected $options = []; protected $arguments = ['command' => 'migrate']; protected $interactive = TRUE; private array $tokens = [0 => 'migrate']; private array $parsed = [] }, $output = class Symfony\Component\Console\Output\ConsoleOutput { private int ${Symfony\Component\Console\Output\Output}verbosity = 32; private Symfony\Component\Console\Formatter\OutputFormatterInterface ${Symfony\Component\Console\Output\Output}formatter = class Symfony\Component\Console\Formatter\OutputFormatter { private bool $decorated = TRUE; private array $styles = [...]; private Symfony\Component\Console\Formatter\OutputFormatterStyleStack $styleStack = class Symfony\Component\Console\Formatter\OutputFormatterStyleStack { ... } }; private ${Symfony\Component\Console\Output\StreamOutput}stream = resource(2) of type (stream); private Symfony\Component\Console\Output\OutputInterface $stderr = class Symfony\Component\Console\Output\StreamOutput { private int ${Symfony\Component\Console\Output\Output}verbosity = 32; private Symfony\Component\Console\Formatter\OutputFormatterInterface ${Symfony\Component\Console\Output\Output}formatter = class Symfony\Component\Console\Formatter\OutputFormatter { ... }; private $stream = resource(3) of type (stream) }; private array $consoleSectionOutputs = [] }) /var/www/html/vendor/symfony/console/Application.php:168
    0.0315    2495232   6. Symfony\Component\Console\Application->doRun($input = class Symfony\Component\Console\Input\ArgvInput { protected $definition = class Symfony\Component\Console\Input\InputDefinition { private array $arguments = [...]; private int $requiredCount = 1; private ?Symfony\Component\Console\Input\InputArgument $lastArrayArgument = NULL; private ?Symfony\Component\Console\Input\InputArgument $lastOptionalArgument = NULL; private array $options = [...]; private array $negations = [...]; private array $shortcuts = [...] }; protected $stream = NULL; protected $options = []; protected $arguments = ['command' => 'migrate']; protected $interactive = TRUE; private array $tokens = [0 => 'migrate']; private array $parsed = [] }, $output = class Symfony\Component\Console\Output\ConsoleOutput { private int ${Symfony\Component\Console\Output\Output}verbosity = 32; private Symfony\Component\Console\Formatter\OutputFormatterInterface ${Symfony\Component\Console\Output\Output}formatter = class Symfony\Component\Console\Formatter\OutputFormatter { private bool $decorated = TRUE; private array $styles = [...]; private Symfony\Component\Console\Formatter\OutputFormatterStyleStack $styleStack = class Symfony\Component\Console\Formatter\OutputFormatterStyleStack { ... } }; private ${Symfony\Component\Console\Output\StreamOutput}stream = resource(2) of type (stream); private Symfony\Component\Console\Output\OutputInterface $stderr = class Symfony\Component\Console\Output\StreamOutput { private int ${Symfony\Component\Console\Output\Output}verbosity = 32; private Symfony\Component\Console\Formatter\OutputFormatterInterface ${Symfony\Component\Console\Output\Output}formatter = class Symfony\Component\Console\Formatter\OutputFormatter { ... }; private $stream = resource(3) of type (stream) }; private array $consoleSectionOutputs = [] }) /var/www/html/vendor/propel/propel/src/Propel/Generator/Application.php:31
    0.0318    2564768   7. Symfony\Component\Console\Application->doRunCommand($command = class Propel\Generator\Command\MigrationMigrateCommand { private ?Symfony\Component\Console\Application ${Symfony\Component\Console\Command\Command}application = class Propel\Generator\Application { private array ${Symfony\Component\Console\Application}commands = [...]; private bool ${Symfony\Component\Console\Application}wantHelps = FALSE; private ?Symfony\Component\Console\Command\Command ${Symfony\Component\Console\Application}runningCommand = ...; private string ${Symfony\Component\Console\Application}name = 'Propel'; private string ${Symfony\Component\Console\Application}version = '2.0.0-dev'; private ?Symfony\Component\Console\CommandLoader\CommandLoaderInterface ${Symfony\Component\Console\Application}commandLoader = NULL; private bool ${Symfony\Component\Console\Application}catchExceptions = TRUE; private bool ${Symfony\Component\Console\Application}autoExit = TRUE; private Symfony\Component\Console\Input\InputDefinition ${Symfony\Component\Console\Application}definition = class Symfony\Component\Console\Input\InputDefinition { ... }; private Symfony\Component\Console\Helper\HelperSet ${Symfony\Component\Console\Application}helperSet = class Symfony\Component\Console\Helper\HelperSet { ... }; private ?Symfony\Contracts\EventDispatcher\EventDispatcherInterface ${Symfony\Component\Console\Application}dispatcher = NULL; private Symfony\Component\Console\Terminal ${Symfony\Component\Console\Application}terminal = class Symfony\Component\Console\Terminal { ... }; private string ${Symfony\Component\Console\Application}defaultCommand = 'list'; private bool ${Symfony\Component\Console\Application}singleCommand = FALSE; private bool ${Symfony\Component\Console\Application}initialized = TRUE; private Symfony\Component\Console\SignalRegistry\SignalRegistry ${Symfony\Component\Console\Application}signalRegistry = *uninitialized*; private array ${Symfony\Component\Console\Application}signalsToDispatchEvent = [...] }; private ?string ${Symfony\Component\Console\Command\Command}name = 'migration:migrate'; private ?string ${Symfony\Component\Console\Command\Command}processTitle = NULL; private array ${Symfony\Component\Console\Command\Command}aliases = [0 => 'migrate']; private Symfony\Component\Console\Input\InputDefinition ${Symfony\Component\Console\Command\Command}definition = class Symfony\Component\Console\Input\InputDefinition { private array $arguments = [...]; private int $requiredCount = 0; private ?Symfony\Component\Console\Input\InputArgument $lastArrayArgument = NULL; private ?Symfony\Component\Console\Input\InputArgument $lastOptionalArgument = NULL; private array $options = [...]; private array $negations = [...]; private array $shortcuts = [...] }; private bool ${Symfony\Component\Console\Command\Command}hidden = FALSE; private string ${Symfony\Component\Console\Command\Command}help = ''; private string ${Symfony\Component\Console\Command\Command}description = 'Execute all pending migrations'; private ?Symfony\Component\Console\Input\InputDefinition ${Symfony\Component\Console\Command\Command}fullDefinition = class Symfony\Component\Console\Input\InputDefinition { private array $arguments = [...]; private int $requiredCount = 1; private ?Symfony\Component\Console\Input\InputArgument $lastArrayArgument = NULL; private ?Symfony\Component\Console\Input\InputArgument $lastOptionalArgument = NULL; private array $options = [...]; private array $negations = [...]; private array $shortcuts = [...] }; private bool ${Symfony\Component\Console\Command\Command}ignoreValidationErrors = FALSE; private ?Closure ${Symfony\Component\Console\Command\Command}code = NULL; private array ${Symfony\Component\Console\Command\Command}synopsis = []; private array ${Symfony\Component\Console\Command\Command}usages = []; private ?Symfony\Component\Console\Helper\HelperSet ${Symfony\Component\Console\Command\Command}helperSet = class Symfony\Component\Console\Helper\HelperSet { private array $helpers = [...] }; protected $filesystem = class Symfony\Component\Filesystem\Filesystem {  } }, $input = class Symfony\Component\Console\Input\ArgvInput { protected $definition = class Symfony\Component\Console\Input\InputDefinition { private array $arguments = [...]; private int $requiredCount = 1; private ?Symfony\Component\Console\Input\InputArgument $lastArrayArgument = NULL; private ?Symfony\Component\Console\Input\InputArgument $lastOptionalArgument = NULL; private array $options = [...]; private array $negations = [...]; private array $shortcuts = [...] }; protected $stream = NULL; protected $options = []; protected $arguments = ['command' => 'migrate']; protected $interactive = TRUE; private array $tokens = [0 => 'migrate']; private array $parsed = [] }, $output = class Symfony\Component\Console\Output\ConsoleOutput { private int ${Symfony\Component\Console\Output\Output}verbosity = 32; private Symfony\Component\Console\Formatter\OutputFormatterInterface ${Symfony\Component\Console\Output\Output}formatter = class Symfony\Component\Console\Formatter\OutputFormatter { private bool $decorated = TRUE; private array $styles = [...]; private Symfony\Component\Console\Formatter\OutputFormatterStyleStack $styleStack = class Symfony\Component\Console\Formatter\OutputFormatterStyleStack { ... } }; private ${Symfony\Component\Console\Output\StreamOutput}stream = resource(2) of type (stream); private Symfony\Component\Console\Output\OutputInterface $stderr = class Symfony\Component\Console\Output\StreamOutput { private int ${Symfony\Component\Console\Output\Output}verbosity = 32; private Symfony\Component\Console\Formatter\OutputFormatterInterface ${Symfony\Component\Console\Output\Output}formatter = class Symfony\Component\Console\Formatter\OutputFormatter { ... }; private $stream = resource(3) of type (stream) }; private array $consoleSectionOutputs = [] }) /var/www/html/vendor/symfony/console/Application.php:314
    0.0319    2564768   8. Symfony\Component\Console\Command\Command->run($input = class Symfony\Component\Console\Input\ArgvInput { protected $definition = class Symfony\Component\Console\Input\InputDefinition { private array $arguments = [...]; private int $requiredCount = 1; private ?Symfony\Component\Console\Input\InputArgument $lastArrayArgument = NULL; private ?Symfony\Component\Console\Input\InputArgument $lastOptionalArgument = NULL; private array $options = [...]; private array $negations = [...]; private array $shortcuts = [...] }; protected $stream = NULL; protected $options = []; protected $arguments = ['command' => 'migrate']; protected $interactive = TRUE; private array $tokens = [0 => 'migrate']; private array $parsed = [] }, $output = class Symfony\Component\Console\Output\ConsoleOutput { private int ${Symfony\Component\Console\Output\Output}verbosity = 32; private Symfony\Component\Console\Formatter\OutputFormatterInterface ${Symfony\Component\Console\Output\Output}formatter = class Symfony\Component\Console\Formatter\OutputFormatter { private bool $decorated = TRUE; private array $styles = [...]; private Symfony\Component\Console\Formatter\OutputFormatterStyleStack $styleStack = class Symfony\Component\Console\Formatter\OutputFormatterStyleStack { ... } }; private ${Symfony\Component\Console\Output\StreamOutput}stream = resource(2) of type (stream); private Symfony\Component\Console\Output\OutputInterface $stderr = class Symfony\Component\Console\Output\StreamOutput { private int ${Symfony\Component\Console\Output\Output}verbosity = 32; private Symfony\Component\Console\Formatter\OutputFormatterInterface ${Symfony\Component\Console\Output\Output}formatter = class Symfony\Component\Console\Formatter\OutputFormatter { ... }; private $stream = resource(3) of type (stream) }; private array $consoleSectionOutputs = [] }) /var/www/html/vendor/symfony/console/Application.php:1022
    0.0320    2566848   9. Propel\Generator\Command\MigrationMigrateCommand->execute($input = class Symfony\Component\Console\Input\ArgvInput { protected $definition = class Symfony\Component\Console\Input\InputDefinition { private array $arguments = [...]; private int $requiredCount = 1; private ?Symfony\Component\Console\Input\InputArgument $lastArrayArgument = NULL; private ?Symfony\Component\Console\Input\InputArgument $lastOptionalArgument = NULL; private array $options = [...]; private array $negations = [...]; private array $shortcuts = [...] }; protected $stream = NULL; protected $options = []; protected $arguments = ['command' => 'migrate']; protected $interactive = TRUE; private array $tokens = [0 => 'migrate']; private array $parsed = [] }, $output = class Symfony\Component\Console\Output\ConsoleOutput { private int ${Symfony\Component\Console\Output\Output}verbosity = 32; private Symfony\Component\Console\Formatter\OutputFormatterInterface ${Symfony\Component\Console\Output\Output}formatter = class Symfony\Component\Console\Formatter\OutputFormatter { private bool $decorated = TRUE; private array $styles = [...]; private Symfony\Component\Console\Formatter\OutputFormatterStyleStack $styleStack = class Symfony\Component\Console\Formatter\OutputFormatterStyleStack { ... } }; private ${Symfony\Component\Console\Output\StreamOutput}stream = resource(2) of type (stream); private Symfony\Component\Console\Output\OutputInterface $stderr = class Symfony\Component\Console\Output\StreamOutput { private int ${Symfony\Component\Console\Output\Output}verbosity = 32; private Symfony\Component\Console\Formatter\OutputFormatterInterface ${Symfony\Component\Console\Output\Output}formatter = class Symfony\Component\Console\Formatter\OutputFormatter { ... }; private $stream = resource(3) of type (stream) }; private array $consoleSectionOutputs = [] }) /var/www/html/vendor/symfony/console/Command/Command.php:312
    0.0673    5347712  10. Propel\Generator\Manager\MigrationManager->getMigrationObject($timestamp = 1672150730) /var/www/html/vendor/propel/propel/src/Propel/Generator/Command/MigrationMigrateCommand.php:104
    0.0675    5363072  11. require_once('/var/www/html/generated-migrations/PropelMigration_1672150730.php') /var/www/html/vendor/propel/propel/src/Propel/Generator/Manager/MigrationManager.php:398
    0.0676    5367512  12. require_once('/var/www/html/generated-conf/config.php') /var/www/html/generated-migrations/PropelMigration_1672150730.php:4
    0.0687    5509648  13. require_once('/var/www/html/generated-conf/loadDatabase.php') /var/www/html/generated-conf/config.php:26
    0.0687    5509648  14. Propel\Runtime\ServiceContainer\StandardServiceContainer->initDatabaseMaps($databaseNameToTableMapClassNames = ['default' => [0 => '\\Models\\Map\\FisioterapeutaTableMap', 1 => '\\Models\\Map\\PacienteTableMap', 2 => '\\Models\\Map\\ProcedimentoTableMap', 3 => '\\Models\\Map\\RegistroProcedimentoTableMap', 4 => '\\Models\\Map\\RegistroTableMap', 5 => '\\Models\\Map\\TabelaTableMap', 6 => '\\Models\\Map\\UsuariosTableMap']]) /var/www/html/generated-conf/loadDatabase.php:6
    0.0690    5530656  15. array_map($callback = [0 => class Propel\Runtime\Map\DatabaseMap { protected string $name = 'default'; protected $tables = [...]; protected $tablesByPhpName = [...] }, 1 => 'addTableFromMapClass'], $array = [0 => '\\Models\\Map\\FisioterapeutaTableMap', 1 => '\\Models\\Map\\PacienteTableMap', 2 => '\\Models\\Map\\ProcedimentoTableMap', 3 => '\\Models\\Map\\RegistroProcedimentoTableMap', 4 => '\\Models\\Map\\RegistroTableMap', 5 => '\\Models\\Map\\TabelaTableMap', 6 => '\\Models\\Map\\UsuariosTableMap']) /var/www/html/vendor/propel/propel/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php:267
    0.0690    5531136  16. Propel\Runtime\Map\DatabaseMap->addTableFromMapClass($tableMapClass = '\\Models\\Map\\FisioterapeutaTableMap') /var/www/html/vendor/propel/propel/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php:267

image

I tried run config:convert first, then model:build. Same happened.

Easy to see this error using my https://github.com/filiperochalopes/cadastro-procedimentos-fisioterapia/tree/9653a4660323da3af8ba263dbc162a1e7a07d650 docker repo. Unfortunatelly I cant offer my base sql seed but it's not necessary to reproduce the error.

It took me 2+ days. But I finally found the error. It was on my schema.xml

<?xml version="1.0" encoding="utf-8"?>
<database name="default" defaultIdMethod="native" namespace="\Models" defaultPhpNamingMethod="underscore">

I was using Api\Models for my models but it was \Models at schema.xml