Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

PetroGromovo's avatar

How to generate migrations/seeds from existing db in Laravel 8?

Hello, I need to generate migrations/seeds from existing db in Laravel 8.25.0 app. In laravel 5 I used plugins https://github.com/Xethron/migrations-generator and https://github.com/orangehill/iseed

But the first of them looks very old (last update 4 years ago). Can they be used in Laravel 8? Maybe now there are better plugins for such tasks? Thanks!

0 likes
5 replies
patrikgrinsvall's avatar

Hi! I'm working on this exact thing right now and has been, on and off for the last month.

For seeding i didnt find anything yet (except laravel-shift/blueprint i think?), so im down to customizing stubs and my own artisan command which has this function

    function generateSeeders(){

        $models = scandir(__DIR__."/../../Models/");
        $config = Config::all();;
        $except = $config['models']['*']['except'];
        $except[] = ".";
        $except[] = "..";
        foreach($models as $model)
        {
            $modelname = explode(".", $model);
            if(empty($modelname[0]) || in_array($modelname[0], $except)) continue;
            $modelname = $modelname[0] . "Seeder";
            if($this->option('overwrite')) unlink(base_path("database/seeders/" . $modelname . ".php"));
            $this->call('make:seeder', ["name" => $modelname]);
        }
    }

I'm generating all the way from database to nova resources now (except seeder) and use, for model generation: reliese/laravel, for factory-generation i'm switching on and off from laravel-shift/factory-generator and thedoctor0/laravel-factory-generator. I think both works fine but laravel-shift feels a bit fresher. For nova resource generation i needed to write my own thing.

Please update me if you find anything that works!

1 like
patrikgrinsvall's avatar

Yea, but they dont generate "real" seeders which generate from model factories with faker. More like query sql, dump it, inserts result again. Which i guess is good for some purposes, but not for new applications

Tray2's avatar

So what you want is a seeder that fakes a certain number of records?

patrikgrinsvall's avatar

Sorry for late reply. Yea, thats what i wanted. It was trivial to write for myself however. Project became bigger so i just need to clean up and then i have a drag and drop laravel+nova boilerplate builder :) Seeding was the easy part

Please or to participate in this conversation.