Skip to content

A free open source IT asset/license management system

Moved back in time migration

snipef142eb7a445c
diff --git a/database/migrations/2023_01_21_225350_add_eol_date_on_assets_table.php b/database/migrations/2023_01_21_225350_add_eol_date_on_assets_table.php
index e28bd1af9b..b333b65238 100644
--- a/database/migrations/2023_01_21_225350_add_eol_date_on_assets_table.php
+++ b/database/migrations/2023_01_21_225350_add_eol_date_on_assets_table.php
@@ -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
diff --git a/database/migrations/2023_07_13_052204_denormalized_eol_and_add_column_for_explicit_date_to_assets.php b/database/migrations/2023_07_13_052204_denormalized_eol_and_add_column_for_explicit_date_to_assets.php
index ef247433b1..ab9037fabb 100644
--- a/database/migrations/2023_07_13_052204_denormalized_eol_and_add_column_for_explicit_date_to_assets.php
+++ b/database/migrations/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) {