feat(api): mobile API Milestone 4 — full PUSH (inspections/issues/features + conflicts)

SyncController now handles the full mutation vocabulary:
- inspection.create (idempotent by uuid; project/layer derived from feature;
  authz member + 'create inspections'; status defaults to completed).
- issue.create (idempotent; authz member + 'create issues').
- issue.update (by server id; authz member + 'edit issues'; sets resolved_at
  when resolved/closed; last-write-wins conflict).
- feature.update (by server id; authz member + 'update progress'; recomputes
  phase progress; last-write-wins conflict).
- Conflict detection: client_updated_at vs server updated_at → returns
  'conflict' with the current server value.
Added uuid + client_updated_at to features/inspections/issues (guarded migration)
and their fillables. Tests: 16 passing (added inspection/issue/feature + conflict).

Note: 2 PRE-EXISTING test failures remain (not from this work, sqlite-only):
ExampleTest expects '/'=200 (app redirects), and the dashboard route uses MySQL
FIELD() which sqlite lacks.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-18 10:09:34 +02:00
parent b5deb1c53a
commit 9d2b63c8f4
6 changed files with 371 additions and 33 deletions
@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
private array $tables = ['features', 'inspections', 'issues'];
public function up(): void
{
foreach ($this->tables as $name) {
Schema::table($name, function (Blueprint $table) use ($name) {
if (! Schema::hasColumn($name, 'uuid')) {
$table->uuid('uuid')->nullable()->unique()->after('id');
}
if (! Schema::hasColumn($name, 'client_updated_at')) {
$table->timestamp('client_updated_at')->nullable();
}
});
}
}
public function down(): void
{
foreach ($this->tables as $name) {
Schema::table($name, function (Blueprint $table) use ($name) {
foreach (['uuid', 'client_updated_at'] as $col) {
if (Schema::hasColumn($name, $col)) {
$table->dropColumn($col);
}
}
});
}
}
};