4 - Add pages and page_links migrations with PageStatusEnum
This commit is contained in:
parent
ec2113710a
commit
bc535c8c0b
3 changed files with 73 additions and 0 deletions
12
app/Enums/PageStatusEnum.php
Normal file
12
app/Enums/PageStatusEnum.php
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
enum PageStatusEnum: string
|
||||||
|
{
|
||||||
|
case Discovered = 'discovered';
|
||||||
|
case Fetched = 'fetched';
|
||||||
|
case Failed = 'failed';
|
||||||
|
}
|
||||||
34
database/migrations/2026_04_25_234157_create_pages_table.php
Normal file
34
database/migrations/2026_04_25_234157_create_pages_table.php
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use App\Enums\PageStatusEnum;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('pages', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->text('url')->unique();
|
||||||
|
$table->string('status')->default(PageStatusEnum::Discovered->value)->index();
|
||||||
|
$table->string('title')->nullable();
|
||||||
|
$table->foreignId('instance_id')
|
||||||
|
->nullable()
|
||||||
|
->constrained('fedi_discover_instances')
|
||||||
|
->nullOnDelete();
|
||||||
|
$table->timestampTz('posted_at')->nullable();
|
||||||
|
$table->timestampTz('fetched_at')->nullable();
|
||||||
|
$table->timestampTz('failed_at')->nullable();
|
||||||
|
$table->timestampsTz();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('pages');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('page_links', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('source_page_id')->constrained('pages')->cascadeOnDelete();
|
||||||
|
$table->foreignId('target_page_id')->constrained('pages')->cascadeOnDelete();
|
||||||
|
$table->timestampsTz();
|
||||||
|
|
||||||
|
$table->unique(['source_page_id', 'target_page_id']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('page_links');
|
||||||
|
}
|
||||||
|
};
|
||||||
Loading…
Reference in a new issue