fix: 修复手工动账导入审计字段超长 (#1253)
Co-authored-by: 92451 <924518135@qq.com> Co-committed-by: 92451 <924518135@qq.com>
This commit is contained in:
parent
e4eca2d9af
commit
c1c98f756b
@ -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();
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
private function connectionName(): string
|
||||
{
|
||||
return (string) config('upstream_mirrors.connection', 'business_mirror');
|
||||
}
|
||||
|
||||
public function up(): void
|
||||
{
|
||||
$schema = Schema::connection($this->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();
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user