kiwilan / typescriptable-laravel

PHP package for Laravel to type Eloquent models, routes, Spatie Settings with autogenerated TypeScript. Optional NPM package for Inertia.
https://packagist.org/packages/kiwilan/typescriptable-laravel
MIT License
30 stars 3 forks source link

[Bug]: Generating models error when using DB_PREFIX #44

Closed ngekoding closed 10 months ago

ngekoding commented 10 months ago

What happened?

Just using prefix for my databases tables by setting in the config/database.php (e.g. sv_).

Then, when trying to run the command:

php artisan typescriptable:models

I get this errors:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'survey.responses' doesn't exist (Connection: mysql, SQL: SHOW COLUMNS FROM responses)

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:822
    818▕                     $this->getName(), $query, $this->prepareBindings($bindings), $e
    819▕                 );
    820▕             }
    821▕ 
  ➜ 822▕             throw new QueryException(
    823▕                 $this->getName(), $query, $this->prepareBindings($bindings), $e
    824▕             );
    825▕         }
    826▕     }

  i   A table was not found: You might have forgotten to run your database migrations. 
      https://laravel.com/docs/master/migrations#running-migrations

      +27 vendor frames 

  28  artisan:35
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

How to reproduce the bug

  1. Setting the database prefix
  2. Install the package
  3. Try to generate TS types for models
  4. Error table not found!

Package Version

^1.11

PHP Version

8.2.10

Which operating systems does with happen with?

macOS

Notes

I was try to publish the package configuration and I don't found any related config to settings the database tables prefix.

ewilan-riviere commented 10 months ago

Thanks, I will fix this today!

ngekoding commented 10 months ago

@ewilan-riviere Thank you

ewilan-riviere commented 10 months ago

Can you test latest release? ;)

ngekoding commented 10 months ago
Screen Shot 2024-01-10 at 16 26 39

Solved! Thank you.