Add routine that caches account balances. Add it to the /flush routine as well.

This commit is contained in:
James Cole
2024-05-12 06:24:11 +02:00
parent d356d39d43
commit cebfaa32bf
6 changed files with 121 additions and 5 deletions

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
if (!Schema::hasTable('account_balances')) {
Schema::create('account_balances', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->integer('account_id', false, true);
$table->integer('transaction_currency_id', false, true);
$table->decimal('balance', 32, 12);
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');
$table->unique(['account_id','transaction_currency_id'],'unique_account_currency');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('account_balances');
}
};