Skip to content

A free open source IT asset/license management system

Removed DB uniqueness constraint

snipe6d58d982ac29
diff --git a/database/migrations/2026_09_01_212858_create_asset_external_sources_table.php b/database/migrations/2026_09_01_212858_create_asset_external_sources_table.php
index c92ead51d2..381fea7604 100644
--- a/database/migrations/2026_09_01_212858_create_asset_external_sources_table.php
+++ b/database/migrations/2026_09_01_212858_create_asset_external_sources_table.php
@@ -16,15 +16,12 @@ return new class extends Migration
// vendor-populated data can grow without widening the row
// and eating custom-field headroom.
//
- // Cardinality: one row per (source, external_id) pair
- // enforced by the unique index below. asset_id is only
- // indexed, not unique, so future adoption / multi-source
- // features (linking one physical device across two adapters,
- // migrating an existing Snipe-IT asset into a new MDM
- // without losing history) can add rows without a schema
- // migration. The Asset::externalSource() relation stays
- // hasOne while the sync path only writes one row per asset.
- // It flips to hasMany when we add the adoption UI.
+ // Cardinality: one row per (source, external_id) pair,
+ // enforced by the unique index below. asset_id is indexed
+ // but not unique so the same physical device can be linked
+ // across multiple adapters without a schema migration (an
+ // admin running Fleet AND Kandji sees the same MacBook in
+ // both).
Schema::create('asset_external_sources', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('company_id')->nullable()->index();
@@ -36,16 +33,8 @@ return new class extends Migration
$table->string('os', 191)->nullable();
$table->string('os_version', 191)->nullable();
$table->timestamp('last_seen')->nullable()->index();
- // Who created this source row. NULL for CLI-triggered
- // sync runs (no auth context) and for background /
- // scheduled runs. Populated with auth()->id() when the
- // sync fires from the interactive Sync Now button.
$table->unsignedBigInteger('created_by')->nullable()->index();
$table->timestamps();
- // Prevents duplicate sync rows from re-syncing the same
- // vendor-side device. The (source, external_id) pair is
- // the identity key SyncHostFromAdapter uses to decide
- // upsert vs create.
$table->unique(['source', 'external_id']);
});
}