incr/database/migrations/2026_08_16_000000_create_trackers_table.php

38 lines
1 KiB
PHP
Raw Permalink Normal View History

<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Consolidates the thirteen migrations that preceded v0.4.0. Those created and
* then dropped assets, users, sessions, milestones and entries to arrive at a
* single table; replaying that chain required MySQL-specific DDL. Deployments
* migrated before this have the old entries in their migrations table and skip
* it via the guard below.
*/
return new class extends Migration
{
public function up(): void
{
if (Schema::hasTable('trackers')) {
return;
}
Schema::create('trackers', function (Blueprint $table): void {
$table->id();
$table->string('label');
$table->string('unit');
$table->unsignedInteger('count')->default(0);
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('trackers');
}
};