Make the combined combination unique.

This commit is contained in:
James Cole
2024-05-12 08:10:12 +02:00
parent fc5143337a
commit e49dbefddd

View File

@@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
return new class extends Migration {
/**
* Run the migrations.
*/
@@ -15,13 +14,13 @@ return new class extends Migration
Schema::create('account_balances', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->string('title',100)->nullable();
$table->string('title', 100)->nullable();
$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');
$table->unique(['account_id', 'transaction_currency_id', 'title'], 'unique_account_currency');
});
}
}