Files
landing-api/database/migrations/2026_08_15_120000_create_revisions_table.php
Josep Piguillem 3897113313 Initial commit: Pireon Admin — headless admin panel and public API
Laravel 13 + Filament 5 admin panel and REST API for a non-profit developer
collective, backed by the Pireon OAuth identity server. The public site is a
separate, server-rendered application consuming /api/public/v1.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 17:55:27 +02:00

55 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Who changed what, and what it said before.
*
* Several people edit the same translated JSON with no record of any of it.
* The gap that matters most is publishing: `pages.publish` exists as a
* separate permission precisely because putting something on the public site
* is a bigger act than writing it — and until now nothing recorded who did it.
*/
return new class extends Migration
{
public function up(): void
{
Schema::create('revisions', function (Blueprint $table) {
$table->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');
}
};