|
| 1 | +<?php |
| 2 | + |
| 3 | +use Illuminate\Database\Migrations\Migration; |
| 4 | +use Illuminate\Database\Schema\Blueprint; |
| 5 | +use Illuminate\Support\Facades\Schema; |
| 6 | + |
| 7 | +return new class extends Migration |
| 8 | +{ |
| 9 | + public function up(): void |
| 10 | + { |
| 11 | + Schema::create('oxylabs_api_request_logger', function (Blueprint $table) { |
| 12 | + $table->id(); |
| 13 | + // Will store the relative path of the request (e.g. /addresses/validate) |
| 14 | + $table->string('path', 191) |
| 15 | + ->index(); |
| 16 | + // What parameters were passed in (e.g. ?status=new) |
| 17 | + $table->string('params', 512) |
| 18 | + ->nullable() |
| 19 | + ->fulltext(); |
| 20 | + // HTTP method (e.g. POST/PUT/DELETE) |
| 21 | + $table->string('http_method', 10) |
| 22 | + ->index(); |
| 23 | + // Status code (e.g. 200, 204, 429) |
| 24 | + $table->smallInteger('response_code', autoIncrement: false, unsigned: true) |
| 25 | + ->nullable() |
| 26 | + ->index(); |
| 27 | + // The entire JSON encoded payload of the request |
| 28 | + $table->json('body') |
| 29 | + ->nullable(); |
| 30 | + // The headers that were part of the request |
| 31 | + $table->json('request_headers') |
| 32 | + ->nullable(); |
| 33 | + // The entire JSON encoded responses |
| 34 | + $table->json('response') |
| 35 | + ->nullable(); |
| 36 | + // The headers that were part of the response |
| 37 | + $table->json('response_headers') |
| 38 | + ->nullable(); |
| 39 | + // Internal exceptions that occurred during the request |
| 40 | + $table->string('exception') |
| 41 | + ->nullable(); |
| 42 | + // When the request was resolved to the millisecond |
| 43 | + $table->timestamp('occurred_at', 3)->index(); |
| 44 | + $table->timestamps(precision: 3); |
| 45 | + $table->processIds(); |
| 46 | + }); |
| 47 | + } |
| 48 | + |
| 49 | + public function down(): void |
| 50 | + { |
| 51 | + Schema::dropIfExists('oxylabs_api_request_logger'); |
| 52 | + } |
| 53 | +}; |
0 commit comments