fix voor wijziging aan migratie
This commit is contained in:
parent
0c6bab4a04
commit
e7481eac95
@ -13,10 +13,11 @@ return new class extends Migration
|
||||
{
|
||||
Schema::create('predefined_mutations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('ledger_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('dynamic_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->text('description')->nullable();
|
||||
$table->integer('amount');
|
||||
$table->string('type')->default('reward');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
@ -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');
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user