laracraft-tech / laravel-xhprof

Easy XHProf setup to profile your Laravel application!
MIT License
219 stars 11 forks source link

Fix the migration #3

Closed zaherg closed 1 year ago

zaherg commented 1 year ago

While working with postgresql, I faced a small problem running the migration,

   INFO  Running migrations.

  2022_10_25_094737_create_xhprof_table .................................................................................................. 42ms FAIL

   Illuminate\Database\QueryException

  SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near "ON"
LINE 1: ...hout time zone not null default CURRENT_TIMESTAMP ON UPDATE ...
                                                             ^ (SQL: create table "details" ("idcount" bigserial primary key not null, "id" char(64) not null, "url" char(255) null, "c_url" char(255) null, "timestamp" timestamp(0) without time zone not null default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, "server name" char(64) null, "perfdata" bytea null, "type" smallint null, "cookie" bytea null, "post" bytea null, "get" bytea null, "pmu" integer null, "wt" integer null, "cpu" integer null, "server_id" char(64) null, "aggregateCalls_include" char(255) null))

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:760
    756▕         // If an exception occurs when attempting to run a query, we'll format the error
    757▕         // message to include the bindings with SQL, which will make this exception a
    758▕         // lot more helpful to the developer instead of just the database's errors.
    759▕         catch (Exception $e) {
  ➜ 760▕             throw new QueryException(
    761▕                 $query, $this->prepareBindings($bindings), $e
    762▕             );
    763▕         }
    764▕     }

      +9 vendor frames
  10  database/migrations/2022_10_25_094737_create_xhprof_table.php:41
      Illuminate\Support\Facades\Facade::__callStatic("create")

      +26 vendor frames
  37  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

so I guess it is better to change https://github.com/laracraft-tech/laravel-xhprof/blob/08e1d80c22697bd04e98b584e02d63a4bdbc8071/database/migrations/create_xhprof_table.php.stub#L21

to

$table->timestamp('timestamp')->useCurrent()->useCurrentOnUpdate();

which in my case fixed the problem :D

Sairahcaz commented 1 year ago

Hi @zaherg, thanks for that! I'll commit this...