feat(inventory): track administrative entry reservations
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
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::table('inventories', function (Blueprint $table): void {
|
||||
$table->unsignedInteger('entry_reserved_stock')->default(0);
|
||||
});
|
||||
Schema::create('desfile_reservation_batches', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained('users')->restrictOnDelete();
|
||||
$table->string('tenant_code');
|
||||
$table->uuid('idempotency_key');
|
||||
$table->string('request_hash', 64);
|
||||
$table->timestamps();
|
||||
$table->unique(['user_id', 'idempotency_key']);
|
||||
});
|
||||
Schema::table('desfile_entry_reservations', function (Blueprint $table): void {
|
||||
$table->foreignId('batch_id')->nullable()->constrained('desfile_reservation_batches')->restrictOnDelete();
|
||||
$table->foreignId('ticket_id')->nullable()->unique()->constrained('tickets')->restrictOnDelete();
|
||||
$table->foreignId('inventory_id')->nullable()->constrained('inventories')->restrictOnDelete();
|
||||
});
|
||||
// Legacy reservations remain excluded by visibleVariants(). Their past stock
|
||||
// movements cannot be inferred safely; only new reservations use this counter.
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('desfile_entry_reservations', function (Blueprint $table): void {
|
||||
$table->dropConstrainedForeignId('batch_id');
|
||||
$table->dropUnique(['ticket_id']);
|
||||
$table->dropConstrainedForeignId('ticket_id');
|
||||
$table->dropConstrainedForeignId('inventory_id');
|
||||
});
|
||||
Schema::dropIfExists('desfile_reservation_batches');
|
||||
Schema::table('inventories', fn (Blueprint $table) => $table->dropColumn('entry_reserved_stock'));
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user