Skip to content

A free open source IT asset/license management system

Added migrations to add archived and consumed_at to consumable tables

snipe951590f82de9
diff --git a/database/migrations/2026_10_19_120000_add_archived_to_consumables_table.php b/database/migrations/2026_10_19_120000_add_archived_to_consumables_table.php
new file mode 100644
index 0000000000..848cb24774
--- /dev/null
+++ b/database/migrations/2026_10_19_120000_add_archived_to_consumables_table.php
@@ -0,0 +1,25 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+ /**
+ * Add an `archived` flag to the consumables table.
+ */
+ public function up(): void
+ {
+ Schema::table('consumables', function (Blueprint $table) {
+ $table->boolean('archived')->default(0)->after('requestable')->index();
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::table('consumables', function (Blueprint $table) {
+ $table->dropColumn('archived');
+ });
+ }
+};
diff --git a/database/migrations/2026_10_19_120100_add_consumed_at_to_consumables_users_table.php b/database/migrations/2026_10_19_120100_add_consumed_at_to_consumables_users_table.php
new file mode 100644
index 0000000000..930443120e
--- /dev/null
+++ b/database/migrations/2026_10_19_120100_add_consumed_at_to_consumables_users_table.php
@@ -0,0 +1,30 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+ /**
+ * Add `consumed_at` to the consumables_users pivot. Null means the
+ * recipient has not yet reported the issued unit as used up, so the
+ * row still counts against the parent consumable's "outstanding"
+ * total for archive and delete gating. Existing rows backfill as
+ * null, which treats every historical distribution as outstanding
+ * until an admin marks it consumed.
+ */
+ public function up(): void
+ {
+ Schema::table('consumables_users', function (Blueprint $table) {
+ $table->timestamp('consumed_at')->nullable()->default(null)->after('note')->index();
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::table('consumables_users', function (Blueprint $table) {
+ $table->dropColumn('consumed_at');
+ });
+ }
+};