feat: add ColumnComment model and migration for tracking field-level comments
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ColumnComment extends Model
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'column_comments';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'table_name',
|
||||
'record_id',
|
||||
'column_name',
|
||||
'comment',
|
||||
'column_value',
|
||||
'user_id',
|
||||
'ip_address'
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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
|
||||
{
|
||||
if (!Schema::hasTable('column_comments')) {
|
||||
Schema::create('column_comments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('table_name');
|
||||
$table->unsignedBigInteger('record_id');
|
||||
$table->string('column_name');
|
||||
$table->text('comment');
|
||||
$table->text('column_value')->nullable();
|
||||
$table->unsignedBigInteger('user_id')->nullable();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['table_name', 'record_id']);
|
||||
$table->index(['table_name', 'column_name']);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('column_comments');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user