Skip to content

A free open source IT asset/license management system

Deleted earlier migrations

snipe6c3d478e73a5
diff --git a/database/migrations/2026_07_28_000001_add_order_number_to_action_logs.php b/database/migrations/2026_07_28_000001_add_order_number_to_action_logs.php
deleted file mode 100644
index 146e34e1a3..0000000000
--- a/database/migrations/2026_07_28_000001_add_order_number_to_action_logs.php
+++ /dev/null
@@ -1,26 +0,0 @@
-<?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('action_logs', function (Blueprint $table) {
- if (! Schema::hasColumn('action_logs', 'order_number')) {
- $table->string('order_number')->nullable()->after('note');
- }
- });
- }
-
- public function down(): void
- {
- Schema::table('action_logs', function (Blueprint $table) {
- if (Schema::hasColumn('action_logs', 'order_number')) {
- $table->dropColumn('order_number');
- }
- });
- }
-};
diff --git a/database/migrations/2026_07_28_000002_backfill_order_number_on_action_logs.php b/database/migrations/2026_07_28_000002_backfill_order_number_on_action_logs.php
deleted file mode 100644
index 54287730f7..0000000000
--- a/database/migrations/2026_07_28_000002_backfill_order_number_on_action_logs.php
+++ /dev/null
@@ -1,73 +0,0 @@
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Support\Facades\DB;
-
-/**
- * Backfill for existing accessory / consumable / component action_logs.
- *
- * Two fields get filled from the parent's current row:
- *
- * 1. order_number on create and update rows. The parent's stored value
- * replaces null in the log. Rows where the observer eventually
- * populated order_number correctly stay untouched (idempotent via
- * whereNull).
- * 2. quantity on create rows. The observers only started capturing the
- * initial on-hand qty at write time in the AdjustsQuantity work, so
- * any pre-existing create log has quantity = 0. Backfill from the
- * parent's current qty column. Only touches rows where quantity is
- * null or 0 so re-runs and observer-written rows stay untouched.
- *
- * Both use the item's CURRENT parent-column state, not the true
- * at-log-time state — any item edited or adjusted since the log was
- * written picks up the newer value. Acceptable one-time trade-off;
- * new log entries are accurate because the observers now capture at
- * write time.
- */
-return new class extends Migration
-{
- public function up(): void
- {
- $prefix = DB::getTablePrefix();
-
- foreach ([
- \App\Models\Accessory::class => 'accessories',
- \App\Models\Consumable::class => 'consumables',
- \App\Models\Component::class => 'components',
- ] as $modelClass => $table) {
- DB::table('action_logs')
- ->where('item_type', $modelClass)
- ->whereIn('action_type', ['create', 'update'])
- ->whereNull('order_number')
- ->update([
- 'order_number' => DB::raw(
- "(SELECT order_number FROM {$prefix}{$table} "
- ."WHERE {$prefix}{$table}.id = {$prefix}action_logs.item_id "
- .'LIMIT 1)'
- ),
- ]);
-
- DB::table('action_logs')
- ->where('item_type', $modelClass)
- ->where('action_type', 'create')
- ->where(function ($q) {
- $q->whereNull('quantity')->orWhere('quantity', 0);
- })
- ->update([
- 'quantity' => DB::raw(
- "(SELECT qty FROM {$prefix}{$table} "
- ."WHERE {$prefix}{$table}.id = {$prefix}action_logs.item_id "
- .'LIMIT 1)'
- ),
- ]);
- }
- }
-
- public function down(): void
- {
- // No-op: we can't distinguish backfilled rows from ones the
- // observer wrote after the fact, so undoing would risk erasing
- // real order references. If you truly need to reverse, run the
- // schema-drop migration instead (which drops the column).
- }
-};
diff --git a/database/migrations/2026_07_29_000001_index_order_number_on_action_logs.php b/database/migrations/2026_07_29_000001_index_order_number_on_action_logs.php
deleted file mode 100644
index 450ed92dde..0000000000
--- a/database/migrations/2026_07_29_000001_index_order_number_on_action_logs.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-/**
- * Index action_logs.order_number so the history-tab search (which sends
- * WHERE order_number LIKE ?) and the column-sort (ORDER BY order_number)
- * don't sequential-scan a table that grows unbounded on busy installs.
- * Search is a prefix LIKE via the bootstrap-table search box, so a plain
- * btree index is enough — no fulltext needed.
- */
-return new class extends Migration
-{
- public function up(): void
- {
- Schema::table('action_logs', function (Blueprint $table) {
- $table->index('order_number');
- $table->index(['item_type', 'item_id', 'quantity']);
- });
- }
-
- public function down(): void
- {
- Schema::table('action_logs', function (Blueprint $table) {
- $table->dropIndex(['order_number']);
- });
- }
-};