laravel-shift / factory-generator

MIT License
41 stars 20 forks source link

There is no column with name 'id' on table #11

Open hayleybech opened 3 years ago

hayleybech commented 3 years ago

When I try to run php artisan generate:factory Example I get a fatal error:

Doctrine\DBAL\Schema\SchemaException 
There is no column with name 'id' on table 'examples'.

I have run migrate:fresh and I'm reasonably confident the id column exists. This error happens for every model I try it on, meaning the factory generator is unusable for me until I can work out the solution.

Nothing turned up in existing issues or Google, do you have any idea why this could happening? Please let me know if there's any more information you need from me.

jasonmccreary commented 3 years ago

Can you share the full stack trace for the error? Also what version of DBAL are you using?

hayleybech commented 3 years ago

Thanks for responding! Okay, I'm running DBAL 2.13.0. Here is the error trace:


  There is no column with name 'id' on table 'attendances'.

  at vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaException.php:86
     82▕      * @return SchemaException
     83▕      */
     84▕     public static function columnDoesNotExist($columnName, $table)
     85▕     {
  ➜  86▕         return new self(
     87▕             sprintf("There is no column with name '%s' on table '%s'.", $columnName, $table),
     88▕             self::COLUMN_DOESNT_EXIST
     89▕         );
     90▕     }

  1   vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Table.php:711
      Doctrine\DBAL\Schema\SchemaException::columnDoesNotExist()

  2   vendor/laravel/framework/src/Illuminate/Database/Connection.php:901
      Doctrine\DBAL\Schema\Table::getColumn()

  3   vendor/naoray/eloquent-model-analyzer/src/Column.php:40
      Illuminate\Database\Connection::getDoctrineColumn()

  4   vendor/naoray/eloquent-model-analyzer/src/Detectors/ColumnsDetector.php:42
      Naoray\EloquentModelAnalyzer\Column::__construct()

  5   vendor/laravel/framework/src/Illuminate/Collections/Collection.php:687
      Naoray\EloquentModelAnalyzer\Detectors\ColumnsDetector::Naoray\EloquentModelAnalyzer\Detectors\{closure}()

  6   vendor/naoray/eloquent-model-analyzer/src/Detectors/ColumnsDetector.php:43
      Illuminate\Support\Collection::mapWithKeys()

  7   vendor/naoray/eloquent-model-analyzer/src/Analyzer.php:19
      Naoray\EloquentModelAnalyzer\Detectors\ColumnsDetector::discover()

  8   vendor/laravel-shift/factory-generator/src/FactoryGenerator.php:53
      Naoray\EloquentModelAnalyzer\Analyzer::columns()

  9   vendor/laravel-shift/factory-generator/src/GenerateCommand.php:39
      Shift\FactoryGenerator\FactoryGenerator::generate()

  10  vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php:234
      Shift\FactoryGenerator\GenerateCommand::Shift\FactoryGenerator\{closure}()

  11  vendor/laravel-shift/factory-generator/src/GenerateCommand.php:46
      Illuminate\Support\Collection::each()

  12  vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36
      Shift\FactoryGenerator\GenerateCommand::handle()

  13  vendor/laravel/framework/src/Illuminate/Container/Util.php:40
      Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()

  14  vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93
      Illuminate\Container\Util::unwrapIfClosure()

  15  vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37
      Illuminate\Container\BoundMethod::callBoundMethod()

  16  vendor/laravel/framework/src/Illuminate/Container/Container.php:611
      Illuminate\Container\BoundMethod::call()

  17  vendor/laravel/framework/src/Illuminate/Console/Command.php:136
      Illuminate\Container\Container::call()

  18  vendor/symfony/console/Command/Command.php:256
      Illuminate\Console\Command::execute()

  19  vendor/laravel/framework/src/Illuminate/Console/Command.php:121
      Symfony\Component\Console\Command\Command::run()

  20  vendor/symfony/console/Application.php:971
      Illuminate\Console\Command::run()

  21  vendor/symfony/console/Application.php:290
      Symfony\Component\Console\Application::doRunCommand()

  22  vendor/symfony/console/Application.php:166
      Symfony\Component\Console\Application::doRun()

  23  vendor/laravel/framework/src/Illuminate/Console/Application.php:92
      Symfony\Component\Console\Application::run()

  24  vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:129
      Illuminate\Console\Application::run()

  25  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()