fix voor wijziging aan migratie
Some checks failed
linter / quality (push) Failing after 1m6s
tests / ci (8.3) (push) Failing after 50s
tests / ci (8.4) (push) Failing after 1m5s
tests / ci (8.5) (push) Failing after 1m6s

This commit is contained in:
Daan Meijer 2026-06-23 17:07:24 +02:00
parent 0c6bab4a04
commit e7481eac95
2 changed files with 43 additions and 1 deletions

View File

@ -13,10 +13,11 @@ return new class extends Migration
{ {
Schema::create('predefined_mutations', function (Blueprint $table) { Schema::create('predefined_mutations', function (Blueprint $table) {
$table->id(); $table->id();
$table->foreignId('ledger_id')->constrained()->cascadeOnDelete(); $table->foreignId('dynamic_id')->constrained()->cascadeOnDelete();
$table->string('name'); $table->string('name');
$table->text('description')->nullable(); $table->text('description')->nullable();
$table->integer('amount'); $table->integer('amount');
$table->string('type')->default('reward');
$table->timestamps(); $table->timestamps();
}); });
} }

View File

@ -0,0 +1,41 @@
<?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
{
Schema::table('predefined_mutations', function (Blueprint $table) {
// Drop old foreign key constraint first
$table->dropForeign(['dynamic_id']);
// Drop old columns
$table->dropColumn(['dynamic_id', 'type']);
// Add new ledger relationship (nullable to support pre-existing entries gracefully)
$table->foreignId('ledger_id')
->after('id')
->nullable()
->constrained()
->cascadeOnDelete();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('predefined_mutations', function (Blueprint $table) {
$table->dropConstrainedForeignId('ledger_id');
$table->foreignId('dynamic_id')->after('id')->constrained()->cascadeOnDelete();
$table->string('type')->default('reward');
});
}
};