Skip to content

A free open source IT asset/license management system

Added comments

snipe2537d0fdaf3c
diff --git a/app/Observers/AssetObserver.php b/app/Observers/AssetObserver.php
index 55542ff2eb..c15c54a568 100644
--- a/app/Observers/AssetObserver.php
+++ b/app/Observers/AssetObserver.php
@@ -129,7 +129,8 @@ class AssetObserver
*
* For example, if there is a database migration that's a bit older and modifies an asset, if the save
* fires before a field gets created in a later migration and that field in the later migration
- * is used in this observer, it doesn't actually exist yet and the migration will break.
+ * is used in this observer, it doesn't actually exist yet and the migration will break unless we
+ * use saveQuietly() in the migration which skips this observer.
*
* @see https://github.com/snipe/snipe-it/issues/13723#issuecomment-1761315938
*/
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 550f6f335b..d20d47d440 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
@@ -23,6 +23,8 @@ class AddEolDateOnAssetsTable extends Migration
});
// Chunk the model query to get the models that do have an EOL date
+ // We use saveQuietly() here to skip the AssetObserver, since it modifies fields
+ // that do not yet exist on the assets table.
AssetModel::whereNotNull('eol')->chunk(10, function ($models) {
foreach ($models as $model) {
foreach ($model->assets as $asset) {