diff --git a/database/migrations/2026_10_30_100000_create_finance_ledger_manual_edit_tables.php b/database/migrations/2026_10_30_100000_create_finance_ledger_manual_edit_tables.php index 572a9651..adcf24d9 100644 --- a/database/migrations/2026_10_30_100000_create_finance_ledger_manual_edit_tables.php +++ b/database/migrations/2026_10_30_100000_create_finance_ledger_manual_edit_tables.php @@ -46,7 +46,7 @@ return new class extends Migration if (! $schema->hasTable('fin_ledger_edit_events')) { $schema->create('fin_ledger_edit_events', function (Blueprint $table): void { $table->bigIncrements('id'); - $table->string('entity_type', 20); + $table->string('entity_type', 64); $table->string('entity_key', 200); $table->json('changes'); $table->unsignedBigInteger('user_id')->nullable(); diff --git a/database/migrations/2026_11_18_230000_widen_finance_ledger_edit_event_entity_type.php b/database/migrations/2026_11_18_230000_widen_finance_ledger_edit_event_entity_type.php new file mode 100644 index 00000000..fe8a1a03 --- /dev/null +++ b/database/migrations/2026_11_18_230000_widen_finance_ledger_edit_event_entity_type.php @@ -0,0 +1,48 @@ +connectionName()); + if (! $schema->hasTable('fin_ledger_edit_events') + || ! $schema->hasColumn('fin_ledger_edit_events', 'entity_type')) { + return; + } + + $schema->table('fin_ledger_edit_events', function (Blueprint $table): void { + $table->string('entity_type', 64)->change(); + }); + } + + public function down(): void + { + $schema = Schema::connection($this->connectionName()); + if (! $schema->hasTable('fin_ledger_edit_events') + || ! $schema->hasColumn('fin_ledger_edit_events', 'entity_type')) { + return; + } + + $hasLongValues = DB::connection($this->connectionName()) + ->table('fin_ledger_edit_events') + ->whereRaw('CHAR_LENGTH(entity_type) > 20') + ->exists(); + if ($hasLongValues) { + return; + } + + $schema->table('fin_ledger_edit_events', function (Blueprint $table): void { + $table->string('entity_type', 20)->change(); + }); + } +};