Skip to content

Commit

Permalink
Drop logs table
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-helldar committed Jun 16, 2023
1 parent babafcc commit 01426d6
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ public function down()
->dropIfExists($this->logsTable());
}

protected function logsConnection(): ?string
{
return Logs::getConnection();
}

protected function logsTable(): string
{
return Logs::getTable();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

/*
* This file is part of the "cashier-provider/core" project.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Andrey Helldar <helldar@ai-rus.com>
*
* @copyright 2021 Andrey Helldar
*
* @license MIT
*
* @see https://github.com/cashier-provider/core
*/

declare(strict_types=1);

use CashierProvider\Core\Support\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

new class extends Migration {
public function up()
{
Schema::connection($this->logsConnection())->dropIfExists('cashier_logs');
}

public function down()
{
Schema::connection($this->logsConnection())
->create('cashier_logs', function (Blueprint $table) {
$table->id();

$table->string('item_type');

$this->isNumericPrimaryKey()
? $table->unsignedBigInteger('item_id')
: $table->uuid('item_id');

$table->string('external_id')->nullable();

$table->string('method');
$table->string('url');

$table->unsignedSmallInteger('status_code');

$table->json('request');
$table->json('response');
$table->json('extra')->nullable();

$table->timestamps();

$table->index(['item_type', 'item_id']);
});
}
};
5 changes: 5 additions & 0 deletions src/Support/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,9 @@ protected function detailsTable(): string
{
return Config::details()->table;
}

protected function logsConnection(): ?string
{
return Logs::getConnection();
}
}

0 comments on commit 01426d6

Please sign in to comment.