1

I have some seeds and I simply want to see the SQL they generate. With migrations I would simply do --pretend but this isn't an option for db:seed.

I also realize that I can see all the SQL statements that I run by using DB::getQueryLog() etc. However, I don't want to actually execute the SQL.

Any ideas on how to generate the SQL your seed files would produce without actually running the sql?

Sample insert from one of my seeders:

    DB::table('aca_reporting_1094_fields')->insert([
        [
            'field_name'    => 'business_name',
            'value'         => 'Sesame St R Us',
            'record_status' => 1,
            'created_at'    => Carbon::now()->format('Y-m-d H:i:s'),
            'updated_at'    => Carbon::now()->format('Y-m-d H:i:s'),
        ],
    ]);

I realize I am probably missing something simple here and thanks for the helpful comments. I will look into extending the seed command and see if I do it successfully I will leave the answer (unless someone beats me to it).

halfer
  • 19,824
  • 17
  • 99
  • 186
Bill Garrison
  • 2,226
  • 3
  • 34
  • 75
  • 1
    https://scotch.io/tutorials/debugging-queries-in-laravel – Jonathan Jun 21 '16 at 20:25
  • 1
    If you are using query builder, you can just call the `toSql()` method. A better option might be to extend the seed command, and add an option for dry-run. Based on that option, you can execute the command or print the SQL. – SArnab Jun 21 '16 at 20:28
  • In my experience there is little value in asking people why they have downvoted, since once they have done so they will have long gone. However, if it is important to you, please add it to the comments, so the post can remain focussed on the problem. – halfer Jun 22 '16 at 10:37

0 Answers0