Moved back in time migration
This commit is contained in:
@@ -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
|
||||
|
||||
+1
-8
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user