id(); $table->morphs('revisionable'); // Null for something done by the scheduler or a command: honest // about it rather than blaming the last person who logged in. $table->foreignId('user_id')->nullable()->constrained()->nullOnDelete(); $table->string('user_name')->nullable(); $table->string('event', 20); /* * Only what changed, old and new. Storing whole records would make * this table larger than the content it describes. * * Not called `changes`: Eloquent declares a `$changes` property of * its own for dirty tracking, and a column of that name is shadowed * by it — `$revision->changes` would silently return the ORM's * array instead of this column. */ $table->jsonb('changeset')->nullable(); $table->timestamp('created_at')->nullable(); $table->index(['revisionable_type', 'revisionable_id', 'created_at'], 'revisions_record_index'); }); } public function down(): void { Schema::dropIfExists('revisions'); } };