Moved back in time migration

This commit is contained in:
snipe
2026-04-15 21:29:26 +01:00
parent 495382c42f
commit f142eb7a44
2 changed files with 9 additions and 8 deletions
@@ -22,6 +22,14 @@ class AddEolDateOnAssetsTable extends Migration
$table->date('asset_eol_date')->after('purchase_date')->nullable()->default(null);
}
// This is a back in time migration to fix restores from very old versions of Snipe-IT where
// companies were not soft-deletable.
Schema::table('companies', function (Blueprint $table) {
if (!Schema::hasColumn('companies', 'deleted_at')) {
$table->softDeletes();
}
});
// This is a temporary shim so we don't have to modify the asset observer for migrations where
// there is a large version difference. (See the AssetObserver notes). This column gets created
// later in 2023_07_13_052204_denormalized_eol_and_add_column_for_explicit_date_to_assets.php
@@ -23,14 +23,7 @@ class DenormalizedEolAndAddColumnForExplicitDateToAssets extends Migration
$table->boolean('eol_explicit')->default(false)->after('asset_eol_date');
}
});
// This is a back in time migration to fix restores from very old versions of Snipe-IT where
// companies were not soft-deletable.
Schema::table('companies', function (Blueprint $table) {
if (! Schema::hasColumn('companies', 'deleted_at')) {
$table->softDeletes();
}
});
// Update the eol_explicit column with the value from asset_eol_date if it exists and is different from the calculated value
Asset::whereNotNull('asset_eol_date')->with('model')->chunkById(500, function ($assetsWithEolDates) {