Xethron / migrations-generator

Laravel Migrations Generator: Automatically generate your migrations from an existing database schema.
MIT License
3.32k stars 591 forks source link

Fix Undefined property: stdClass::$column_name #179

Open stuheiss opened 5 years ago

stuheiss commented 5 years ago

Querying information_schema.columns returns upper cased column names on some versions of mysqld. This is similar to an old bug in laravel/framework. See https://github.com/laravel/framework/issues/20190

Fix by changing select column_name, column_type ... to select column_name as column_name, column_type as column_type ...

t4e192 commented 5 years ago

I encountered the exact same error message while using xethron/migrations-generator ^2.0 However, I was using this in a Lumen 5.5.*, PHP 7.1.27 no OpCache implementation. Bear in mind that OpCache will cause other problems. Steps:

  1. composer require --dev "xethron/migrations-generator"

  2. bootstrap\app.php $app->register(\Way\Generators\GeneratorsServiceProvider::class); $app->register(\Xethron\MigrationsGenerator\MigrationsGeneratorServiceProvider::class);

  3. vendor\laravel\lumen-framework\src\Application.php at the bottom append the following: public function configPath($path = ''){ return $this->basePath.DIRECTORY_SEPARATOR.'config'.($path ? DIRECTORY_SEPARATOR.$path : $path); }

  4. vendor\xethron\laravel-4-generators\src\config\config.php at the top add the following: function app_path($path = '') { return app('path') . ($path ? DIRECTORY_SEPARATOR . $path : $path); }

  5. vendor\xethron\laravel-4-generators\src\Way\Generators\GeneratorsServiceProvider.php Change the boot() function to the following: public function boot(){ $path = 'generators.config.php'; $basePath = '../../../../../../../../'; // this points back to the project base folder $this->publishes([ DIR.'/../../config/config.php' => $basePath.DIRECTORY_SEPARATOR.'config'.($path ? DIRECTORY_SEPARATOR.$path : $path), ]); }

  6. vendor\xethron\laravel-4-generators\src\Way\Generators\Commands\GeneratorCommand.php comment out //use Config and replace it with use Illuminate\Support\Fascades\Config;

  7. php artisan --> should work normally now

  8. try to do a "php artisan migrate:generate" and see if the same error message appears or not. If it does, then take a look at your table schema and change enum's to chars instead.

--Jemmy

zack6849 commented 4 years ago

I encountered this issue and the PR fixed it for me, it seems to happen specifically when running laradock, at least for me, +1

skcin7 commented 4 years ago

Okay, so any ideas how best to fix this?

I'm getting this issue now for one of my tables which has an ENUM field, for whatever reason.

sevba commented 4 years ago

Also interested in a fix for this one.

hughsmith10 commented 4 years ago

Any chance this issue could be fixed? Or maybe even upgraded to Laravel 7.x?

jafarchoupan commented 3 years ago

i have same problem . any body have resolve for this issue ?

configuration : php7.1 laravel 5.3 mysql 8.0.22

ErrorException in MySqlProcessor.php line 18: Undefined property: stdClass::$column_name

tjventurini commented 2 years ago

The simple workaround for now is to update the file vendor/xethron/migrations-generator/src/Xethron/MigrationsGenerator/Generators/FieldGenerator.php. On line 82 and 83, change column_name to COLUMN_NAME and column_type to COLUMN_TYPE.

Then the command should run through :+1: