id(); $table->foreignId('village_id')->constrained()->cascadeOnDelete(); $table->foreignId('home_village_id')->constrained('villages')->cascadeOnDelete(); $table->string('unit', 32); $table->unsignedInteger('count')->default(0); $table->timestamps(); $table->unique(['village_id', 'home_village_id', 'unit']); }); // One queue per military building instance. Times are fixed when queued, so units // arrive lazily: done = floor((now − starts_at) / seconds_per_unit). Schema::create('recruit_orders', function (Blueprint $table) { $table->id(); $table->foreignId('village_id')->constrained()->cascadeOnDelete(); $table->foreignId('building_id')->constrained()->cascadeOnDelete(); $table->string('unit', 32); $table->unsignedInteger('count'); $table->unsignedInteger('done')->default(0); $table->unsignedInteger('seconds_per_unit'); // Per unit, refunded for the ones not trained when cancelled. $table->json('cost'); $table->dateTime('starts_at', 3); $table->dateTime('finishes_at', 3); $table->timestamps(); }); } public function down(): void { Schema::dropIfExists('recruit_orders'); Schema::dropIfExists('unit_stacks'); } };